This is an auto-generated API client based on the OpenAPI Spec for Cycle. 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.
go get github.com/cycleplatform/api-client-go
Create a client
package main
import (
"log""os""context""net/http""fmt""github.com/cycleplatform/api-client-go"
)
funcmain() {
apiKey:=os.Getenv("CYCLE_API_KEY")
ifapiKey=="" {
log.Fatal("missing env var CYCLE_API_KEY")
}
hubId:=os.Getenv("CYCLE_HUB_ID")
ifhubId=="" {
log.Fatal("missing env var CYCLE_HUB_ID")
}
c, err:=cycle.NewAuthenticatedClient(cycle.ClientConfig{
APIKey: apiKey,
HubID: hubId,
})
iferr!=nil {
log.Fatal(err)
}
// Get list of environmentsresp, err:=c.GetEnvironmentsWithResponse(context.TODO(), &cycle.GetEnvironmentsParams{})
iferr!=nil {
log.Fatal(err)
}
ifresp.StatusCode() !=http.StatusOK {
log.Fatalf("Expected HTTP 200 but received %d %s", resp.StatusCode(), *resp.JSONDefault.Error.Title)
}
for_, v:=rangeresp.JSON200.Data {
fmt.Printf("ID: %s - Name: %s\n", v.Id, v.Name)
}
}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)
go generate
See ogen for usage.