api

module
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: Apache-2.0

README

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

Directories

Path Synopsis
Package client provides a client over the REST HTTP API of Calyptia Cloud.
Package client provides a client over the REST HTTP API of Calyptia Cloud.
secrets
Package secrets provides RSA codec to work with Calyptia Cloud pipeline secrets.
Package secrets provides RSA codec to work with Calyptia Cloud pipeline secrets.
token
Package token provides a decoder for Calyptia Cloud projects tokens.
Package token provides a decoder for Calyptia Cloud projects tokens.
Package types contains the required base types used for both client and server side for Calyptia Cloud API.
Package types contains the required base types used for both client and server side for Calyptia Cloud API.
errs
Package errs provides common error types that can be used across the application.
Package errs provides common error types that can be used across the application.
legacy
Package legacy provides types for legacy/deprecated APIs.
Package legacy provides types for legacy/deprecated APIs.
metric03
Package metric03 holds the structure for the old mskpack cmetrics version 0.3.x.
Package metric03 holds the structure for the old mskpack cmetrics version 0.3.x.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL