Place orders targeting a capacity to increase your reserved compute balance during some time period.
List all orders.
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.Orders.List(ctx, operations.ListOrdersRequest{
ID: []string{
"ordr_k3R-nX9vLm7Qp2Yw5Jd8F",
},
Capacity: sfc.Pointer("cap_k3R-nX9vLm7Qp2Yw5Jd8F"),
CreatedAfter: sfc.Pointer[int64](1738972800),
CreatedBefore: sfc.Pointer[int64](1738972800),
StartingAfter: sfc.Pointer("ordrc_gqXR7s0Kj5mHvE2wNpLc4Q"),
EndingBefore: sfc.Pointer("ordrc_gqXR7s0Kj5mHvE2wNpLc4Q"),
})
if err != nil {
log.Fatal(err)
}
if res.V2ListOrdersResponse != 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.ListOrdersRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.ListOrdersResponse, 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 | */* |
Place a buy or sell order. Orders fill completely or not at all. All nodes fill on a single instance SKU matching the order's requirements. Order filling is asynchronous; poll GET /v2/orders/{id} to check status.
package main
import(
"context"
sfc "github.com/sfcompute/sfc-go"
"github.com/sfcompute/sfc-go/models/components"
"github.com/sfcompute/sfc-go/optionalnullable"
"log"
)
func main() {
ctx := context.Background()
s := sfc.New(
sfc.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
res, err := s.Orders.Create(ctx, components.V2CreateOrderRequest{
Capacity: "cap_k3R-nX9vLm7Qp2Yw5Jd8F",
Side: components.SideSell,
InstanceSku: "isku_k3R-nX9vLm7Qp2Yw5Jd8F",
Delta: components.CreateV2CreateOrderRequestDeltaUnionV2CreateOrderRequestDeltaRectangle(
components.V2CreateOrderRequestDeltaRectangle{
NodeCount: 387888,
StartAt: 1738972800,
EndAt: 1738972800,
},
),
LimitPriceDollarsPerNodeHour: "2.500000",
}, optionalnullable.From[string](nil))
if err != nil {
log.Fatal(err)
}
if res.V2OrderResponse != nil {
switch res.V2OrderResponse.Capacity.Type {
case components.ExpandableCapacityIDCapacitySummaryUnionTypeStr:
// res.V2OrderResponse.Capacity.Str is populated
case components.ExpandableCapacityIDCapacitySummaryUnionTypeExpandableCapacityIDCapacitySummary:
// res.V2OrderResponse.Capacity.ExpandableCapacityIDCapacitySummary is populated
default:
// Unknown type - use res.V2OrderResponse.Capacity.GetUnknownRaw() for raw JSON
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
body |
components.V2CreateOrderRequest | ✔️ | N/A |
idempotencyKey |
optionalnullable.OptionalNullable[string] |
➖ | Unique key to ensure idempotent order creation. If provided, duplicate requests with the same key will not place a new order and return the original order. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CreateOrderResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.UnauthorizedError | 401 | application/json |
| apierrors.PaymentRequiredError | 402 | application/json |
| apierrors.ForbiddenError | 403 | application/json |
| apierrors.NotFoundError | 404 | application/json |
| apierrors.UnprocessableEntityError | 422 | application/json |
| apierrors.InternalServerError | 500 | application/json |
| apierrors.ServiceUnavailableError | 503 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Retrieve an order by ID.
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.Orders.Fetch(ctx, "ordr_xyz789", nil)
if err != nil {
log.Fatal(err)
}
if res.V2OrderResponse != nil {
switch res.V2OrderResponse.Capacity.Type {
case components.ExpandableCapacityIDCapacitySummaryUnionTypeStr:
// res.V2OrderResponse.Capacity.Str is populated
case components.ExpandableCapacityIDCapacitySummaryUnionTypeExpandableCapacityIDCapacitySummary:
// res.V2OrderResponse.Capacity.ExpandableCapacityIDCapacitySummary is populated
default:
// Unknown type - use res.V2OrderResponse.Capacity.GetUnknownRaw() for raw JSON
}
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
id |
string |
✔️ | Order ID | ordr_k3R-nX9vLm7Qp2Yw5Jd8F |
expand |
[]string |
➖ | N/A | |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.FetchOrderResponse, 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 | */* |
Request cancellation of an order. This is asynchronous — poll GET /v2/orders/{id} to confirm the status has changed to cancelled.
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.Orders.Cancel(ctx, "ordr_xyz789")
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 |
✔️ | Order ID | ordr_k3R-nX9vLm7Qp2Yw5Jd8F |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CancelOrderResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.UnauthorizedError | 401 | application/json |
| apierrors.NotFoundError | 404 | application/json |
| apierrors.UnprocessableEntityError | 422 | application/json |
| apierrors.InternalServerError | 500 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |