# README
Go API client for ccloud
To regenerate run:
gen.sh
Requires openapi-generator to be installed. I used 6.0.0 on a mac. For some reason I didn't dig into too deeply, the generated code is broken (missing open curly brace on some if statements) so I just patched the results. When openapi-generator or the go plugin changes sufficiently it will likely break the patch, which will need to be removed or adjusted.
autogenerated follows
This is an early access, experimental version of the Cloud API. The interface and output is subject to change, and there may be bugs.
Authentication
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: 2022-03-31
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://support.cockroachlabs.com
Installation
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
Put the package under your project folder and add the following in import:
import ccloud "github.com/jess-sheneberger/cockroach-cloud-golang"
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 sw.ContextServerIndex
of type int
.
ctx := context.WithValue(context.Background(), ccloud.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(), ccloud.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(), ccloud.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), ccloud.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
Documentation for API Endpoints
All URIs are relative to https://cockroachlabs.cloud
Class | Method | HTTP request | Description |
---|---|---|---|
CockroachCloudApi | AddAllowlistEntry | Post /api/v1/clusters/{cluster_id}/networking/allowlist | Add a new CIDR address to the IP allowlist. |
CockroachCloudApi | AddAllowlistEntry2 | Put /api/v1/clusters/{cluster_id}/networking/allowlist/{entry.cidr_ip}/{entry.cidr_mask} | Add a new CIDR address to the IP allowlist. |
CockroachCloudApi | CreateCluster | Post /api/v1/clusters | Create and initialize a new cluster. |
CockroachCloudApi | CreateSQLUser | Post /api/v1/clusters/{cluster_id}/sql-users | Create a new SQL user. |
CockroachCloudApi | DeleteAllowlistEntry | Delete /api/v1/clusters/{cluster_id}/networking/allowlist/{cidr_ip}/{cidr_mask} | Delete an IP allowlist entry. |
CockroachCloudApi | DeleteCluster | Delete /api/v1/clusters/{cluster_id} | Delete a cluster and all of its data. |
CockroachCloudApi | DeleteSQLUser | Delete /api/v1/clusters/{cluster_id}/sql-users/{name} | Delete a SQL user. |
CockroachCloudApi | EnableCMEK | Post /api/v1/clusters/{cluster_id}/cmek | Enable CMEK for a cluster. |
CockroachCloudApi | GetCMEKClusterInfo | Get /api/v1/clusters/{cluster_id}/cmek | Get CMEK-related information for a cluster. |
CockroachCloudApi | GetCluster | Get /api/v1/clusters/{cluster_id} | Get extended information about a cluster. |
CockroachCloudApi | ListAllowlistEntries | Get /api/v1/clusters/{cluster_id}/networking/allowlist | Get the IP allowlist and propagation status for a cluster. |
CockroachCloudApi | ListAvailableRegions | Get /api/v1/clusters/available-regions | List the regions available for new clusters and nodes. |
CockroachCloudApi | ListClusterNodes | Get /api/v1/clusters/{cluster_id}/nodes | List nodes for a cluster. |
CockroachCloudApi | ListClusters | Get /api/v1/clusters | List clusters owned by an organization. |
CockroachCloudApi | ListSQLUsers | Get /api/v1/clusters/{cluster_id}/sql-users | List SQL users for a cluster. |
CockroachCloudApi | UpdateAllowlistEntry | Patch /api/v1/clusters/{cluster_id}/networking/allowlist/{entry.cidr_ip}/{entry.cidr_mask} | Update an IP allowlist entry. |
CockroachCloudApi | UpdateCMEKStatus | Patch /api/v1/clusters/{cluster_id}/cmek | Update the CMEK-related status for a cluster. |
CockroachCloudApi | UpdateCluster | Patch /api/v1/clusters/{cluster_id} | Scale or edit a cluster. |
CockroachCloudApi | UpdateSQLUserPassword | Put /api/v1/clusters/{cluster_id}/sql-users/{name}/password | Update a SQL user's password. |
Documentation For Models
- AllowlistEntry
- Any
- ApiCloudProvider
- CMEKClusterInfo
- CMEKClusterSpecification
- CMEKCustomerAction
- CMEKKeyInfo
- CMEKKeySpecification
- CMEKKeyType
- CMEKRegionInfo
- CMEKRegionSpecification
- CMEKStatus
- CloudProviderRegion
- Cluster
- ClusterConfig
- ClusterStateType
- ClusterStatusType
- CreateClusterRequest
- CreateClusterSpecification
- CreateSQLUserRequest
- DedicatedClusterCreateSpecification
- DedicatedClusterUpdateSpecification
- DedicatedHardwareConfig
- DedicatedHardwareCreateSpecification
- DedicatedHardwareUpdateSpecification
- DedicatedMachineTypeSpecification
- KeysetPaginationRequest
- KeysetPaginationResponse
- ListAllowlistEntriesResponse
- ListAvailableRegionsResponse
- ListClusterNodesResponse
- ListClustersResponse
- ListSQLUsersResponse
- Node
- NodeStatus
- PageDirection
- Plan
- Region
- SQLUser
- ServerlessClusterConfig
- ServerlessClusterCreateSpecification
- ServerlessClusterUpdateSpecification
- SortOrder
- Status
- UpdateCMEKStatusRequest
- UpdateClusterSpecification
- UpdateSQLUserPasswordRequest
Documentation For Authorization
Bearer
- Type: HTTP Bearer token authentication
Example
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "BEARER_TOKEN_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