Custom machine images for instances.
- List - List images
- StartUpload - Create image
- Fetch - Get image
- Delete - Delete image
- CompleteUpload - Complete image upload
- Download - Download image
- UploadPart - Get upload part URL
List all images owned by the authenticated user.
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.Images.List(ctx, operations.ListImagesRequest{
Workspace: "wksp_k3R-nX9vLm7Qp2Yw5Jd8F",
ID: []string{
"image_k3R-nX9vLm7Qp2Yw5Jd8F",
},
StartingAfter: sfc.Pointer("imagec_gqXR7s0Kj5mHvE2wNpLc4Q"),
EndingBefore: sfc.Pointer("imagec_gqXR7s0Kj5mHvE2wNpLc4Q"),
})
if err != nil {
log.Fatal(err)
}
if res.ListImagesResponse != 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.ListImagesRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.ListImagesResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestError | 400 | application/json |
| apierrors.UnauthorizedError | 401 | application/json |
| apierrors.InternalServerError | 500 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Create an image and start a multipart upload.
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.Images.StartUpload(ctx, components.StartUploadRequest{
Name: optionalnullable.From(sfc.Pointer("my-resource-name")),
Workspace: "wksp_k3R-nX9vLm7Qp2Yw5Jd8F",
})
if err != nil {
log.Fatal(err)
}
if res.ImageUploadResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.StartUploadRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CreateImageResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestError | 400 | application/json |
| apierrors.UnauthorizedError | 401 | application/json |
| apierrors.ConflictError | 409 | application/json |
| apierrors.InternalServerError | 500 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Retrieve an image by ID. Returns both user-owned and public images.
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.Images.Fetch(ctx, "image_k3R-nX9vLm7Qp2Yw5Jd8F")
if err != nil {
log.Fatal(err)
}
if res.ImageListEntry != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
id |
string |
✔️ | Image ID or resource path | image_k3R-nX9vLm7Qp2Yw5Jd8F |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.FetchImageResponse, 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 an image.
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.Images.Delete(ctx, "image_k3R-nX9vLm7Qp2Yw5Jd8F")
if err != nil {
log.Fatal(err)
}
if res.DeleteImageResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
id |
string |
✔️ | Image ID, name, or resource path | image_k3R-nX9vLm7Qp2Yw5Jd8F |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.DeleteImageResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.UnauthorizedError | 401 | application/json |
| apierrors.NotFoundError | 404 | application/json |
| apierrors.ConflictError | 409 | application/json |
| apierrors.InternalServerError | 500 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Finalize a multipart image upload.
package main
import(
"context"
sfc "github.com/sfcompute/sfc-go"
"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.Images.CompleteUpload(ctx, "image_k3R-nX9vLm7Qp2Yw5Jd8F", components.CompleteUploadRequest{
Sha256: "<value>",
})
if err != nil {
log.Fatal(err)
}
if res.ImageUploadResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
id |
string |
✔️ | Image ID, name, or resource path | image_k3R-nX9vLm7Qp2Yw5Jd8F |
body |
components.CompleteUploadRequest | ✔️ | N/A | |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CompleteImageUploadResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestError | 400 | application/json |
| apierrors.UnauthorizedError | 401 | application/json |
| apierrors.NotFoundError | 404 | application/json |
| apierrors.InternalServerError | 500 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Get a presigned URL to download an image.
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.Images.Download(ctx, "image_k3R-nX9vLm7Qp2Yw5Jd8F")
if err != nil {
log.Fatal(err)
}
if res.ImageDownloadResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
id |
string |
✔️ | Image ID, name, or resource path | image_k3R-nX9vLm7Qp2Yw5Jd8F |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.DownloadImageResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.UnauthorizedError | 401 | application/json |
| apierrors.NotFoundError | 404 | application/json |
| apierrors.ConflictError | 409 | application/json |
| apierrors.InternalServerError | 500 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Get a presigned URL to upload one part of a multipart image upload.
package main
import(
"context"
sfc "github.com/sfcompute/sfc-go"
"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.Images.UploadPart(ctx, "image_k3R-nX9vLm7Qp2Yw5Jd8F", components.UploadPartRequest{
PartID: 797058,
})
if err != nil {
log.Fatal(err)
}
if res.UploadPartResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
id |
string |
✔️ | Image ID, name, or resource path | image_k3R-nX9vLm7Qp2Yw5Jd8F |
body |
components.UploadPartRequest | ✔️ | N/A | |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CreateImageUploadPartURLResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestError | 400 | application/json |
| apierrors.UnauthorizedError | 401 | application/json |
| apierrors.NotFoundError | 404 | application/json |
| apierrors.InternalServerError | 500 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |