OpenAPI spec, Golang types and client for the API to Calyptia Core.
go get github.com/chronosphereio/calyptia-api
Get an API key from Calyptia Cloud under settings.
package main
import "github.com/chronosphereio/calyptia-api/client"
func main() {
c := client.New()
c.SetProjectToken("YOUR_API_KEY_HERE")
}
API keys are bound to an specific project. With that API key you cannot list all your other projects, or create more API keys. But you can perform all other actions within a project: manage agents, aggregators and pipelines, invite members, etc.
Machines using this client should prefer API key authorization, but if you need user authentication, you must setup Auth0. After you successfully login and get an access token, you can create an authenticated client like so:
tok := &oauth2.Token{
AccessToken: "YOUR_AUTH0_ACCESS_TOKEN",
TokenType: "Bearer",
Expiry: auth0Expiry,
}
tokSrc := oauth2.StaticTokenSource(tok)
c.Client = oauth2.NewClient(ctx, tokSrc)
Refer to client/client_test.go for a testing example.
The /spec
directory contains an OpenAPI specification.
You can use it to generate clients for your favorite programming language.
Or preview it using SwaggerUI.
Example using openapi-typescript-codegen.
npx openapi-typescript-codegen \
--input ./spec/open-api.yml \
--output ./ts-client \
--name Client