Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.1.0-alpha.1"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 10
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/the-san-francisco-compute-company%2Fsfc-nodes-b800806859333bacc88fa4236eae35c8cdbec62970b7fb9ad440a330f24a1622.yml
openapi_spec_hash: fa672b6ca8953a8059961a7559a607a9
config_hash: c41bbd00e07f543c79f5d6d61fbee825
configured_endpoints: 4
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/the-san-francisco-compute-company%2Fsfc-nodes-d41b5a590956acc71242ed938a212ee64655756fbd4c2af91db937f97f4fd4f5.yml
openapi_spec_hash: 19777fc4ebc8a243cf8ce3a9ad0e1da4
config_hash: e5ed8abf8452457d45fc10488ad15bd2
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Changelog

## 0.1.0-alpha.1 (2025-07-25)

Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/sfcompute/nodes-go/compare/v0.0.1-alpha.0...v0.1.0-alpha.1)

### Features

* **api:** api update ([f419ced](https://github.com/sfcompute/nodes-go/commit/f419ced0cd6952e529b1bcc031f37d2db0bad646))
* **api:** api update ([834cc67](https://github.com/sfcompute/nodes-go/commit/834cc67601b75f3312c1c7b039f60540b145d6b8))
* **api:** manually add new Nodes API models ([2e782e3](https://github.com/sfcompute/nodes-go/commit/2e782e38c064a41bbddbe8b32c077979e1312020))
* **api:** update via SDK Studio ([5a3ea36](https://github.com/sfcompute/nodes-go/commit/5a3ea36fb89e3c4cfcbe3b612644f98a5ae33e31))


### Bug Fixes

* **client:** process custom base url ahead of time ([59732a1](https://github.com/sfcompute/nodes-go/commit/59732a1b52f5adf2d65e59f781528be6d0f797f0))


### Chores

* configure new SDK language ([6e68d64](https://github.com/sfcompute/nodes-go/commit/6e68d64dc949d10023baf84985a7aa35be588a0e))
* lint tests in subpackages ([4ec488f](https://github.com/sfcompute/nodes-go/commit/4ec488f47f3be8686f911403dc5f28159e0fa055))
* update SDK settings ([ffa4444](https://github.com/sfcompute/nodes-go/commit/ffa4444199a4a95811ff66907dc56d71c356f921))
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ To use a local version of this library from source in another project, edit the
directive. This can be done through the CLI with the following:

```sh
$ go mod edit -replace github.com/stainless-sdks/sfc-nodes-go=/path/to/sfc-nodes-go
$ go mod edit -replace github.com/sfcompute/nodes-go=/path/to/nodes-go
```

## Running tests
Expand Down
66 changes: 49 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SFC Nodes Go API Library

<a href="https://pkg.go.dev/github.com/stainless-sdks/sfc-nodes-go"><img src="https://pkg.go.dev/badge/github.com/stainless-sdks/sfc-nodes-go.svg" alt="Go Reference"></a>
<a href="https://pkg.go.dev/github.com/sfcompute/nodes-go"><img src="https://pkg.go.dev/badge/github.com/sfcompute/nodes-go.svg" alt="Go Reference"></a>

The SFC Nodes Go library provides convenient access to the [SFC Nodes REST API](https://docs.sfcompute.com/api-reference#tag/nodes)
from applications written in Go.
Expand All @@ -9,18 +9,26 @@ It is generated with [Stainless](https://www.stainless.com/).

## Installation

<!-- x-release-please-start-version -->

```go
import (
"github.com/stainless-sdks/sfc-nodes-go" // imported as sfcnodes
"github.com/sfcompute/nodes-go" // imported as sfcnodes
)
```

<!-- x-release-please-end -->

Or to pin the version:

<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/stainless-sdks/sfc-nodes-go@v0.0.1-alpha.0'
go get -u 'github.com/sfcompute/nodes-go@v0.1.0-alpha.1'
```

<!-- x-release-please-end -->

## Requirements

This library requires Go 1.18+.
Expand All @@ -36,19 +44,22 @@ import (
"context"
"fmt"

"github.com/stainless-sdks/sfc-nodes-go"
"github.com/stainless-sdks/sfc-nodes-go/option"
"github.com/sfcompute/nodes-go"
"github.com/sfcompute/nodes-go/option"
)

func main() {
client := sfcnodes.NewClient(
option.WithBearerToken("My Bearer Token"), // defaults to os.LookupEnv("SFC_BEARER_TOKEN")
option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("SFC_API_KEY")
)
nodes, err := client.Nodes.List(context.TODO())
response, err := client.Vms.Logs(context.TODO(), sfcnodes.VmLogsParams{
InstanceID: "instance_id",
OrderBy: sfcnodes.VmLogsParamsOrderBySeqnumAsc,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", nodes)
fmt.Printf("%+v\n", response.Data)
}

```
Expand Down Expand Up @@ -254,7 +265,7 @@ client := sfcnodes.NewClient(
option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Nodes.List(context.TODO(), ...,
client.Vms.Logs(context.TODO(), ...,
// Override the header
option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
// Add an undocumented field to the request body, using sjson syntax
Expand All @@ -264,7 +275,7 @@ client.Nodes.List(context.TODO(), ...,

The request option `option.WithDebugLog(nil)` may be helpful while debugging.

See the [full list of request options](https://pkg.go.dev/github.com/stainless-sdks/sfc-nodes-go/option).
See the [full list of request options](https://pkg.go.dev/github.com/sfcompute/nodes-go/option).

### Pagination

Expand All @@ -285,14 +296,17 @@ When the API returns a non-success status code, we return an error with type
To handle errors, we recommend that you use the `errors.As` pattern:

```go
_, err := client.Nodes.List(context.TODO())
_, err := client.Vms.Logs(context.TODO(), sfcnodes.VmLogsParams{
InstanceID: "instance_id",
OrderBy: sfcnodes.VmLogsParamsOrderBySeqnumAsc,
})
if err != nil {
var apierr *sfcnodes.Error
if errors.As(err, &apierr) {
println(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request
println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
}
panic(err.Error()) // GET "/v1/nodes": 400 Bad Request { ... }
panic(err.Error()) // GET "/v0/vms/logs2": 400 Bad Request { ... }
}
```

Expand All @@ -310,8 +324,12 @@ To set a per-retry timeout, use `option.WithRequestTimeout()`.
// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Nodes.List(
client.Vms.Logs(
ctx,
sfcnodes.VmLogsParams{
InstanceID: "instance_id",
OrderBy: sfcnodes.VmLogsParamsOrderBySeqnumAsc,
},
// This sets the per-retry timeout
option.WithRequestTimeout(20*time.Second),
)
Expand Down Expand Up @@ -345,7 +363,14 @@ client := sfcnodes.NewClient(
)

// Override per-request:
client.Nodes.List(context.TODO(), option.WithMaxRetries(5))
client.Vms.Logs(
context.TODO(),
sfcnodes.VmLogsParams{
InstanceID: "instance_id",
OrderBy: sfcnodes.VmLogsParamsOrderBySeqnumAsc,
},
option.WithMaxRetries(5),
)
```

### Accessing raw response data (e.g. response headers)
Expand All @@ -356,11 +381,18 @@ you need to examine response headers, status codes, or other details.
```go
// Create a variable to store the HTTP response
var response *http.Response
nodes, err := client.Nodes.List(context.TODO(), option.WithResponseInto(&response))
response, err := client.Vms.Logs(
context.TODO(),
sfcnodes.VmLogsParams{
InstanceID: "instance_id",
OrderBy: sfcnodes.VmLogsParamsOrderBySeqnumAsc,
},
option.WithResponseInto(&response),
)
if err != nil {
// handle error
}
fmt.Printf("%+v\n", nodes)
fmt.Printf("%+v\n", response)

fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)
Expand Down Expand Up @@ -461,7 +493,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/sfc-nodes-go/issues) with questions, bugs, or suggestions.
We are keen for your feedback; please open an [issue](https://www.github.com/sfcompute/nodes-go/issues) with questions, bugs, or suggestions.

## Contributing

Expand Down
4 changes: 2 additions & 2 deletions aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
package sfcnodes

import (
"github.com/stainless-sdks/sfc-nodes-go/internal/apierror"
"github.com/stainless-sdks/sfc-nodes-go/packages/param"
"github.com/sfcompute/nodes-go/internal/apierror"
"github.com/sfcompute/nodes-go/packages/param"
)

// aliased to make [param.APIUnion] private when embedding
Expand Down
Loading