A list of examples written in Go to interact with Couchbase Cloud Public API. More details about the API:
https://docs.couchbase.com/cloud/public-api-guide/introducing-public-api.html
Basically this repository provides a tiny http client wrapper which generates request headers using access/secret keys. Generated headers are requires to interact with the API.
Environment variables provided below must be set in order to use API Client. You
can use godotenv
(https://github.com/joho/godotenv) package to temporary
populate it using .env
file. .env
is located in ./examples
directory.
In order to get ACCESS/SECRET (or in other words api-key) you need to have access to the Couchbase Cloud UI and have an admin user who has access to manage the tenant.
ACCESS_KEY=
SECRET_KEY=
BASE_URL=https://cloudapi.cloud.couchbase.com
Executing the command from ./examples
directory should list all tenant
projects.
godotenv -f .env go run ./get '/v2/projects'
The response of each example consists of response status code
and body
Adds an ip to a cluster's allowlist.
godotenv -f .env go run ./addip <cluster-id> <ip>
Creates a bucket with <bucket-name>
for a cluster.
godotenv -f .env go run ./createbucket <cluster-id> <bucket-name>
Creates a project with <project-name>
godotenv -f .env go run ./createproject <project-name>
Creates a Database User for a Cluster. Created user going to have full access to
a provided <bucket>
godotenv -f .env go run ./createuser <cluster-id> <username> <password> <bucket>
Initiates new Cluster deployment in connect Cloud. It creates a new project for
with a given <project-name>
godotenv -f .env go run ./deploycluster <cloud-id> <project-name> <cluster-name>
Send GET
request to a given uri <endpoint>
. For example: `./get '
/v2/projects' returns a list of projects.
godotenv -f .env go run ./get <endpoint>
Get Cluster's self-signed certificate
godotenv -f .env go run ./getcertificate <cluster-id>
Get Cluster's health stats. It includes bucket and node stats.
godotenv -f .env go run ./health <cluster-id>
It checks bucket status for every 5 seconds till it becomes healthy
godotenv -f .env go run ./pollbuckethealth <cluster-id> <bucket-name>
It checks cluster status for every 5 seconds till it becomes ready
godotenv -f .env go run ./pollclusterstatus <cluster-id>
Returns Public API Status. The endpoint does not require authentication.
godotenv -f .env go run ./status