How-to: How the API Improves Hosting Provider Infrastructure

    image

    In our last topic, the topic of API was touched , or rather, ways of how this technology can serve the business. During the development of the 1cloud hosting provider, we were faced with the need to improve the quality of integration of client applications with our cloud, as well as to 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 be used to solve our today's topic.

    How it works


    In order for clients to be able to manage their servers from third-party applications, a 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 occurs, the system only generates a task to perform the required action by the handler.

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

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

    Example message header in JSON format:

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

    In response, the system will return a JSON object containing the job 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: through the web (control panel) and 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, and to large clients and partners who plan to create their own services based on the provider's infrastructure. 1cloud infrastructure (the picture is clickable) Using the API methods, you can deploy the server with a single request, while it is possible to fully automate all hosting management tasks (or, for example, to scale the infrastructure) without having to perform any actions with your hands in the interface Our API can Enjoy a range of private and corporate clients. Among them:

    image






    • Resellers who resell our services;
    • Partners helping to implement various combinations of services of different hosting providers (an example of such a service in the west is deploy4me.com );
    • Organizations that sell their own services at 1cloud facilities and want to automate the process of creating new server instances;
    • Application developers - the API helps them automatically scale the hosting infrastructure. For example, when the load increases, the system can automatically create a new server and distribute tasks, and when the load decreases, unused servers are automatically deleted.

    In addition, the API can be used as part of the continuous integration process - during the verification of the finished code, you can create a reference test environment (one or a group of servers) on which all test scripts 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 gratitude to Sergey partyz0ne Vycheganzhan for implementation )

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

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

    PPS Authors of the best implementations of client parts for API 1сloud in other programming languages ​​will receive bonuses in our system. Post your projects on GitHub and we will indicate the name of the author and a link to them on our website.

    Also popular now: