Categorygithub.com/qernal/openapi-chaos-go-client
repositorypackage
0.0.0-20241201024103-fd51fb986a40
Repository: https://github.com/qernal/openapi-chaos-go-client.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

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.10.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

ClassMethodHTTP requestDescription
FunctionsAPIFunctionsCreatePost /functionsCreate function
FunctionsAPIFunctionsDeleteDelete /functions/{function_id}Delete function
FunctionsAPIFunctionsGetGet /functions/{function_id}Get function (latest revision)
FunctionsAPIFunctionsRevisionsGetGet /functions/{function_id}/revisions/{function_revision_id}Get a specific revision of a function
FunctionsAPIFunctionsRevisionsListGet /functions/{function_id}/revisionsList all revisions for a function
FunctionsAPIFunctionsUpdatePut /functions/{function_id}Update function
FunctionsAPIProjectsFunctionsListGet /projects/{project_id}/functionsList all functions within a project
HostsAPIProjectsHostsCreatePost /projects/{project_id}/hostsCreate host for project
HostsAPIProjectsHostsDeleteDelete /projects/{project_id}/hosts/{hostname}Delete specific host by hostname
HostsAPIProjectsHostsGetGet /projects/{project_id}/hosts/{hostname}Get specific host by hostname
HostsAPIProjectsHostsListGet /projects/{project_id}/hostsList hosts for project
HostsAPIProjectsHostsUpdatePut /projects/{project_id}/hosts/{hostname}Update specific host by hostname
HostsAPIProjectsHostsVerifyCreatePost /projects/{project_id}/hosts/{hostname}/verifySchedule host verification task
OrganisationsAPIOrganisationsCreatePost /organisationsCreate organisations
OrganisationsAPIOrganisationsDeleteDelete /organisations/{organisation_id}Delete an organisation
OrganisationsAPIOrganisationsGetGet /organisations/{organisation_id}Get an organisation
OrganisationsAPIOrganisationsListGet /organisationsList organisations
OrganisationsAPIOrganisationsUpdatePut /organisations/{organisation_id}Update an organisation
ProjectsAPIOrganisationsProjectsListGet /organisations/{organisation_id}/projectsGet all projects within an organisation
ProjectsAPIProjectsCreatePost /projectsCreate project
ProjectsAPIProjectsDeleteDelete /projects/{project_id}Delete project
ProjectsAPIProjectsGetGet /projects/{project_id}Get project
ProjectsAPIProjectsListGet /projectsList projects
ProjectsAPIProjectsUpdatePut /projects/{project_id}Update project
ProvidersAPIProvidersListGet /providersGet available providers
SecretsAPIProjectsSecretsCreatePost /projects/{project_id}/secretsCreate project secret
SecretsAPIProjectsSecretsDeleteDelete /projects/{project_id}/secrets/{secret_name}Delete project secret
SecretsAPIProjectsSecretsGetGet /projects/{project_id}/secrets/{secret_name}Get project secret
SecretsAPIProjectsSecretsListGet /projects/{project_id}/secretsList project secrets of a specific type
SecretsAPIProjectsSecretsUpdatePut /projects/{project_id}/secrets/{secret_name}Update project secret
TokensAPIAuthTokensCreatePost /auth/tokensCreate new auth token
TokensAPIAuthTokensDeleteDelete /auth/tokens/{token_id}Delete token
TokensAPIAuthTokensGetGet /auth/tokens/{token_id}Get token information
TokensAPIAuthTokensListGet /auth/tokensList all user auth tokens
TokensAPIAuthTokensUpdatePut /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: cookie 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{
			"cookie": {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

[email protected]