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/v2/Env/ListEnvironments?timestamp=1363462656&token=6WDPTRKQEV&UserApiId=VWRWJ4550LB086FG&HMAC=ccd88c851e04395dc0ecc169470c1d5ea8016613

Response

{
    "data": [
        {
            "blueprint": "A linux environment",
            "description": " CloudShare Pro environment",
            "envId": "V0MDPUQHHN1A",
            "envToken": "VQbE1o1IBQK6B633_UFGog2",
            "environmentPolicy": null,
            "expirationTime": "Wed, 18 Dec 2013 22:00:00 GMT",
            "invitationAllowed": true,
            "licenseValid": "Valid",
            "name": "A linux environment",
            "organization": null,
            "owner": "jsmith@company.com",
            "project": null,
            "snapshot": "snap1",
            "status_code": 2,
            "status_text": "Not ready",
            "view_url": "https://use.cloudshare.com/Pro/Environment.mvc/View/VQbE1o1IBQK6B633_U
        },
        {
            "blueprint": "linux environment",
            "description": "A new linux environment",
            "envId": "VJ1DWJYN5GXB",
            "envToken": "9wtGldOX2PVXHaUlrTRG2g2",
            "environmentPolicy": "CloudShare/PoC (10 days)",
            "expirationTime": "Thu, 04 Apr 2013 09:55:44 GMT",
            "invitationAllowed": true,
            "licenseValid": "Not relevant",
            "name": "Linux2",
            "organization": "CloudShare",
            "owner": "jsmith@company.com",
            "project": "Documentation Campaign",
            "snapshot": "Initial State Snapshot",
            "status_code": 2,
            "status_text": "Not ready",
            "view_url": "https://use.cloudshare.com/Ent/Environment.mvc/View/9wtGldOX2PVXHaUlrT
        },
        {
            "blueprint": "linux environment",
            "description": "A new linux environment",
            "envId": "P400PXZJOWEB",
            "envToken": "9FgUl7qx5--BByJ3sEholw2",
            "environmentPolicy": "CloudShare/PoC (10 days)",
            "expirationTime": "Thu, 04 Apr 2013 10:05:53 GMT",
            "invitationAllowed": true,
            "licenseValid": "Not relevant",
            "name": "Linux2",
            "organization": "CloudShare",
            "owner": "jsmith@company.com",
            "project": "Documentation Campaign",
            "snapshot": "Initial State Snapshot",
            "status_code": 2,
            "status_text": "Not ready",
            "view_url": "https://use.cloudshare.com/Ent/Environment.mvc/View/9FgUl7qx5--BByJ3sE
        },
        {
            "blueprint": "Linux2",
            "description": "A new linux environment",
            "envId": "HA0VLW3GJ0PA",
            "envToken": "Gh5wSR5wN2nm7I6orvTcDg2",
            "environmentPolicy": "CloudShare/PoC (10 days)",
            "expirationTime": "Thu, 04 Apr 2013 08:37:32 GMT",
            "invitationAllowed": false,
            "licenseValid": "Not relevant",
            "name": "Linux2",
            "organization": "CloudShare",
            "owner": "jsmith@company.com",
            "project": "Documentation Campaign",
            "snapshot": null,
            "status_code": 2,
            "status_text": "Not ready",
            "view_url": "https://use.cloudshare.com/Ent/Environment.mvc/View/Gh5wSR5wN2nm7I6orv
        }
    ],
    "remaining_api_calls": 99999,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}

Status

HTTP/1.1 200 OK
Get state of environment

Request status of environment with id HA0VLW3GJ0PA

Response lists single machine for the environment.

Request

https://use.cloudshare.com/API/v2/Env/GetEnvironmentState?envId=HA0VLW3GJ0PA&timestamp=1363463260&token=EA9VL7X4F2&UserApiId=VWRWJ4550LB086FG&HMAC=bd8aa60d0377278294f3c56c28fcc24638225849

Response

