/openapi-chaos-go-client

Go client for the Chaos API (auto-generated repo)

Primary LanguageShell

Go API client for openapi_chaos_client

Central Management API - publicly exposed set of APIs for managing deployments

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 1.0.0
  • Package version: 1.0.0
  • Generator version: 7.5.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openapi_chaos_client "github.com/qernal/openapi-chaos-go-client"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value openapi_chaos_client.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi_chaos_client.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value openapi_chaos_client.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi_chaos_client.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using openapi_chaos_client.ContextOperationServerIndices and openapi_chaos_client.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi_chaos_client.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi_chaos_client.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://chaos.qernal.com/v1

Class Method HTTP request Description
FunctionsAPI FunctionsCreate Post /functions Create function
FunctionsAPI FunctionsDelete Delete /functions/{function_id} Delete function
FunctionsAPI FunctionsGet Get /functions/{function_id} Get function (latest revision)
FunctionsAPI FunctionsRevisionsGet Get /functions/{function_id}/revisions/{function_revision_id} Get a specific revision of a function
FunctionsAPI FunctionsRevisionsList Get /functions/{function_id}/revisions List all revisions for a function
FunctionsAPI FunctionsUpdate Put /functions/{function_id} Update function
FunctionsAPI ProjectsFunctionsList Get /projects/{project_id}/functions List all functions within a project
HostsAPI ProjectsHostsCreate Post /projects/{project_id}/hosts Create host for project
HostsAPI ProjectsHostsDelete Delete /projects/{project_id}/hosts/{hostname} Delete specific host by hostname
HostsAPI ProjectsHostsGet Get /projects/{project_id}/hosts/{hostname} Get specific host by hostname
HostsAPI ProjectsHostsList Get /projects/{project_id}/hosts List hosts for project
HostsAPI ProjectsHostsUpdate Put /projects/{project_id}/hosts/{hostname} Update specific host by hostname
HostsAPI ProjectsHostsVerifyCreate Post /projects/{project_id}/hosts/{hostname}/verify Schedule host verification task
OrganisationsAPI OrganisationsCreate Post /organisations Create organisations
OrganisationsAPI OrganisationsDelete Delete /organisations/{organisation_id} Delete an organisation
OrganisationsAPI OrganisationsGet Get /organisations/{organisation_id} Get an organisation
OrganisationsAPI OrganisationsList Get /organisations List organisations
OrganisationsAPI OrganisationsUpdate Put /organisations/{organisation_id} Update an organisation
ProjectsAPI OrganisationsProjectsList Get /organisations/{organisation_id}/projects Get all projects within an organisation
ProjectsAPI ProjectsCreate Post /projects Create project
ProjectsAPI ProjectsDelete Delete /projects/{project_id} Delete project
ProjectsAPI ProjectsGet Get /projects/{project_id} Get project
ProjectsAPI ProjectsList Get /projects List projects
ProjectsAPI ProjectsUpdate Put /projects/{project_id} Update project
ProvidersAPI ProvidersList Get /providers Get available providers
SecretsAPI ProjectsSecretsCreate Post /projects/{project_id}/secrets Create project secret
SecretsAPI ProjectsSecretsDelete Delete /projects/{project_id}/secrets/{secret_name} Delete project secret
SecretsAPI ProjectsSecretsGet Get /projects/{project_id}/secrets/{secret_name} Get project secret
SecretsAPI ProjectsSecretsList Get /projects/{project_id}/secrets List project secrets of a specific type
SecretsAPI ProjectsSecretsUpdate Put /projects/{project_id}/secrets/{secret_name} Update project secret
TokensAPI AuthTokensCreate Post /auth/tokens Create new auth token
TokensAPI AuthTokensDelete Delete /auth/tokens/{token_id} Delete token
TokensAPI AuthTokensGet Get /auth/tokens/{token_id} Get token information
TokensAPI AuthTokensList Get /auth/tokens List all user auth tokens
TokensAPI AuthTokensUpdate Put /auth/tokens/{token_id} Update token

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

token

  • Type: HTTP Bearer token authentication

Example

auth := context.WithValue(context.Background(), openapi_chaos_client.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)

cookie

  • Type: API key
  • API key parameter name: qernal_kratos_session
  • Location:

Note, each API key must be added to a map of map[string]APIKey where the key is: qernal_kratos_session and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi_chaos_client.ContextAPIKeys,
		map[string]openapi_chaos_client.APIKey{
			"qernal_kratos_session": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

support@qernal.com