Advanced Cloud Hosting/Cloud API

From XMission Wiki
Revision as of 16:42, 16 November 2016 by Boom (talk | contribs)
Jump to: navigation, search

Archives.png

The RESTful API is one of the most useful and more interesting features of our Cloud Infrastructure service. With the ability to expose nearly all the features of your control panel the API will definitely help you get some 'REST'.

The Cloud Infrastructure RESTful API is well documented and available to all Cloud Infrastructure and Cloud Server subscribers. You can read the full documentation here:

http://download.pa.parallels.com/poa/5.4/doc/pdf/POA%20RESTful%20API%20Guide/paci-restful-api-guide-5.4.pdf


Accessing a Resource

A PACI resource is accessed by sending an HTTPS request to a PACI server. When the server receives a request, it processes it accordingly (performs actions or retrieves data) and sends back a response that can contain the data that you requested, an operation status code, or an error messate. All PACI resources are accessed at the following URL (referred to as baseURL)

https://{ip_address | hostname}:port/paci/version

where:

  1. ip_address | hostname is the PACI server IP address or hostname.
  2. port is the port number on which the server is listening for REST requests
  3. paci must be typed exactly as shown
  4. version is the API version number

For our resource the baseURL will use the following:

https://api.cloud.xmission.com:4464/paci/v1.0/


Server Management

Using this API can come in handy for various types of resource information for example you can use the API to list your current server, configure your server, even stop and start lets take a look at a few basic commands.

List your current servers

Use this request to obtain the list of servers owned by the current user

GET https://api.cloud.xmission.com:4464/paci/v1.0/ve

A sample out put would list your current servers.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ve-list>
    <ve-info description="XMission minecraft server" state="STARTED" name="minecraft" subscription-id="1003209"/>
</ve-list>


More specific server info

If you want to be more specific and obtain information about a specific server you can add the server name like this:

GET https://api.cloud.xmission.com:4464/paci/v1.0/ve/server1

A sample out put will look like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ve>
    <id>296</id>
    <uuid>3c1c50b1.13d794f9065._7ff0</uuid>
    <hnId>14</hnId>
    <customer-id>1000001</customer-id>
    <name>server1</name>
    <description>Testing Server</description>
    <subscription-id>100001</subscription-id>
    <cpu number="4" power="1500"/>
    <ram-size>6400</ram-size>
    <bandwidth>10000</bandwidth>
    <ve-disk created="true" id="0" local="true" size="25"/>
    <platform>
        <template-info name="ubuntu-12.04-x86_64"/>
        <os-info type="ubuntu-12.04-x64" technology="CT"/>
    </platform>
    <network private-ip="10.0.0.0/8">
        <public-ip chunk-ref="1" id="269" address="123.123.123.123/24" gateway="123.123.123.1"/>
    </network>
    <state>STARTED</state>
    <primary-disk-id>0</primary-disk-id>
    <template-id>12</template-id>
    <admin login="root" password="[hidden]"/>
    <steady-state>STARTED</steady-state>
</ve>

Here you can see it shows you all relative information about the server including the number of CPUs, CPU Power, Ram, IP address and much more.

Many more useful command can be used as well - more common would be to start or stop your server.


Start / Stop your Server

PUT https://api.cloud.xmission.com:4464/paci/v1.0/ve/server1/stop

A sample output would be:

VE START initiated

There is so much more you can do with this API including adjusting your server at peak times to compensate for your server load, and then readjusting them back during non peak times.

We have a great blog post regarding this API located on Transmission XMission's Company Journal

Use the Cloud Infrastructure API to Automatically Resize Your Server

This documentation is to be used as a guide. Your server will require different settings to optimize your traffic and this code is not perfect. We encourage you to customize it to fit your needs, or write it in a language of your choice. Remember to refer to the documentation.