Congrats, you've got here! This is the only RESTful API documentation page.

Please do not hesitate to contact us for any feedbacks or support requests by sending email to support@mobingi.com.

Overview

moCloud RESTful API documentation v1.0

This page is the moCloud RESTful API documentation for deveopers to programtically interact with moCloud instead of accessing the Dashboard. For moCloud user guide full documentations, please refer to Mobingi Documentation .

https://api.mobingi.com/v1

moCloud uses Hash-based message authentication code to verify each API requests.
Pass a "token" parameter with each request by calculating a sha256 hash value.

For a PHP implementation, see following example:


return $token === hash_hmac('sha256', $uid.$time, $api_token);
            

For $api_token value, please log into moCloud Dashboard and grab it at settings page.

moCloud currently provides 3 different datacenter regions across North Ameria (Virgina and California) and Asia (Tokyo).
The region parameters correspond to those 3 regions are:

  • ap-northeast-1 Tokyo
  • us-east-1 Virgina (US East)
  • us-west-1 California (US West)

Note: You will have to pass a region parameter to some API calls. Details will be documented with each API call below.

  • Stack
    A stack (or A.K.A application on moCloud Dashboard) is a set of hardware and software components needed for your application to run. Each level of the stack represents an abstraction layer that provides a high-level overview of your setup. For example, your stack might be comprised of a load balancer, a number of web servers, process and database servers, your operating system and the hardware.
  • Configuration
    A configuration is a json formed file that describes your application's requirements. On moCloud, you can either save a configuration from a running stack (or a.k.a application) or create a new configuration file from scrach. You can launch a new stack (or a.k.a application) based on the configuration file provided.
    Below is an example configuration file:

    Note: Details of the each configuration parameters are documented in each API call below.

Users

Rename a Stack (Application)

GET /user/{uid}/rename/stack

Parameters:

{
    "stack_id" : "ap-5447826c870e7-U6HV4QYa6-nc"
    "stack_nickname" : "My example Appname"
}

Example response:

{
    "status":"success"
}

Get saved stack configurations

GET /user/{uid}/configuration

Example response:

Save a stack's configuration

POST /user/{uid}/configuration

Parameters:

{
    "stack_id" : "ap-5447826c870e7-U6HV4QYa6-nc"
}

Example response:

{
    "status":"success"
}

Delete a saved configuration

POST /user/{uid}/configuration/delete

Parameters:

{
    "id" : "5594d7f025cbb" // the configuration ID
}

Example response:

{
    "status":"success"
}

Get a list of your saved SSH keys

GET /user/{uid}/ssh

Example response:

Save an SSH key to your account

POST /user/{uid}/ssh

Parameters:

{
    "title" : "MyMac", // the ssh title (a.k.a a User)
    "body" : " *** your key body *** " // the ssh key body
}

Example response:

{
    "status":"success"
}

Delete an SSH key from your account

POST /user/{uid}/ssh/delete

Parameters:

{
    "id" : "MyMac", // the ssh key ID
}

Example response:

{
    "status":"success"
}

Check subdomain availablity

GET /user/{uid}/subdomain

Parameters:

{
    "subdomain" : "disneyproduction", // only alphanumeric characters allowed
}

Example error response:

{
    "status":"error",
    "reason":"Name already in use."
}

Example success response:

{
    "status":"success"
}

Get user's total running stacks

GET /user/{uid}/get/stacks

Example response:

{
    "stacks":"2"
}

Get user's total running server nodes

GET /user/{uid}/get/nodes

Example response:

{
    "nodes":"6"
}

Get a instance's metrics graph. This API returns a collection of datapoints of each metric categories.

GET /user/{uid}/get/metrics/graph

Example response:


This API will return a set of Json formed metrics datapoints.
          

Get user's stack status

GET /user/{uid}/get/stackstatus?stack_ids={id1},{id2}

Example response:

[
    {
        "mo-54477f1b43535-d3ubs3r7x":"DELETE_COMPLETE"
    },
    {
        "mo-54477f1b43535-uo7enam02":"CREATE_COMPLETE"
    }
]

Deployment

Create a new stack

POST /deploy/{uid}/{region}/stack/start?configurations={...}

Example parameters:

"configurations":{
    "nickname":"my app 1",
    "region":"ap-northeast-1",
    "architecture":"art_elb",     // or "art_single", see notes below
    "image":"mobingi/ubuntu-nginx-php5",  // the public Image path on Docker Registry
    "code":"git://github.com/mobingilabs/default-site-php"  // the code repo on github
    "privateKey":"*** your github deploy key ***", // if this is a private repo
    "max":"10",  // maximum servers when auto-scaling
    "min":"2",   // minumum servers when auto-scaling
    "type":"t2.micro"
}

Example response:

{
    "stack_name":"mo-54477f1b43535-s07cav0w4-tk",
    "status":"CREATE_IN_PROGRESS"
}

Details:

Parameter architecture has two supported values: art_single and art_elb.

If you create a single structured stack there will be only one server node deployed and it cannot be scaled up or down.

Parameter region has 3 supported values: ap-northeast-1 for Tokyo, us-east-1 for Virginia, and us-west-1 for California.

Parameter type has 4 supported values: t2.micro for type 1, t2.medium for type 2, m3.large for type 3 and m3.xlarge for type 4 servers.

POST /deploy/{uid}/{region}/stack/update

Update an existing stack

Parameters:


{
  "stack_id":"mo-54477f1b43535-s07cav0w4-tk",
  "configurations":"" // this parameter has the same structure with Create Stack.
}
        

Delete an existing stack

POST /deploy/{uid}/{region}/stack/delete

Parameters:


{
  "stack_id":"mo-54477f1b43535-s07cav0w4-tk"
}
        

Delete an existing stack

POST /deploy/{uid}/{region}/code/start

Parameters:


{
  "stack_id":"mo-54477f1b43535-s07cav0w4-tk",
  "method":"github_private", // or "github_public", see notes below
  "filepath":"git://github.com/mobingilabs/default-site-rails", // git repo on GitHub
  "privateKey":"" // if the repo is private
}
        

Parameter method has two supported values: github_public and github_private. For the private repo you need to pass privateKey value as well.

Attach a keypair to stack

POST /deploy/{uid}/{region}/serverconfig/attachkeypair

Parameters:


{
  "stack_id":"",
  "keypair_id":""
}
        

Detach a keypair from stack

POST /deploy/{uid}/{region}/serverconfig/detachkeypair

Parameters:


{
  "stack_id":"ap-5447826c870e7-U6HV4QYa6-nc",
  "keypair_id":"559257902868e"
}
        

Describe

Describe stack detailed information. If stack_ids is not passed, API will return all stacks information.

GET /describe/{uid}/stack

Example request:

{
    "stack_ids":"ap-5447826c870e7-U6HV4QYa6-nc",

}

Example response:

Describe stack's configuration

POST /describe/{uid}/serverconfig

Parameters:


{
  "stack_id":"ap-5447826c870e7-U6HV4QYa6-nc"
}
        

Example Response:

Describe instance's status

POST /describe/{uid}/instance/status

Parameters:


{
  "stack_id":"ap-5447826c870e7-U6HV4QYa6-nc",
  "instance_id":"i-8cdf01c"
}
        

Example response:


{
  "stack_id":"ap-5447826c870e7-U6HV4QYa6-nc",
  "instance_id":"i-05f3d6c7",
  "status":"complete"
}