Deployment automations that maintain a fleet of instances on a capacity.
- List - List deployments
- Create - Create deployment
- GetDeployment - Get deployment
- Delete - Delete deployment
- PatchDeployment - Update deployment
List all deployments.
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
}
}
}
}| 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. |
*operations.ListDeploymentsResponse, error
| 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 a deployment for bulk node management.
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
}
}
}| 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. |
*operations.CreateDeploymentResponse, error
| 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 | */* |
Retrieve a deployment by ID or name.
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
}
}
}| 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. |
*operations.GetDeploymentResponse, error
| 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 a deployment.
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
}
}| 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. |
*operations.DeleteDeploymentResponse, error
| 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 | */* |
Update a deployment's configuration.
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
}
}
}| 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. |
*operations.PatchDeploymentResponse, error
| 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 | */* |