{
    "data": {
        "available_actions": {
            "add_vms": true,
            "delete_vm": true,
            "reboot_vm": true,
            "resume_environment": false,
            "revert_environment": false,
            "revert_vm": false,
            "take_snapshot": true
        },
        "blueprint": "Linux2",
        "description": "A new linux environment",
        "envId": "HA0VLW3GJ0PA",
        "envToken": "Gh5wSR5wN2nm7I6orvTcDg2",
        "environmentPolicy": "CloudShare/PoC (10 days)",
        "expirationTime": "Thu, 04 Apr 2013 08:37:32 GMT",
        "invitationAllowed": false,
        "licenseValid": "Not relevant",
        "name": "Linux2",
        "organization": "CloudShare",
        "owner": "jsmith@company.com",
        "project": "Documentation Campaign",
        "resources": {
            "cpu_in_use": 1,
            "cpu_qouta": 10,
            "disk_size_in_use_mb": 12288,
            "disk_size_qouta_mb": 204800,
            "total_memory_in_use_mb": 1024,
            "total_memory_qouta_mb": 10240
        },
        "snapshot": null,
        "status_code": 0,
        "status_text": "Ready",
        "view_url": "https://use.cloudshare.com/Ent/Environment.mvc/View/Gh5wSR5wN2nm7I6orvTcDg2",
        "vms": [
            {
                "FQDN": null,
                "IP": "pub9-70.env.cloudshare.com",
                "description": "OS: CentOS 5 Spec: 12 GB HD / 1 GB RAM Installed: MySQL ",
                "image_url": "https://use.cloudshare.com/ImageHandler.ashx?zsjkKbLQqcJ1PLTNRN2o4w2",
                "name": "CentOS 5 W/ MySQL",
                "os": "Linux",
                "password": null,
                "progress": 100,
                "status_code": 0,
                "status_text": "Ready",
                "url": "https://use.cloudshare.com/Ent/Machine.mvc/Show?machineToken=03kPsIRWu58N-nIGEtOahw2",
                "username": null,
                "vmId": "ZN3OZ4Z3VE2B",
                "vmToken": "03kPsIRWu58N-nIGEtOahw2",
                "webAccessUrl": null
            }
        ]
    },
    "remaining_api_calls": 99997,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}

Status

HTTP/1.1 200 OK
Take a snapshot of the environment

Label the snapshot, Initial snapshot

Request

https://use.cloudshare.com/API/v2/Env/EntAppTakeSnapshot?description=snapshot%20at%20initialization&envId=HA0VLW3GJ0PA&setAsDefault=false&snapshotName=Initial%20snapshot&timestamp=1363464317&token=Z09YVIOXLY&UserApiId=VWRWJ4550LB086FG&HMAC=67201b68789f73f1c4b1e9e094d7f64921a05345

Response

{
    "data": {
        "envId": "HA0VLW3GJ0PA"
    },
    "remaining_api_calls": 99996,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}

Status

HTTP/1.1 200 OK
Revert machine to snapshot state.

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

Request

https://use.cloudshare.com/API/v2/Env/RevertVm?envId=HA0VLW3GJ0PA&timestamp=1363464690&token=KRJIRKOMCX&UserApiId=VWRWJ4550LB086FG&vmId=ZN3OZ4Z3VE2B&HMAC=87c5d31cda6b32aeb698f21b5d6b91f307c320d2

Response

{
    "data": {
        "vmId": "ZN3OZ4Z3VE2B"
    },
    "remaining_api_calls": 99994,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}

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/v2/Env/GetEnvironmentState?envId=HA0VLW3GJ0PA&timestamp=1363464889&token=KYV8SUFT3U&UserApiId=VWRWJ4550LB086FG&HMAC=da3d5c09af0773ad699ab55d8cc8ef010c974fd5

Response

{
    "data": {
        "available_actions": {
            "add_vms": true,
            "delete_vm": true,
            "reboot_vm": true,
            "resume_environment": false,
            "revert_environment": true,
            "revert_vm": true,
            "take_snapshot": false
        },
        "blueprint": "Linux2",
        "description": "A new linux environment",
        "envId": "HA0VLW3GJ0PA",
        "envToken": "Gh5wSR5wN2nm7I6orvTcDg2",
        "environmentPolicy": "CloudShare/PoC (10 days)",
        "expirationTime": "Thu, 04 Apr 2013 08:37:32 GMT",
        "invitationAllowed": true,
        "licenseValid": "Not relevant",
        "name": "Linux2",
        "organization": "CloudShare",
        "owner": "jsmith@company.com",
        "project": "Documentation Campaign",
        "resources": {
            "cpu_in_use": 1,
            "cpu_qouta": 10,
            "disk_size_in_use_mb": 12288,
            "disk_size_qouta_mb": 204800,
            "total_memory_in_use_mb": 1024,
            "total_memory_qouta_mb": 10240
        },
        "snapshot": "Initial snapshot",
        "status_code": 1,
        "status_text": "In progress",
        "view_url": "https://use.cloudshare.com/Ent/Environment.mvc/View/Gh5wSR5wN2nm7I6orvTcDg2",
        "vms": [
            {
                "FQDN": null,
                "IP": "pub12-201.env.cloudshare.com",
                "description": "OS: CentOS 5 Spec: 12 GB HD / 1 GB RAM Installed: MySQL",
                "image_url": "https://use.cloudshare.com/ImageHandler.ashx?zsjkKbLQqcJ1PLTNRN2o4w2",
                "name": "CentOS 5 W/ MySQL",
                "os": "Linux",
                "password": null,
                "progress": 63,
                "status_code": 1,
                "status_text": "In progress",
                "url": "https://use.cloudshare.com/Ent/Machine.mvc/Show?machineToken=03kPsIRWu58N-nIGEtOahw2",
                "username": null,
                "vmId": "ZN3OZ4Z3VE2B",
                "vmToken": "03kPsIRWu58N-nIGEtOahw2",
                "webAccessUrl": null
            }
        ]
    },
    "remaining_api_calls": 99993,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}

Status

HTTP/1.1 200 OK