在我们的CloudWorks的第3部分中 - 这就是我们使用IT系列的方式,we will introduce you to the CloudWorks API.
这篇博客文章通常适用于对REST API概念和编程的观众。
如果您需要关于什么是Cloudworks的复习,请参阅第1部分,or on How to set it up, see第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.
现在,我们已经完成了Anaplan,AWS S3&Postman中所需的准备工作,我们将提出CloudWorks API请求,以构建和执行集成,以将数据从AWS S3加载到Anaplan。我们将遵循以下典型的CloudWorks任务中概述的步骤,以构建此集成。CloudWorks REST API请求将使用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.
我们将在Postman中执行以下任务,以将AWS S3数据带到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 ishttps://auth.anaplan.com/token/authentication。
Authentication Services API to generate token has the following REST structure:
方法 |
邮政 |
API终点 |
|
Headers |
Authorization: Basic username:password (username:password string must be base64 encoded) |
Copy value fortokenValue收集变量token_value。您将在API请求中使用变量而不是硬编码值。令牌值每30分钟到期。您将需要重新生成一个令牌并更新token_value值变量如果遇到身份验证失败。
The first step in building a CloudWorks integration is to create a connection to AWS S3 bucket. PassingAuthToken在API请求的标题中,我们将在此步骤中创建与AWS S3存储桶的连接。Create Connection API具有以下REST结构。
方法 |
邮政 |
API终点 |
https://api.cloudworks.anaplan.com/1/0/integrations/connection |
Authorization |
No Auth |
Headers |
Authorization: AnaplanAuthToken {{token_value}} |
Body |
{ “类型”:“ Amazons3”, "body": { "name":"AWS_CW_API", “ AccessKeyId”:“ XXXXXXXXXXXXXXXX”, "secretAccessKey":"XXXXXXXXXXXXXXXXXXXXXXX", “ bucketname”:“ anaplandemo” } } 不要更改“类型”的值。 Provide name for following elements: name, accessKeyId, secretAccessKey, & bucketName |
{
“类型”:“ 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:
方法 |
邮政 |
API终点 |
|
Authorization |
No Auth |
Headers |
Authorization: AnaplanAuthToken {{token_value}} |
Body |
{ "name": "CWAPI_AWSS3_Anaplan", "jobs": [ { “ type”:“ amazons3toanaplan”, "sources": [ { “类型”:“ Amazons3”, “ ConnectionID”:“ A2FB43A9-3BC8-4BCB-9F37-DD59A75EEB940”, “ file”:“ source/accountss3.csv” } 这是给予的,,,, "targets": [ { “类型”:“ Anaplan”, "actionId": "112000000005", "fileId": "113000000000", "workspaceId": "8a81b09d5e8c6f27015ece3402487d33", “国防部elId": "35A6EF893D7F47EEA5A554D5CC7DC330" } 这是给予的 } 这是给予的 } Do not change the value for “type”: “AmazonS3ToAnaplan”, “type”:”AmazonS3”, “type”:”Anaplan” 为以下元素提供值:ConnectionID,ActionID,FileID,WorkspaceID,ModelID。 |
{
"name": "CWAPI_AWSS3_Anaplan",
"jobs": [
{
“ type”:“ amazons3toanaplan”,
"sources": [
{
“类型”:“ Amazons3”,
“ ConnectionID”:“ A2FB43A9-3BC8-4BCB-9F37-DD59A75EEB940”,
“ file”:“ source/accountss3.csv”
}
这是给予的,,,,
"targets": [
{
“类型”:“ Anaplan”,
"actionId": "112000000005",
"fileId": "113000000000",
"workspaceId": "8a81b09d5e8c6f27015ece3402487d33",
“国防部elId": "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:
方法 |
邮政 |
API终点 |
|
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:
方法 |
GET |
API终点 |
|
参数 |
Offset = 0 |
Authorization |
No Auth |
Headers |
Authorization: AnaplanAuthToken {{token_value}} |
Body |
None |