Workflows for PowerProtect Cloud Snapshot Manager REST API v1

The following workflows are presented to the REST API programmer as examples of how to create a workflow using the PowerProtect Cloud Snapshot Manager REST API. These examples are only to guide the programming effort, and they have to be customized according to the requirements. As part of each workflow, examples of API requests and responses for every step have been provided.

Create on-demand snapshot

The following is a sample workflow for creating on-demand snapshot.

Procedure

  1. Create the Authentication token and send it as Bearer Authentication token under the
    'Authorization'
    header for each of the subsequent API calls.
  2. Discover cloud accounts that are registered with Cloud Snapshot Manager:
    GET /v1/cloud-accounts
    1. Set the
      'Authorization'
      header as mentioned in step 1.
    2. Copy the target cloud account id value from the list in the response. This is used for the
      'cloud_account_id'
      query parameter for GET and JSON keypair in the POST body for each of the subsequent calls.
  3. Take snapshot of cloud resource:
    POST /v1/snapshots
    1. Set the
      'Authorization'
      header as mentioned in step 1.
    2. Set the
      'Content-Type'
      header to
      application/x-www-formurlencoded
    3. In the POST body, provide
      'cloud_account_id'
      ,
      'region_id'
      ,
      'resource_group_id'
      (for Azure),
      'resource_type'
      and
      'resource_id'
      information in key-value pairs.
    4. Copy the
      id
      value from the response. This is the snapshot id that can be used to read its details from the server.
  4. Get snapshot details:
    GET /v1/snapshots/{snapshotId}
    1. Replace
      {snapshotId}
      in the above URL with the one from step 3.4.
    2. Set the
      'Authorization'
      header as mentioned in step 1.

Example usage for the workflow

The following are examples of the API requests and responses for each of the steps in the workflow.

Create Authentication Token 

API Request

The following command uses the Cloud Snapshot Manager REST API to create an authentication token.

  
curl -X POST \ https://ssgosge.emc.com/external/auth/oauth/v2/token \ -H 'cache-control: no-cache' \ -H 'content-type: application/x-www-form-urlencoded' \ -d 'grant_type=client_credentials&client_id=l7xx6bf585bee63e499799b11ca75ed1c99e&client_secret=c540564f40df4491bfff83e89a14254f'
API Response
  
{ "access_token": "cc387d99-7c95-477b-ab5a-5f2c2b5293dc", "token_type": "Bearer", "expires_in": 3600, "scope": "oob" }

Discover cloud accounts registered with Cloud Snapshot Manager 

API request

The following command uses the Cloud Snapshot Manager REST API to generate the list of cloud accounts.

  
curl -X GET \ https://ssgosge.emc.com/csm/v1/cloud_accounts \ -H 'accept: application/json' \ -H 'authorization: Bearer cc387d99-7c95-477b-ab5a-5f2c2b5293dc' \ -H 'cache-control: no-cache' \ -H 'content-type: application/json'
API response

The following response is received from the API.

  
[{ "id": "b402fe9b-42d2-4347-ad12-dca6e5c87ffc", "display_name": "AWS-001", "cloud_provider": "aws", "account_number": "341004231416", "subscription_id": "341004231416" }]

Take snapshot of a cloud resource

API request

The following command uses the Cloud Snapshot Manager REST API to take a snapshot of a cloud resource.

  
curl -X POST \ https://ssgosge.emc.com/csm/v1/snapshots \ -H 'accept: application/json' \ -H 'authorization: Bearer cc387d99-7c95-477b-ab5a-5f2c2b5293dc' \ -H 'cache-control: no-cache' \ -H 'content-type: application/json' \ -d '{ "cloud_account_id":"b402fe9b-42d2-4347-ad12-dca6e5c87ffc", "region_id":"eu-west-3", "resource_id": "i-0ed3200afc73f9552", "resource_type": "vm", "scripts": "{\"timeout\":300,\"preSnapshotScript\":\"pre-script-success\"}", "vss_enabled": false, "retention": 604800 }'
API response

The following response is received from the API.

  
{ "cloud_account_id": "b402fe9b-42d2-4347-ad12-dca6e5c87ffc", "id": "5c73a027-92fe-49de-a05e-ddacdc970006", "region_id": "eu-west-3", "resource_id": "i-0ed3200afc73f9552", "resource_type": "vm", "status": "in progress" }

Get snapshot details

API request

The following command uses the Cloud Snapshot Manager REST API to retrieve snapshot details.

  
curl -X GET \ https://ssgosge.emc.com/csm/v1/snapshots/5c73a027-92fe-49de-a05e-ddacdc970006 \ -H 'accept: application/json' \ -H 'authorization: Bearer cc387d99-7c95-477b-ab5a-5f2c2b5293dc' \ -H 'cache-control: no-cache' \ -H 'content-type: application/json'
API response

