Skip to content

OpenAPI spec, types and client for the API to Calyptia Cloud.

License

Notifications You must be signed in to change notification settings

chronosphereio/calyptia-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calyptia Cloud API - OpenAPI specification, Golang reference client and types

Go Reference

OpenAPI spec, Golang types and client for the API to Calyptia Core.

Install

go get github.com/chronosphereio/calyptia-api

Client usage

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.

User authentication

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.

Spec

The /spec directory contains an OpenAPI specification. You can use it to generate clients for your favorite programming language. Or preview it using SwaggerUI.

Typescript codegen

Example using openapi-typescript-codegen.

npx openapi-typescript-codegen \
    --input ./spec/open-api.yml \
    --output ./ts-client \
    --name Client