A bucket of owned compute balance over time.
- list - List capacities
- create - Create capacity
- fetch - Get capacity
- delete - Delete capacity
- update - Update capacity
List all capacities.
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.capacities.list({
startingAfter: "capc_gqXR7s0Kj5mHvE2wNpLc4Q",
endingBefore: "capc_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 { capacitiesList } from "@sfcompute/sdk/funcs/capacities-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 capacitiesList(sfc, {
startingAfter: "capc_gqXR7s0Kj5mHvE2wNpLc4Q",
endingBefore: "capc_gqXR7s0Kj5mHvE2wNpLc4Q",
});
if (res.ok) {
const { value: result } = res;
for await (const page of result) {
console.log(page);
}
} else {
console.log("capacitiesList failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.ListCapacitiesRequest | ✔️ | 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.ListCapacitiesResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedError | 401 | application/json |
| errors.UnprocessableEntityError | 422 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SfcDefaultError | 4XX, 5XX | */* |
Create a capacity to hold compute in specified zones.
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.capacities.create({
name: "my-resource-name",
zones: [
"richmond",
],
nodeTemplate: "ntmpl_k3R-nX9vLm7Qp2Yw5Jd8F",
startNodesAutomatically: false,
scheduler: {
desiredQuantity: 152218,
managedWindowMinutes: 424047,
minSellPriceDollarsPerNodeHour: "2.500000",
maxBuyPriceDollarsPerNodeHour: "2.500000",
enabled: false,
},
});
console.log(result);
}
run();The standalone function version of this method:
import { SfcCore } from "@sfcompute/sdk/core.js";
import { capacitiesCreate } from "@sfcompute/sdk/funcs/capacities-create.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 capacitiesCreate(sfc, {
name: "my-resource-name",
zones: [
"richmond",
],
nodeTemplate: "ntmpl_k3R-nX9vLm7Qp2Yw5Jd8F",
startNodesAutomatically: false,
scheduler: {
desiredQuantity: 152218,
managedWindowMinutes: 424047,
minSellPriceDollarsPerNodeHour: "2.500000",
maxBuyPriceDollarsPerNodeHour: "2.500000",
enabled: false,
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("capacitiesCreate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
models.CreateCapacityRequest | ✔️ | 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.CapacityResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedError | 401 | application/json |
| errors.ForbiddenError | 403 | application/json |
| errors.UnprocessableEntityError | 422 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SfcDefaultError | 4XX, 5XX | */* |
Retrieve a capacity by ID or name, including its compute schedule and scheduler configuration.
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.capacities.fetch({
id: "cap_k3R-nX9vLm7Qp2Yw5Jd8F",
});
console.log(result);
}
run();The standalone function version of this method:
import { SfcCore } from "@sfcompute/sdk/core.js";
import { capacitiesFetch } from "@sfcompute/sdk/funcs/capacities-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 capacitiesFetch(sfc, {
id: "cap_k3R-nX9vLm7Qp2Yw5Jd8F",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("capacitiesFetch failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.FetchCapacityRequest | ✔️ | 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.CapacityResponse>
| 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 a capacity. The capacity must be empty and the scheduler must be disabled or absent.
import { Sfc } from "@sfcompute/sdk";
const sfc = new Sfc({
serverURL: "https://api.example.com",
bearerAuth: process.env["SFC_BEARER_AUTH"] ?? "",
});
async function run() {
await sfc.capacities.delete({
id: "cap_k3R-nX9vLm7Qp2Yw5Jd8F",
});
}
run();The standalone function version of this method:
import { SfcCore } from "@sfcompute/sdk/core.js";
import { capacitiesDelete } from "@sfcompute/sdk/funcs/capacities-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 capacitiesDelete(sfc, {
id: "cap_k3R-nX9vLm7Qp2Yw5Jd8F",
});
if (res.ok) {
const { value: result } = res;
} else {
console.log("capacitiesDelete failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.DeleteCapacityRequest | ✔️ | 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<void>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedError | 401 | application/json |
| errors.ForbiddenError | 403 | application/json |
| errors.NotFoundError | 404 | application/json |
| errors.UnprocessableEntityError | 422 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SfcDefaultError | 4XX, 5XX | */* |
Update a capacity. Omitted fields are left unchanged.
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.capacities.update({
id: "cap_k3R-nX9vLm7Qp2Yw5Jd8F",
body: {
zones: [
"richmond",
],
scheduler: {
desiredQuantity: 436706,
managedWindowMinutes: 661494,
minSellPriceDollarsPerNodeHour: "2.500000",
maxBuyPriceDollarsPerNodeHour: "2.500000",
enabled: true,
},
},
});
console.log(result);
}
run();The standalone function version of this method:
import { SfcCore } from "@sfcompute/sdk/core.js";
import { capacitiesUpdate } from "@sfcompute/sdk/funcs/capacities-update.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 capacitiesUpdate(sfc, {
id: "cap_k3R-nX9vLm7Qp2Yw5Jd8F",
body: {
zones: [
"richmond",
],
scheduler: {
desiredQuantity: 436706,
managedWindowMinutes: 661494,
minSellPriceDollarsPerNodeHour: "2.500000",
maxBuyPriceDollarsPerNodeHour: "2.500000",
enabled: true,
},
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("capacitiesUpdate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.UpdateCapacityRequest | ✔️ | 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.CapacityResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedError | 401 | application/json |
| errors.ForbiddenError | 403 | application/json |
| errors.NotFoundError | 404 | application/json |
| errors.UnprocessableEntityError | 422 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SfcDefaultError | 4XX, 5XX | */* |