Getting Started with Native Workloads API trial

Instructions and samples to get started using the Druva Native Workloads API

This is where you show your users how to set it up. You can use code samples, like this:

Authentication

Druva Native Workloads supports OAuth 2.0 based authentication for API requests. The following is the process to generate an authentication token to access the API requests. Sample scripts enable you to automate the process of generating the token and access Druva Native Workloads APIs.

Follow the instructions below to authorize and send a simple request to the Native Workloads API

Step 1

In order to start making requests with the Native Workloads API, users must first register for an API key to authenticate the requests.
You can retrieve your API key from the User Settings page in your Native Workloads account by clicking [User Settings] (https://cloudranger.druva.com/admin/user-settings)

To do this, authenticate with the GET request sample below:

curl --request GET \
  --url https://api.cloudranger.com/202004/authorize \
  --header 'accept: application/json' \
  --header 'x-api-key: 2qop3RkZY6t.................................'
var request = require("request");

var options = {
  method: 'GET',
  url: 'https://api.cloudranger.com/202004/authorize',
  headers: {accept: 'application/json', 'x-api-key': '2qop3RkZY6t.................................'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

This will return a token for use a Bearer Authentication for use in further calls

{"token":"eyJhbGdgdggfdggdgfSEGqUw9TvRrdRwxxxxxxxxx"}

Step 2

Using the token returned in step 1, execute the accessible accounts GET request below which will return a list of accounts that you can perform API requests against.

curl --request GET  --url https://api.cloudranger.com/202004/organizations/t7GfxgtC/accounts
 --header 'accept: application/json'
 --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyE1ODg5NDUwMsXXXXXXXXXXXXXX'
 --header 'x-api-key: 2qop3RkZY6t.................'
var request = require("request");

var options = {
  method: 'GET',
  url: 'https://api.cloudranger.com/202004/organizations/organization_id/accounts',
  headers: {accept: 'application/json', 'x-api-key': '2qop3RkZY6t.................................', 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cXXXXXXXXXXXXXXX''}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

This call will return json data with a list of accounts like the following

{
    "id":"isfsyJs35",
    "organization_id":"sdfdsfsdfsd",
    "name":"Default Account",
    "initials":"DA",
    "color":"rgb(121,123,243)",
    "avatar_image":null,

What’s Next

The Full API is available in the API Reference