Skip to content

Latest commit

 

History

History
349 lines (269 loc) · 20.8 KB

File metadata and controls

349 lines (269 loc) · 20.8 KB

Deployments

Overview

Deployment automations that maintain a fleet of instances on a capacity.

Available Operations

List

List all deployments.

Example Usage

package main

import(
	"context"
	sfc "github.com/sfcompute/sfc-go"
	"github.com/sfcompute/sfc-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := sfc.New(
        sfc.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    res, err := s.Deployments.List(ctx, operations.ListDeploymentsRequest{
        Workspace: "wksp_k3R-nX9vLm7Qp2Yw5Jd8F",
        Capacity: sfc.Pointer("cap_k3R-nX9vLm7Qp2Yw5Jd8F"),
        StartingAfter: sfc.Pointer("deplc_gqXR7s0Kj5mHvE2wNpLc4Q"),
        EndingBefore: sfc.Pointer("deplc_gqXR7s0Kj5mHvE2wNpLc4Q"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.ListDeploymentsResponse != nil {
        for {
            // handle items

            res, err = res.Next()

            if err != nil {
                // handle error
            }

            if res == nil {
                break
            }
        }
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.ListDeploymentsRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.ListDeploymentsResponse, error

Errors

Error Type Status Code Content Type
apierrors.UnauthorizedError 401 application/json
apierrors.UnprocessableEntityError 422 application/json
apierrors.InternalServerError 500 application/json
apierrors.APIError 4XX, 5XX */*

Create

Create a deployment for bulk node management.

Example Usage

package main

import(
	"context"
	sfc "github.com/sfcompute/sfc-go"
	"github.com/sfcompute/sfc-go/optionalnullable"
	"github.com/sfcompute/sfc-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := sfc.New(
        sfc.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    res, err := s.Deployments.Create(ctx, components.CreateDeploymentRequest{
        Name: optionalnullable.From(sfc.Pointer("my-resource-name")),
        Capacity: "cap_k3R-nX9vLm7Qp2Yw5Jd8F",
        InstanceTemplate: "ntmpl_k3R-nX9vLm7Qp2Yw5Jd8F",
        TargetInstanceCount: 384760,
        InstanceNameTemplate: sfc.Pointer("my-fleet-{{nanoid(9)}}"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.DeploymentResponse != nil {
        switch res.DeploymentResponse.Capacity.Type {
            case components.ExpandableCapacityIDCapacitySummaryUnionTypeStr:
                // res.DeploymentResponse.Capacity.Str is populated
            case components.ExpandableCapacityIDCapacitySummaryUnionTypeExpandableCapacityIDCapacitySummary:
                // res.DeploymentResponse.Capacity.ExpandableCapacityIDCapacitySummary is populated
            default:
                // Unknown type - use res.DeploymentResponse.Capacity.GetUnknownRaw() for raw JSON
        }

    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.CreateDeploymentRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.CreateDeploymentResponse, error

Errors

Error Type Status Code Content Type
apierrors.BadRequestError 400 application/json
apierrors.UnauthorizedError 401 application/json
apierrors.ForbiddenError 403 application/json
apierrors.NotFoundError 404 application/json
apierrors.UnprocessableEntityError 422 application/json
apierrors.InternalServerError 500 application/json
apierrors.APIError 4XX, 5XX */*

GetDeployment

Retrieve a deployment by ID or name.

Example Usage

package main

import(
	"context"
	sfc "github.com/sfcompute/sfc-go"
	"log"
	"github.com/sfcompute/sfc-go/models/components"
)

func main() {
    ctx := context.Background()

    s := sfc.New(
        sfc.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    res, err := s.Deployments.GetDeployment(ctx, "depl_k3R-nX9vLm7Qp2Yw5Jd8F", nil)
    if err != nil {
        log.Fatal(err)
    }
    if res.DeploymentResponse != nil {
        switch res.DeploymentResponse.Capacity.Type {
            case components.ExpandableCapacityIDCapacitySummaryUnionTypeStr:
                // res.DeploymentResponse.Capacity.Str is populated
            case components.ExpandableCapacityIDCapacitySummaryUnionTypeExpandableCapacityIDCapacitySummary:
                // res.DeploymentResponse.Capacity.ExpandableCapacityIDCapacitySummary is populated
            default:
                // Unknown type - use res.DeploymentResponse.Capacity.GetUnknownRaw() for raw JSON
        }

    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A depl_k3R-nX9vLm7Qp2Yw5Jd8F
expand []operations.GetDeploymentExpand N/A
opts []operations.Option The options for this request.

Response

*operations.GetDeploymentResponse, error

Errors

Error Type Status Code Content Type
apierrors.UnauthorizedError 401 application/json
apierrors.NotFoundError 404 application/json
apierrors.InternalServerError 500 application/json
apierrors.APIError 4XX, 5XX */*

Delete

Delete a deployment.

Example Usage

package main

import(
	"context"
	sfc "github.com/sfcompute/sfc-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := sfc.New(
        sfc.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    res, err := s.Deployments.Delete(ctx, "depl_k3R-nX9vLm7Qp2Yw5Jd8F")
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A depl_k3R-nX9vLm7Qp2Yw5Jd8F
opts []operations.Option The options for this request.

Response

*operations.DeleteDeploymentResponse, error

Errors

Error Type Status Code Content Type
apierrors.UnauthorizedError 401 application/json
apierrors.ForbiddenError 403 application/json
apierrors.NotFoundError 404 application/json
apierrors.InternalServerError 500 application/json
apierrors.APIError 4XX, 5XX */*

PatchDeployment

Update a deployment's configuration.

Example Usage

package main

import(
	"context"
	sfc "github.com/sfcompute/sfc-go"
	"github.com/sfcompute/sfc-go/optionalnullable"
	"github.com/sfcompute/sfc-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := sfc.New(
        sfc.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    res, err := s.Deployments.PatchDeployment(ctx, "depl_k3R-nX9vLm7Qp2Yw5Jd8F", components.PatchDeploymentRequest{
        Name: optionalnullable.From(sfc.Pointer("my-resource-name")),
        InstanceTemplate: optionalnullable.From(sfc.Pointer("ntmpl_k3R-nX9vLm7Qp2Yw5Jd8F")),
        InstanceNameTemplate: optionalnullable.From(sfc.Pointer("my-fleet-{{nanoid(9)}}")),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.DeploymentResponse != nil {
        switch res.DeploymentResponse.Capacity.Type {
            case components.ExpandableCapacityIDCapacitySummaryUnionTypeStr:
                // res.DeploymentResponse.Capacity.Str is populated
            case components.ExpandableCapacityIDCapacitySummaryUnionTypeExpandableCapacityIDCapacitySummary:
                // res.DeploymentResponse.Capacity.ExpandableCapacityIDCapacitySummary is populated
            default:
                // Unknown type - use res.DeploymentResponse.Capacity.GetUnknownRaw() for raw JSON
        }

    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A depl_k3R-nX9vLm7Qp2Yw5Jd8F
body components.PatchDeploymentRequest ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.PatchDeploymentResponse, error

Errors

Error Type Status Code Content Type
apierrors.BadRequestError 400 application/json
apierrors.UnauthorizedError 401 application/json
apierrors.ForbiddenError 403 application/json
apierrors.NotFoundError 404 application/json
apierrors.UnprocessableEntityError 422 application/json
apierrors.InternalServerError 500 application/json
apierrors.APIError 4XX, 5XX */*