In Part 3 of our CloudWorks - This is How We Use It series, we will introduce you to the CloudWorks API.
This blog post is typically for an audience comfortable with REST APIs concepts and programming.
If you need a refresher on What CloudWorks is, see Part 1, or on How to set it up, see Part 2.
CloudWorks API will allow you to create & execute connections and integrations extending integration automation capabilities between Amazon AWS S3 & Anaplan.
We will use a typical CloudWorks workflow to build and run integrations using REST API & Postman. To follow along, download the set of Jupyter Notebooks and data set that will walk you through each step of this workflow using Python (CloudWorksAPIBasic.zip and AccountDetailsS3.zip).
The following are minimum requirements to be able to perform the steps described in this blog.
Now that we have completed the required prep-work in Anaplan, AWS S3 & Postman, we will make CloudWorks API requests to build and execute integrations to load data from AWS S3 to Anaplan. We will follow steps outlined in a typical CloudWorks task, outlined below, to build this integration. CloudWorks REST API requests will be made using Postman.
Each Anaplan API request begins with generating an Authentication Token using Anaplan Authentication Services REST API. Generated Auth Token is then passed in the header of CloudWorks API request for Anaplan authentication. Keep in mind, Anaplan Authtoken is valid for only 30 min. Once expired, you will need to regenerate the token and update CloudWorks API header.
We will perform the following tasks in Postman to bring AWS S3 data to Anaplan.
The first step in any Anaplan API request, including CloudWorks, is generating Anaplan Authentication Token. The authentication token can be generated using Anaplan Authentication Services API. URL for authentication services is https://auth.anaplan.com/token/authentication.
Authentication Services API to generate token has the following REST structure:
Method |
POST |
API end point |
|
Headers |
Authorization: Basic username:password (username:password string must be base64 encoded) |
Copy value for tokenValue to collection variable token_value. You will use variables instead of hard coding values in your API requests. Token values expire every 30 minutes. You will need to re-generate a token and update the token_value value variable if you encounter authentication failures.
The first step in building a CloudWorks integration is to create a connection to AWS S3 bucket. Passing AuthToken in the header of API request, we will create a connection to AWS S3 bucket in this step. Create connection API has the following REST structure.
Method |
POST |
API end point |
https://api.cloudworks.anaplan.com/1/0/integrations/connection |
Authorization |
No Auth |
Headers |
Authorization: AnaplanAuthToken {{token_value}} |
Body |
{ "type": "AmazonS3", "body": { "name":"AWS_CW_API", "accessKeyId":"XXXXXXXXXXXXXXXX", "secretAccessKey":"XXXXXXXXXXXXXXXXXXXXXXX", "bucketName":"anaplandemo" } }
Do not change the value for “type”. Provide name for following elements: name, accessKeyId, secretAccessKey, & bucketName |
{
"type": "AmazonS3",
"body": {
"name":"AWS_CW_API",
"accessKeyId":"XXXXXXXXXXXXXXXX",
"secretAccessKey":"XXXXXXXXXXXXXXXXXXXXXXX",
"bucketName":"anaplandemo"
}
}
In this second step, we will create a CloudWorks integration. In the integration, we will provide connectivity information for both AWS S3 and Anaplan. Two types of integrations can be built:
Create integration API has the following REST structure:
Method |
POST |
API end point |
|
Authorization |
No Auth |
Headers |
Authorization: AnaplanAuthToken {{token_value}} |
Body |
{ "name": "CWAPI_AWSS3_Anaplan", "jobs": [ { "type": "AmazonS3ToAnaplan", "sources": [ { "type": "AmazonS3", "connectionId": "a2fb43a9-3bc8-4bcb-9f37-dd59a75eb940", "file": "source/AccountsS3.csv" } ], "targets": [ { "type": "Anaplan", "actionId": "112000000005", "fileId": "113000000000", "workspaceId": "8a81b09d5e8c6f27015ece3402487d33", "modelId": "35A6EF893D7F47EEA5A554D5CC7DC330" } ] } ] }
Do not change the value for “type”: “AmazonS3ToAnaplan”, “type”:”AmazonS3”, “type”:”Anaplan” Provide values for following elements: connectionId, actionId, fileId, workspaceId, modelId. |
{
"name": "CWAPI_AWSS3_Anaplan",
"jobs": [
{
"type": "AmazonS3ToAnaplan",
"sources": [
{
"type": "AmazonS3",
"connectionId": "a2fb43a9-3bc8-4bcb-9f37-dd59a75eb940",
"file": "source/AccountsS3.csv"
}
],
"targets": [
{
"type": "Anaplan",
"actionId": "112000000005",
"fileId": "113000000000",
"workspaceId": "8a81b09d5e8c6f27015ece3402487d33",
"modelId": "35A6EF893D7F47EEA5A554D5CC7DC330"
}
]
}
]
}
Now that we have created an integration, we will run the integration that loads data from a file on AWS S3 bucket to an Anaplan module. Once the integration is run, we will retrieve a history of integration runs and its details. We will do this in the next step. CloudWorks APIs can be used to schedule integrations. However, in this blog, we will focus on executing integrations via API.
You will need to provide the following details in your API request:
Method |
POST |
API end point |
https://api.cloudworks.anaplan.com/1/0/integrations/<integration_id>/run |
Authorization |
No Auth |
Headers |
Authorization: AnaplanAuthToken {{token_value}} |
Body |
None |
CloudWorks API provides end points to get details on integration run history. REST structure for this end point is:
Method |
GET |
API end point |
https://api.cloudworks.anaplan.com/1/0/integrations/runs/<integrationId> |
Parameters |
Offset = 0 |
Authorization |
No Auth |
Headers |
Authorization: AnaplanAuthToken {{token_value}} |
Body |
None |
@annejulie Brilliant. Thank you.