📜 ⬆️ ⬇️

How our IaaS provider API works

Today we will talk about practical cases in which we use the API of our IaaS provider 1cloud . Its main task is to ensure the integration of client applications and our IT infrastructure.


/ photo by Rachel Johnson CC

One of our main principles of work is to provide customers with a simple and convenient interface. The task is to make the virtual infrastructure available even for those who have not yet come up with the customization of the IT component of their project.
')
Custom actions in the control panel create the corresponding tasks that are processed by service services. This approach allows you to create universal conditions for work using a graphical interface and through our REST API.

Thus, applications of our clients can form similar tasks for the processor and monitor the progress of their execution with the help of special requests. To do this, you must authorize the application by getting a unique key in the control panel.


Authorization of the application to work with the API occurs by inserting a token (private key) into the request header, this scheme is safe, because SSL encryption is used. The token can be generated in the control panel (in the screenshot above).

Our API allows you to automate a series of service tasks that any company that uses a virtual infrastructure faces. I can benefit most from those who are engaged in reselling hosting services, displaying their own services to the cloud of our IaaS provider and prefer to quickly scale the already reserved capacities.

For example, developers can automatically tap into additional cloud resources if monitoring systems record peak loads. In a recession, automatically discard unused resources. All this can be done using our API.

As part of working with the server, it is possible to perform such actions as: getting a list of all servers; server search by its identifier; change settings and delete server.

There are several client application implementations for our API.





An example of the most common action is creating a new server :

curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer 75bb9805c018b1267b2cf599a38b95a3a811e2ef7ad9ca5ed838ea4c6bafaf50' "https://api.1cloud.ru/Server" -d '{"Name":"testAPI","CPU":1,"RAM":1024,"HDD":40,"imageID":1,"HDDType":"SSD","IsHighPerformance":true}' 

The response is a JSON object with the attributes of the server created:

 { "ID":777, "Name":"testAPI", "State":"Active", "IsPowerOn":true, "CPU":1, "RAM":1024, "HDD":40, "IP":"5.200.XX.XX", "AdminUserName":"1CloudAdmin", "AdminPassword":"XXXXXXXX", "Image":"WinServer2008R2x64En", "IsHighPerformance":false, "HDDType":"SAS", "LinkedNetworks":[{"NetworkID":57, "IP":"10.0.1.1"}, {"NetworkID":98, "IP":"10.0.2.4"}] } 


An example for creating a virtual server template (POST request at api.1cloud.ru/image ):

 curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer 75bb9805c018b1267b2cf599a38b95a3a811e2ef7ad9ca5ed838ea4c6bafaf50' "https://api.1cloud.ru/image" -d '{"Name":"","TechName":"TemplateAPI","ServerID":6940}' 


Another example is the creation of a private network (POST request):

 curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer 75bb9805c018b1267b2cf599a38b95a3a811e2ef7ad9ca5ed838ea4c6bafaf50' "https://api.1cloud.ru/network" -d '{"Name":"testNetworkAPI"}' 


PS For the Habrakhabr audience, we provide an extended test period, during which we are ready to provide support to all users (to activate it, just write to us at support@1cloud.ru ).

Source: https://habr.com/ru/post/260523/


All Articles