Custom machine images for nodes.
- list - List images
- startUpload - Create image
- fetch - Get image
- delete - Delete image
- completeUpload - Complete image upload
- download - Download image
- uploadPart - Create image upload part URL
List all images owned by the authenticated user.
import { Sfc } from "@sfcompute/sdk";
const sfc = new Sfc({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await sfc.images.list({
startingAfter: "imagec_gqXR7s0Kj5mHvE2wNpLc4Q",
endingBefore: "imagec_gqXR7s0Kj5mHvE2wNpLc4Q",
});
for await (const page of result) {
console.log(page);
}
}
run();The standalone function version of this method:
import { SfcCore } from "@sfcompute/sdk/core.js";
import { imagesList } from "@sfcompute/sdk/funcs/images-list.js";
// Use `SfcCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sfc = new SfcCore({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
const res = await imagesList(sfc, {
startingAfter: "imagec_gqXR7s0Kj5mHvE2wNpLc4Q",
endingBefore: "imagec_gqXR7s0Kj5mHvE2wNpLc4Q",
});
if (res.ok) {
const { value: result } = res;
for await (const page of result) {
console.log(page);
}
} else {
console.log("imagesList failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.ListImagesRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.ListImagesResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestError | 400 | application/json |
| errors.UnauthorizedError | 401 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SfcDefaultError | 4XX, 5XX | */* |
Create an image and start a multipart upload.
import { Sfc } from "@sfcompute/sdk";
const sfc = new Sfc({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await sfc.images.startUpload({
name: "my-resource-name",
});
console.log(result);
}
run();The standalone function version of this method:
import { SfcCore } from "@sfcompute/sdk/core.js";
import { imagesStartUpload } from "@sfcompute/sdk/funcs/images-start-upload.js";
// Use `SfcCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sfc = new SfcCore({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
const res = await imagesStartUpload(sfc, {
name: "my-resource-name",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("imagesStartUpload failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
models.StartUploadRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.ImageUploadResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestError | 400 | application/json |
| errors.UnauthorizedError | 401 | application/json |
| errors.ForbiddenError | 403 | application/json |
| errors.ConflictError | 409 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SfcDefaultError | 4XX, 5XX | */* |
Retrieve an image by ID. Returns both user-owned and public images.
import { Sfc } from "@sfcompute/sdk";
const sfc = new Sfc({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await sfc.images.fetch({
id: "image_k3R-nX9vLm7Qp2Yw5Jd8F",
});
console.log(result);
}
run();The standalone function version of this method:
import { SfcCore } from "@sfcompute/sdk/core.js";
import { imagesFetch } from "@sfcompute/sdk/funcs/images-fetch.js";
// Use `SfcCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sfc = new SfcCore({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
const res = await imagesFetch(sfc, {
id: "image_k3R-nX9vLm7Qp2Yw5Jd8F",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("imagesFetch failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.FetchImageRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.ImageListEntry>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedError | 401 | application/json |
| errors.NotFoundError | 404 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SfcDefaultError | 4XX, 5XX | */* |
Delete an image. This is a soft delete.
import { Sfc } from "@sfcompute/sdk";
const sfc = new Sfc({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await sfc.images.delete({
id: "image_k3R-nX9vLm7Qp2Yw5Jd8F",
});
console.log(result);
}
run();The standalone function version of this method:
import { SfcCore } from "@sfcompute/sdk/core.js";
import { imagesDelete } from "@sfcompute/sdk/funcs/images-delete.js";
// Use `SfcCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sfc = new SfcCore({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
const res = await imagesDelete(sfc, {
id: "image_k3R-nX9vLm7Qp2Yw5Jd8F",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("imagesDelete failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.DeleteImageRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.DeleteImageResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedError | 401 | application/json |
| errors.NotFoundError | 404 | application/json |
| errors.ConflictError | 409 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SfcDefaultError | 4XX, 5XX | */* |
Complete a multipart image upload after all parts have been uploaded.
import { Sfc } from "@sfcompute/sdk";
const sfc = new Sfc({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await sfc.images.completeUpload({
id: "image_k3R-nX9vLm7Qp2Yw5Jd8F",
body: {
sha256: "<value>",
},
});
console.log(result);
}
run();The standalone function version of this method:
import { SfcCore } from "@sfcompute/sdk/core.js";
import { imagesCompleteUpload } from "@sfcompute/sdk/funcs/images-complete-upload.js";
// Use `SfcCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sfc = new SfcCore({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
const res = await imagesCompleteUpload(sfc, {
id: "image_k3R-nX9vLm7Qp2Yw5Jd8F",
body: {
sha256: "<value>",
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("imagesCompleteUpload failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.CompleteImageUploadRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.ImageUploadResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestError | 400 | application/json |
| errors.UnauthorizedError | 401 | application/json |
| errors.ForbiddenError | 403 | application/json |
| errors.NotFoundError | 404 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SfcDefaultError | 4XX, 5XX | */* |
Get a presigned URL to download an image. Works for both user-owned and public images.
import { Sfc } from "@sfcompute/sdk";
const sfc = new Sfc({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await sfc.images.download({
id: "image_k3R-nX9vLm7Qp2Yw5Jd8F",
});
console.log(result);
}
run();The standalone function version of this method:
import { SfcCore } from "@sfcompute/sdk/core.js";
import { imagesDownload } from "@sfcompute/sdk/funcs/images-download.js";
// Use `SfcCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sfc = new SfcCore({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
const res = await imagesDownload(sfc, {
id: "image_k3R-nX9vLm7Qp2Yw5Jd8F",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("imagesDownload failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.DownloadImageRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.ImageDownloadResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedError | 401 | application/json |
| errors.NotFoundError | 404 | application/json |
| errors.ConflictError | 409 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SfcDefaultError | 4XX, 5XX | */* |
Get a presigned URL to upload a part of a multipart image upload.
import { Sfc } from "@sfcompute/sdk";
const sfc = new Sfc({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await sfc.images.uploadPart({
id: "image_k3R-nX9vLm7Qp2Yw5Jd8F",
body: {
partId: 797058,
},
});
console.log(result);
}
run();The standalone function version of this method:
import { SfcCore } from "@sfcompute/sdk/core.js";
import { imagesUploadPart } from "@sfcompute/sdk/funcs/images-upload-part.js";
// Use `SfcCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sfc = new SfcCore({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
const res = await imagesUploadPart(sfc, {
id: "image_k3R-nX9vLm7Qp2Yw5Jd8F",
body: {
partId: 797058,
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("imagesUploadPart failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.CreateImageUploadPartUrlRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.UploadPartResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestError | 400 | application/json |
| errors.UnauthorizedError | 401 | application/json |
| errors.ForbiddenError | 403 | application/json |
| errors.NotFoundError | 404 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SfcDefaultError | 4XX, 5XX | */* |