Skip to content
Merged
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
60 changes: 53 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,66 @@
# 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 under /client. If you have any questions on what changes are made in the latest version, please refer to the spec above._
_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._

## Setup

Install Ogen
## Usage

`go install -v github.com/ogen-go/ogen/cmd/ogen@latest`
`go get github.com/cycleplatform/api-client-go`

## Generating
Create a client

### Updating the spec
```go
package main

import (
cycle "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:public && npm run build:internal)`
Using `npm`, run `(cd api-spec; npm run build:platform && npm run downconvert:platform)`

### Generating the client

Expand Down
2 changes: 1 addition & 1 deletion api-spec
Submodule api-spec updated 148 files
37 changes: 0 additions & 37 deletions client/authentication.go

This file was deleted.

67 changes: 0 additions & 67 deletions client/oas_cfg_gen.go

This file was deleted.

Loading