Simplify CloudRaya Management with API

How can we help?
< All Topics
Print

Simplify CloudRaya Management with API

Introduction to API Services from CloudRaya

CloudRaya management can be very simple With CloudRaya’s REST API. We can easily perform various activities related to CloudRaya. One of the key benefits of this feature is that with the API, we can carry out a wide range of tasks without the need to go through the CloudRaya dashboard. Additionally, through the API, we can automate scheduled tasks.

And don’t worry about security because every access to execute commands on the CloudRaya API requires access tokens.

In this tutorial, we’ll take a closer look at how to use CloudRaya with its API, breaking down the steps in a simple way.

Generating Account API Key

Before you can use the API, you need to enable and generate an API key for your application or platform. Please follow this guideline here.

Introduction to Postman as an API Testing Tool

Let’s have a brief overview of what Postman is before we directly use it in the simple API usage.

Postman itself is a platform for building and using APIs. You can download the application here, or if you prefer to use it via a browser, Postman also provides a web version of the platform.

In a more detailed explanation, Postman is a software used to send requests and receive responses through the HTTP protocol.

To use it, the steps are quite simple:

  1. Save the URL of the API or endpoint you want to use here.
  2. Choose the request method according to what is described in the CloudRaya API documentation.
  3. To input the request details, you can fill in the information in the ‘Body‘ tab.
  4. Finally, to execute the request, simply click the ‘Send‘ button.

Generating API Token

After creating the API Key, next, we need to send an authentication request to the API gateway using the credentials of the API key to generate the ‘Bearer’ token.

The API token, referred to as the ‘Bearer’ Token, is useful to enable access to CloudRaya API located in the CloudRaya API Docs.

Step 1 - Sending an HTTP Post

In Postman, Send an HTTP POST request to the URL https://api.cloudraya.com/v1/api/gateway/user/auth with a raw JSON Body that contains the app_key and secret_key found in API Gateway Management Page in the CloudRaya Control Panel.

Step 2 - Obtaining a Bearer Token

The API Gateway will return a bearer_token that you can use to communicate with the API gateway. You may use the bearer_token value in your header as an “Authorization.

You can find more information about the instructions for generating this API token on the following page.

Simple Activities in API Usage

Let’s dive into performing a few CloudRaya management tasks through the API.

Make sure to always generate the Bearer token and use it for every API activity.
In Postman, you can copy the bearer token into the 'Authorization' tab.

Create VM using API

To create a VM using the API, you can follow these steps:

In Postman, send an HTTP POST request to the URL https://api.cloudraya.com/v1/api/gateway/user/virtualmachines with a raw JSON Body containing the variable parameters for creating the VM. Then, click ‘Send

If the parameters and variables match, then a successful API response, as shown above, will be displayed.

If you check on the panel, it is confirmed that the VM creation process was successful.

You can find more information about the instructions for creating VM via API on the following page.

View VM Details

To view the details of the VM you’ve previously created, you can follow these steps:

In Postman, send an HTTP GET request to the URL https://api.cloudraya.com/v1/api/gateway/user/virtualmachines/:id. Replace the :id variable in the URL with the ID of the VM you want to check. Then, click ‘Send.’

If the variables match, then a successful API response, as shown above, will be displayed.

You can find more information about the instructions for viewing VM details via API on the following page.

Delete VM

And, if you want to delete the VM you’ve just created, you can follow these steps:

In Postman, send an HTTP POST request to the URL https://api.cloudraya.com/v1/api/gateway/user/virtualmachines/action with a raw JSON Body containing the variable parameters for deleting the VM. Then, click ‘Send

If the variables match, then a successful API response, as shown above, will be displayed.

You can find more information about the instructions for deleting VM via API on the following page.

Conclusion

Now, you know how to efficiently proceed your project with cloudraya management. To access the full documentation of the activities you can perform with the CloudRaya API,  You can find in the CloudRaya API Docs.

Table of Contents

Ready, Set, Cloud

Ready, Set, Cloud