Skip to content

Latest commit

 

History

History
280 lines (234 loc) · 13.8 KB

README.md

File metadata and controls

280 lines (234 loc) · 13.8 KB

Go API client for couchbasecapella

Go Reference

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

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: 2.0.0
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Configuring environment variables

In order to set up authentication a programmatic API key must be generated. Instructions to generate your API key can be found in the Couchbase Capella Public API documentation.

You will need to provide your credentials for authentication via the environment variables, CBC_ACCESS_KEY and CBC_SECRET_KEY, for your access and secret API Key Pair respectively.

$  export CBC_ACCESS_KEY="xxxx"
$  export CBC_SECRET_KEY="xxxx"

Installation

Install the following dependency:

go get github.com/couchbasecloud/couchbase-capella-api-go-client

Add the following in import:

import "github.com/couchbasecloud/couchbase-capella-api-go-client"

Creating an API client

ctx := context.WithValue(
    context.Background(),
    couchbasecloud.ContextAPIKeys,
    map[string]couchbasecloud.APIKey{
        "accessKey": {
            Key: os.Getenv("CBC_ACCESS_KEY"),
        },
        "secretKey": {
            Key: os.Getenv("CBC_SECRET_KEY"),
        },
    },
)
configuration := couchbasecloud.NewConfiguration()
apiClient := couchbasecloud.NewAPIClient(configuration)

API usage - Retrieving a project

projectId := "39eidkdhe-48389-dk38-8e84-34038djsjks"
project, _, err := apiClient.ProjectsApi.ProjectsShow(ctx, projectId).Execute()

if err != nil {
    t.Fatalf("Error when calling `ProjectsApi.ProjectsShow(ctx)`: %v\n", err)
}

fmt.Fprintf(os.Stdout, "Response from `ProjectsApi.ProjectsShow(ctx)`: %v\n", project)

To use a proxy server, 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 sw.ContextServerIndex of type int.

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

Templated Server URL

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

ctx := context.WithValue(context.Background(), sw.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 sw.ContextOperationServerIndices and sw.ContextOperationServerVariables context maps.

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

Documentation for API Endpoints

All URIs are relative to https://cloudapi.cloud.couchbase.com

Class Method HTTP request Description
CloudsApi CloudsList Get /v2/clouds List Clouds
CloudsApi CloudsShow Get /v2/clouds/{id} Get Cloud
ClustersApi ClustersCreate Post /v2/clusters Create cluster
ClustersApi ClustersCreateAllowlistEntry Post /v2/clusters/{id}/allowlist Adds entry to allowlist
ClustersApi ClustersCreateBucket Post /v2/clusters/{id}/buckets Create bucket in cluster
ClustersApi ClustersCreateUser Post /v2/clusters/{id}/users Create Database User
ClustersApi ClustersDelete Delete /v2/clusters/{id} Delete cluster
ClustersApi ClustersDeleteAllowlistEntry Delete /v2/clusters/{id}/allowlist Delete entry from allowlist
ClustersApi ClustersDeleteBucket Delete /v2/clusters/{id}/buckets Delete bucket in cluster
ClustersApi ClustersDeleteSingleBucket Delete /v2/clusters/{id}/buckets/{bucketId} Delete an existing bucket
ClustersApi ClustersDeleteUser Delete /v2/clusters/{id}/users/{username} Delete Database User
ClustersApi ClustersGetAllowlist Get /v2/clusters/{id}/allowlist Get current allowlist
ClustersApi ClustersGetCertificate Get /v2/clusters/{id}/certificate Get Cluster Certificate
ClustersApi ClustersHealth Get /v2/clusters/{id}/health Get Cluster Health
ClustersApi ClustersList Get /v2/clusters List Clusters
ClustersApi ClustersListBuckets Get /v2/clusters/{id}/buckets List cluster buckets
ClustersApi ClustersListUsers Get /v2/clusters/{id}/users List Database Users
ClustersApi ClustersShow Get /v2/clusters/{id} Get Cluster
ClustersApi ClustersStatus Get /v2/clusters/{id}/status Get Cluster Status
ClustersApi ClustersUpdateAllowlist Put /v2/clusters/{id}/allowlist Update the allowlist for a cluster
ClustersApi ClustersUpdateBucket Put /v2/clusters/{id}/buckets Update bucket in cluster
ClustersApi ClustersUpdateSingleBucket Put /v2/clusters/{id}/buckets/{bucketId} Update an existing bucket
ClustersApi ClustersUpdateUser Put /v2/clusters/{id}/users/{username} Update Database User
ClustersV3Api ClustersV3create Post /v3/clusters Create Cluster V3
ClustersV3Api ClustersV3createUser Post /v3/clusters/{id}/users Create cluster user
ClustersV3Api ClustersV3delete Delete /v3/clusters/{id} Delete Cluster V3
ClustersV3Api ClustersV3list Get /v3/clusters List all clusters v3
ClustersV3Api ClustersV3show Get /v3/clusters/{id} Get Cluster Info V3
ClustersV3Api ClustersV3status Get /v3/clusters/{id}/status Get Cluster Status V3
ClustersV3Api ClustersV3updateMeta Put /v3/clusters/{id}/meta Update Cluster Metadata V3
ClustersV3Api ClustersV3updateServers Put /v3/clusters/{id}/servers Update Cluster Servers V3
ClustersV3Api ClustersV3updateSupport Put /v3/clusters/{id}/support Update Cluster Support Package V3
ProjectsApi ProjectsCreate Post /v2/projects Create project
ProjectsApi ProjectsDelete Delete /v2/projects/{id} Delete project
ProjectsApi ProjectsList Get /v2/projects List Projects
ProjectsApi ProjectsShow Get /v2/projects/{id} Get project by ID
StatusApi StatusShow Get /v2/status API status
UsersApi UsersList Get /v2/users List Users

Documentation For Models

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