Managing BigAnimal Clusters with BigAnimal’s APIs

February 04, 2022

EDB released BigAnimal on November 17, 2021. BigAnimal is EDB’s Postgres Database-as-a-Service. Before explaining what BigAnimal is, we will review what a DBaaS aka Database-as-a-Service is. 

A generic definition is

DBaaS is a cloud computing managed service offering that provides access to a database without requiring the setup of physical hardware, software installation or configuration.

That is a great definition, but it does not clarify that administrative tasks along with maintenance are covered by the service provider. This is one of the largest appealing factors of DBaaS, because it allows organizations to delegate the administrative tasks and maintenance while focusing towards utilizing the database(s).

BigAnimal Features and Capabilities

There are many features and capabilities available. A few are listed below:

  • Extensive Enterprise-grade features:
    • SSO
    • Audit Logging
    • RBAC
  • Priced for transparency
    • Simple per-core pricing model
    • No infrastructure markup
  • Runs in your cloud account
  • Oracle compatibility
  • Security enhancements
  • Supported by PostgreSQL experts
  • Flexible and resilient
  • Highly available
  • Scalable
  • Management via API and/or CLI
  • Many more….

The rise of the APIs

An API ( aka Application Programming Interface ) is a set of protocols, routines, functions, and/or commands that facilitate interaction between software services. APIs accomplish this without needing to know specific details about how the other software service works.

Modern APIs have been around since the early 2000s, and are commonly available for desktop and mobile use. Most applications have services available that provide APIs, while others make their APIs available sometime after their launch. 

BigAnimal has made its API readily available since its launch!

BigAnimal API Cluster Management

BigAnimal APIs make it possible to manage various components and resources such as: Billing, Cloud Providers, Clusters, Events, Organizations, Permissions, Postgres Types, Postgres Versions, Provider, Roles, Status, Users, and Auth. 

A BigAnimal cluster consists of databases, users, roles, and tablespaces that will be managed by a group of nodes of a predefined architecture with the goal of running Postgres/EDB Postgres Advanced Server. The API task that we are interested in the most for managing clusters is named: clusters. This API allows us to create, list, and delete a cluster.

Authentication

Before we get started with cluster management in BigAnimal we must provide our credentials and authenticate against BigAnimal. We will focus on utilizing get-token.sh available in the BigAnimal Cloud Utilities GitHub repository.

This method will consist of the following steps:

  1. Downloading and executing the get-token.sh
  2. Authenticating with the url provided by the get-token.sh script
    1. Navigating to the indicated url in a browser
    2. Clicking the Confirm Button for the indicated device code
    3. Confirming the successful login
    4. Retrieving the provided token after the successful login
  3. Assigning the authentication token to a variable for use across the command line
TOKEN='<token>'

Creating Clusters

The creation of a cluster requires multiple parameters to be sent via the command line. To prevent writing all those parameters, a data.json file has been created which contains all the parameters to be sent to the clusters API.

{
  "clusterName": "do-cluster-1",
  "instanceType": {
    "cpu": 2,
    "id": "azure:Standard_E2s_v3",
    "instanceType": "E2s v3",
    "ram": 16
  },
  "password": "SuperSecretPassword",
  "pgConfigMap": [
    [
      "max_connections",
      "100"
    ]
  ],
  "postgresType": {
    "dockerImage": "",
    "id": "epas"
  },
  "postgresVersion": "13",
  "privateNetworking": true,
  "provider": {
    "cloudProviderId": "azure"
  },
  "region": {
    "regionId": "westus2"
  },
  "replicas": 3,
  "volumeProperties": "P1",
  "volumeType": {
    "configFieldsList": [
      "secretName",
      "shareName"
    ],
    "displayName": "Azure Premium Storage",
    "id": "azurepremiumstorage",
    "storageClass": "managed-premium"
  },
  "zoneRedundantHa": true
}

Once the data.json is created, we can refer to it in the command line. 

The command line statement below will create a cluster.

curl -X 'POST' 'https://portal.edbcloud.com/api/v1/clusters' -H "Authorization: Bearer ${TOKEN}" -H 'accept: application/json' -H 'Content-Type: application/json' -d '@data.json'

A successful cluster creation will return a json array with cluster details.

[{"name":"do-cluster-1","instance":3,"currentPrimary":"p-c6b6543ehcerrn8s6rg-1", "ehcerrn8s6rg-r","phase":"Creating a new replica","phaseReason","Creating replica",0dc168873bea9bddacc45e63fdea17bdc28a7c8b450","postgresConfig":"","maintenanceWi

Listing Clusters

Listing clusters can be achieved by providing multiple parameters that were defined in the data.json utilized for creating the cluster. These parameters can be used to filter the results. A few example parameters could be: name, provider, pgtype, and or pgVersion. 

Below is the command utilized to list clusters by: name, provider, pgtype, and pgVersion with the parameter used to sort by.

curl -X 'GET' 'https://portal.edbcloud.com/api/v1/clusters?name=DO&provider=azure&pgType=epas&pgVersion=13&sort=%2Bname' -H 'accept: application/json'  -H "Authorization: Bearer ${TOKEN}"

Deleting Clusters

Deleting clusters is accomplished by providing the pgID, which can be retrieved by listing the cluster details and seeking the ‘pgId’ value.

curl -X 'DELETE' 'https://portal.edbcloud.com/api/v1/clusters/<pgId>' -H 'accept: *.*'  -H "Authorization: Bearer ${TOKEN}"

Conclusion

In this blog we: 

  • Explained what BigAnimal is, what APIs are, and how they relate to BigAnimal
  • Covered some of the features and capabilities of BigAnimal
  • Authenticated towards BigAnimal API
  • Learned how to create, list, and delete a BigAnimal cluster

Check out my other blog on BigAnimals and its CLI. https://web-origin.enterprisedb.com/blog/managing-biganimal-clusters-biganimals-cli-bash

 

Try EDB BigAnimal today!

Share this

More Blogs

EDB Postgres® AI Migration Tools Highlights

Accelerate Oracle-to-Postgres transitions and modernize legacy apps with new Data Migration Service, Oracle Estate Migration Assessment, and more This blog was co-authored by Matthew Lewandowski and Tim Boutin . Global...
December 12, 2024

EDB Postgres® 17 Transactional Database Highlights

Accelerate legacy application modernization, AI innovation, and secure open source software adoption This blog was co-authored by Adam Wright and Tim Boutin . The recent PostgreSQL 17 release won over...
December 10, 2024