https://github.com/cycleplatform/api-client-go
A Go API client for the Cycle API
https://github.com/cycleplatform/api-client-go
Last synced: 4 months ago
JSON representation
A Go API client for the Cycle API
- Host: GitHub
- URL: https://github.com/cycleplatform/api-client-go
- Owner: cycleplatform
- License: other
- Created: 2023-05-05T21:12:29.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-11-29T17:01:15.000Z (7 months ago)
- Last Synced: 2025-12-01T19:52:45.318Z (7 months ago)
- Language: Go
- Size: 6.47 MB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Cycle API Go Client

_This is an auto-generated API client based on the [OpenAPI Spec for Cycle](https://github.com/cycleplatform/api-spec). Please do not open any PRs for the generated code in `generated.go`. If you have any questions on what changes are made in the latest version, please refer to the spec above._
## Usage
`go get github.com/cycleplatform/api-client-go`
Create a client
```go
package main
import (
"log"
"os"
"context"
"net/http"
"fmt"
"github.com/cycleplatform/api-client-go"
)
func main() {
apiKey := os.Getenv("CYCLE_API_KEY")
if apiKey == "" {
log.Fatal("missing env var CYCLE_API_KEY")
}
hubId := os.Getenv("CYCLE_HUB_ID")
if hubId == "" {
log.Fatal("missing env var CYCLE_HUB_ID")
}
c, err := cycle.NewAuthenticatedClient(cycle.ClientConfig{
APIKey: apiKey,
HubID: hubId,
})
if err != nil {
log.Fatal(err)
}
// Get list of environments
resp, err := c.GetEnvironmentsWithResponse(context.TODO(), &cycle.GetEnvironmentsParams{})
if err != nil {
log.Fatal(err)
}
if resp.StatusCode() != http.StatusOK {
log.Fatalf("Expected HTTP 200 but received %d %s", resp.StatusCode(), *resp.JSONDefault.Error.Title)
}
for _, v := range resp.JSON200.Data {
fmt.Printf("ID: %s - Name: %s\n", v.Id, v.Name)
}
}
```
## Development
### Updating the API spec
Update the API spec to the latest version:
`git submodule update --recursive --remote`
Using `npm`, run `(cd api-spec; npm run build:platform && npm run downconvert:platform)`
### Generating the client
`go generate`
See [ogen](https://ogen.dev/docs/intro/) for usage.