Giter Club home page Giter Club logo

public-api-go-examples's Introduction

Cloud Public API Go Examples

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.

Usage

Environment variables

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

Usage

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

Examples

addip

Adds an ip to a cluster's allowlist.

godotenv -f .env go run ./addip <cluster-id> <ip>

createbucket

Creates a bucket with <bucket-name> for a cluster.

godotenv -f .env go run ./createbucket <cluster-id> <bucket-name>

createproject

Creates a project with <project-name>

godotenv -f .env go run ./createproject <project-name>

createuser

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>

deploycluster

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>

get

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>

getcertificate

Get Cluster's self-signed certificate

godotenv -f .env go run ./getcertificate <cluster-id>

health

Get Cluster's health stats. It includes bucket and node stats.

godotenv -f .env go run ./health <cluster-id>

pollbuckethealth

It checks bucket status for every 5 seconds till it becomes healthy

godotenv -f .env go run ./pollbuckethealth <cluster-id> <bucket-name>

pollclusterstatus

It checks cluster status for every 5 seconds till it becomes ready

godotenv -f .env go run ./pollclusterstatus <cluster-id>

status

Returns Public API Status. The endpoint does not require authentication.

godotenv -f .env go run ./status

public-api-go-examples's People

Contributors

rhymond avatar

Watchers

Steve Yen avatar Sarath Lakshman avatar Jeffry Morris avatar Priya Rajagopal avatar James Cloos avatar Brett Lawson avatar  avatar Jack Harper avatar Wayne Siu avatar  avatar Dan Owen avatar Dave Finlay avatar  avatar Adam Fraser avatar Keshav Murthy avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.