Skip to content

Latest commit

 

History

History
587 lines (443 loc) · 43.7 KB

File metadata and controls

587 lines (443 loc) · 43.7 KB

Images

Overview

Custom machine images for nodes.

Available Operations

list

List all images owned by the authenticated user.

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<operations.ListImagesResponse>

Errors

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 */*

startUpload

Create an image and start a multipart upload.

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<models.ImageUploadResponse>

Errors

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 */*

fetch

Retrieve an image by ID. Returns both user-owned and public images.

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<models.ImageListEntry>

Errors

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

Delete an image. This is a soft delete.

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<models.DeleteImageResponse>

Errors

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 */*

completeUpload

Complete a multipart image upload after all parts have been uploaded.

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<models.ImageUploadResponse>

Errors

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 */*

download

Get a presigned URL to download an image. Works for both user-owned and public images.

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<models.ImageDownloadResponse>

Errors

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 */*

uploadPart

Get a presigned URL to upload a part of a multipart image upload.

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<models.UploadPartResponse>

Errors

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 */*