api

module
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: Apache-2.0

README

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

Go Reference CI codecov

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

Install

go get github.com/calyptia/api

Client usage

Get an API key from Calyptia Cloud under settings.

package main

import "github.com/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.

Jump to

Keyboard shortcuts

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