The following response is received from the API.

  
{ "id": "5c73a017-92fe-49de-a05e-ddacdc970006", "cloud_account_id": "b402fe9b-42d2-4347-ad12-dca6e5c87ffc", "created_time": 1550565829510, "expiry_time": 1551170629510, "progress": 100, "status": "completed", "resource_type": "vm", "region_id": "eu-west-3", "resource_id": "i-0ed3200afc73f9552" }

Restore a resource from a snapshot

The following is a sample workflow to restore a resource (VM or Volume or Database) from a snapshot.

Procedure

  1. Create the Authentication token and send it as
    Bearer Authentication token
    under the
    'Authorization'
    header for each of the subsequent API calls.
  2. Discover cloud providers that are registered with Cloud Snapshot Manager:
    GET /v1/cloud-accounts
    1. Set the
      'Authorization'
      header as mentioned in step 1.
    2. Copy the target cloud provider id value from the list in the response. This is used for the
      'cloud_account_id'
      query parameter for GET and JSON keypair in the POST body for each of the subsequent calls.
  3. Restore resource from snapshot.
    POST /v1/restores
    1. Set the
      'Authorization'
      header as mentioned in step 1.
    2. Set the
      'Content-Type'
      header to
      application/x-www-formurlencoded
      .
    3. In the POST body, provide the following information in key-value pairs,
      'snapshot_id'
      ,
      'cloud_account_id'
      ,
      'region_id'
      ,
      'resource_group_id'
      (mandatory for Azure),
      'ami_id'
      (optional and for AWS VM),
      'database_identifier'
      (optional and for AWS DB),
      'availability_zone_id'
      (optional and for AWS), and
      'subnet_id'
      (optional and for VM).
    4. Copy the
      id
      value from the response. This is the restore id that can be used to read its details from the server.
  4. Get restored resource details from the snapshot.
    GET /v1/restores/{restoreId}
    1. Replace
      {restoreId}
      in the above URL with the one from step 3.4.
    2. Set the
      'Authorization'
      header as mentioned in step 1.

Example usage for the workflow

The following are examples of the API requests and responses for each of the steps in the workflow. For an example on how to create the authentication token, see Create authentication token and for an example on how to discover cloud providers registered with Cloud Snapshot Manager, see Discover cloud accounts registered with Cloud Snapshot Manager.

Restore resource from a snapshot

API request

The following command uses the Cloud Snapshot Manager REST API to restore a resource from a snapshot.

  
curl -X POST \ https://ssgosge.emc.com/csm/v1/restores \ -H 'accept: application/json' \ -H 'authorization: Bearer cc387d99-7c95-477b-ab5a-5f2c2b5293dc' \ -H 'cache-control: no-cache' -d '{ "cloud_account_id":"b402fe9b-42d2-4347-ad12-dca6e5c87ffc", "snapshot_id":"5c73a017-92fe-49de-a05e-ddacdc970006", "region_id":"eu-west-3" }'
API response

The following response is received from the API.

  
{ "availability_zone_id": "eu-west-3c", "cloud_account_id": "b402fe9b-42d2-4347-ad12-dca6e5c87ffc", "id": "0a748211-1593-416c-aba9-6b4e8fd17cd3", "region_id": "eu-west-3", "resource_type": "vm", "snapshot_id": "5c73a017-92fe-49de-a05e-ddacdc970006", "status": "in progress" }

Get restored resource details from the snapshot

API request

The following command uses the Cloud Snapshot Manager REST API to retrieve the restored resource details from the snapshot.

  
curl -X GET \ https://ssgosge.emc.com/csm/v1/restores/0a748211-1593-416c-aba9-6b4e8fd17cd3 \ -H 'accept: application/json' \ -H 'authorization: Bearer cc387d99-7c95-477b-ab5a-5f2c2b5293dc' \ -H 'cache-control: no-cache' \ -d '{ "cloud_account_id":"b402fe9b-42d2-4347-ad12-dca6e5c87ffc", "snapshot_id":"5c73a017-92fe-49de-a05e-ddacdc970006", "region_id":"eu-west-3" }'
API response

The following response is received from the API.

  
{ "id": "0a748211-1593-416c-aba9-6b4e8fd17cd3", "snapshot_id": "5c73a017-92fe-49de-a05e-ddacdc970006", "cloud_account_id": "b402fe9b-42d2-4347-ad12-dca6e5c87ffc", "progress": 100, "status": "completed", "resource_type": "vm", "region_id": "eu-west-3", "restored_resource_id": "i-11b9c20fbe8983011", "created_time": 1550569105290, "availability_zone_id": "eu-west-3c" }