Scenario 1 – take a snapshot

This scenario lists all environments for a user, then checks the status of a specific one. Then, it takes a snapshot of the environment and reverts the machine back to the snapshot state.

List environments

List all environments for user

Request

https://use.cloudshare.com/API/v1/Env/ListEnvironments?timestamp=1354435644&UserApiId=VWRWJ4550LB086FG&HMAC=7c5373c2fe32058f45d7eff3f8374298566a995a

Response

{
    "envsList": [
        {
            "apiId": "2G5ZZQT0Q4PA",
            "campaign": "API Documentation Campaign",
            "description": "",
            "expirationTime": "Sat, 22 Dec 2012 08:06:38 GMT",
            "invitationAllowed": false,
            "licenseValid": "Not relevant",
            "name": "linux environment",
            "organization": "CloudShare",
            "owner": "****@*****.com",
            "package": "CloudShare/PoC (10 days)",
            "prototype": "linux environment",
            "snapshot": "N/A",
            "status": "Preparing"
        }
    ]
}

Status

HTTP/1.1 200 OK
Get state of environment

Request status of environment with id 2G5ZZQT0Q4PA

Response lists single machine for the environment.

Request

https://use.cloudshare.com/API/v1/Env/GetEnvironmentSTate?EnvApiId=2G5ZZQT0Q4PA&timestamp=1354436092&UserApiId=VWRWJ4550LB086FG&HMAC=e43f210d5af1d90c0cb48ad59f0fa633b063eed3

Response

{
    "apiId": "2G5ZZQT0Q4PA",
    "campaign": "API Documentation Campaign",
    "description": "",
    "expirationTime": "Sat, 22 Dec 2012 08:06:38 GMT",
    "invitationAllowed": true,
    "licenseValid": "Not relevant",
    "machines": [
        {
            "apiId": "WMX5DSTOO22B",
            "description": "OS: Ubuntu 10.04 Server 				Spec: 16 GB HD / 0.5 GB RAM",
            "ip": "pub*-***.env.cloudshare.com",
            "name": "Ubuntu 10.04 Server",
            "password": null,
            "progress": -1,
            "status": "Running",
            "username": null,
            "webAccessUrl": null
        }
    ],
    "name": "linux environment",
    "organization": "CloudShare",
    "owner": "*****@*****.com",
    "package": "CloudShare/PoC (10 days)",
    "prototype": "linux environment",
    "snapshot": " N/A",
    "status": "Running"
}

Status

HTTP/1.1 200 OK
Take a snapshot of the environment

Label the snapshot, newsnapshot. This will be the default snapshot for the environment.

Request

https://use.cloudshare.com/API/v1/Env/EntAppTakeSnapshot?EnvApiId=2G5ZZQT0Q4PA&setasdefault=true&snapshotName=newsnapshot&timestamp=1354435791&UserApiId=VWRWJ4550LB086FG&HMAC=3f69c8b4c171793be67c2e7cad58699ae6438356

Response

{
    "envApiId": "2G5ZZQT0Q4PA"
}

Status

HTTP/1.1 200 OK
Revert machine to snapshot state.

The default snapshot is used. The machine id, WMX5DSTOO22B, is obtained from the getEnvironmentState request, above.

Request

https://use.cloudshare.com/API/v1/Env/RevertMachine?MachineApiId=WMX5DSTOO22B&timestamp=1354436307&UserApiId=VWRWJ4550LB086FG&HMAC=5b1f968d4c763d4d2c089f2875e0e17abd3f6efb

Response

{
    "apiId": "WMX5DSTOO22B"
}

Status

HTTP/1.1 200 OK
Check progress of revert request, using the getEnvironmentState request.

Progress is indicated by the ‘progress‘ line in the JSON response.

Request

https://use.cloudshare.com/API/v1/Env/GetEnvironmentSTate?EnvApiId=2G5ZZQT0Q4PA&timestamp=1354436474&UserApiId=VWRWJ4550LB086FG&HMAC=8c42566f4c54c8ad7d277952ab6c37e512877115

Response

{
    "apiId": "2G5ZZQT0Q4PA",
    "campaign": "API Documentation Campaign",
    "description": "",
    "expirationTime": "Sat, 22 Dec 2012 08:06:38 GMT",
    "invitationAllowed": true,
    "licenseValid": "Not relevant",
    "machines": [
        {
            "apiId": "WMX5DSTOO22B",
            "description": "OS: Ubuntu 10.04 Server                 Spec: 16 GB HD / 0.5 GB RAM",
            "ip": "pub*-***.env.cloudshare.com",
            "name": "Ubuntu 10.04 Server",
            "password": null,
            "progress": 30,
            "status": "Loading from snapshot",
            "username": null,
            "webAccessUrl": null
        }
    ],
    "name": "linux environment",
    "organization": "CloudShare",
    "owner": "*****@*****.com",
    "package": "CloudShare/PoC (10 days)",
    "prototype": "linux environment",
    "snapshot": "newsnapshot",
    "status": "Preparing"
}

Status

HTTP/1.1 200 OK