📜 ⬆️ ⬇️

How-to: How the API improves the hosting provider infrastructure

image

In our past topic, the topic of the API was touched upon , or more precisely, how the technology could serve the business. In the course of the development of the hosting provider 1cloud, we are faced with the need to improve the quality of integration of client applications with our cloud, as well as facilitate interaction with our infrastructure for customers and partners.

To solve these problems, we developed an API about how this interface works and what tasks it can use to solve our today's topic.
')

How it works


In order for clients to manage their servers from third-party applications, the REST API was implemented.

In one of the previous topics about the project infrastructure, we talked about the fact that when users perform actions in the graphical interface, no processing takes place, the system only forms a task to perform the required action by the handler.

To implement the API, we used the same mechanism. When a client sends a request to the API, a task is formed, then the handler picks it up, after which the execution is done. You can track the status of a specific task by accessing the “Action on server” method :

curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer 75bb9805c018b1267b2cf599a38b95a3a811e2ef7ad9ca5ed838ea4c6bafaf50' https://api.1cloud.ru/Server/777/Action/999 

Sample JSON message header:

 Content-Type: application/json Authorization: Bearer 75bb9805c018b1267b2cf599a38b95a3a811e2ef7ad9ca5ed838ea4c6bafaf50 

In response, the system returns a JSON object containing the task ID, the type of task (in this case, the creation of the server) and its status:

 { "ID":999, "Type":"Create", "State":"Completed" } 

In the future, when commissioning new functions, we will support two interfaces: via the web (control panel) and the program interface (API).

What does it give


In the case of hosting, the API can be useful both to private users who do not want to deal with complex technologies, as well as to large customers and partners who are planning to create their own services based on the provider's infrastructure.

image

Infrastructure 1cloud (image clickable)

Using API methods, you can deploy a server using a single request, while it is possible to fully automate all hosting management tasks (or, for example, to scale the infrastructure) without the need to perform any actions with your hands in the interface
Our API can be used by a number of private and corporate clients. Among them:


In addition, the API can be used as part of the continuous integration process (continuous integration) - during the verification of the finished code, you can create a reference test environment (one or a group of servers) on which all test scenarios are “run”.

An example of the implementation of the client application for the API 1cloud in C # can be found at the link (we express our gratitude for the implementation of Sergei partyz0ne to Vychegzhanin)

That's all for today. Thank you for your attention, we will be happy to answer questions in the comments!

PS Habr users who want to use our API, we will provide an extended test period during which we will fix the problems and difficulties found (to activate it, you just need to contact support at support@1cloud.ru ).

PPS The authors of the best client parts implementations for API 1cloud in other programming languages ​​will be given bonuses in our system. Post your projects on GitHub and we will definitely indicate the name of the author and a link to them on your website.

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


All Articles