DescribePipeline C Example
#include <C_CkRest.h>
#include <C_CkAuthAws.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>
void ChilkatSample(void)
{
HCkRest rest;
BOOL success;
HCkAuthAws authAws;
HCkStringBuilder sbResponseBody;
int respStatusCode;
HCkJsonObject jResp;
const char *v_String;
const char *addAttributesName;
const char *v_Next;
const char *ChannelName;
const char *channelName;
const char *channelNext;
const char *DatastoreName;
const char *datastoreName;
const char *Attribute;
const char *deviceRegistryEnrichName;
const char *deviceRegistryEnrichNext;
const char *RoleArn;
const char *ThingName;
const char *deviceShadowEnrichAttribute;
const char *deviceShadowEnrichName;
const char *deviceShadowEnrichNext;
const char *deviceShadowEnrichRoleArn;
const char *deviceShadowEnrichThingName;
const char *Filter;
const char *filterName;
const char *filterNext;
int BatchSize;
const char *LambdaName;
const char *lambdaName;
const char *lambdaNext;
const char *mathAttribute;
const char *Math;
const char *mathName;
const char *mathNext;
const char *removeAttributesName;
const char *removeAttributesNext;
const char *selectAttributesName;
const char *selectAttributesNext;
int j;
int count_j;
const char *strVal;
int creationTime;
const char *id;
const char *status;
const char *Arn;
int CreationTime;
int LastUpdateTime;
const char *Name;
int i;
int count_i;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
rest = CkRest_Create();
authAws = CkAuthAws_Create();
CkAuthAws_putAccessKey(authAws,"AWS_ACCESS_KEY");
CkAuthAws_putSecretKey(authAws,"AWS_SECRET_KEY");
// Don't forget to change the region to your particular region. (Also make the same change in the call to Connect below.)
CkAuthAws_putRegion(authAws,"us-west-2");
CkAuthAws_putServiceName(authAws,"iotanalytics");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest_SetAuthAws(rest,authAws);
// URL: https://iotanalytics.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = CkRest_Connect(rest,"iotanalytics.us-west-2.amazonaws.com",443,TRUE,TRUE);
if (success != TRUE) {
printf("ConnectFailReason: %d\n",CkRest_getConnectFailReason(rest));
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
return;
}
CkRest_AddHeader(rest,"Content-Type","application/x-amz-json-1.1");
CkRest_AddHeader(rest,"X-Amz-Target","DescribePipeline");
sbResponseBody = CkStringBuilder_Create();
success = CkRest_FullRequestNoBodySb(rest,"GET","/pipelines/{pipelineName}",sbResponseBody);
if (success != TRUE) {
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
CkStringBuilder_Dispose(sbResponseBody);
return;
}
respStatusCode = CkRest_getResponseStatusCode(rest);
printf("response status code = %d\n",respStatusCode);
if (respStatusCode != 200) {
printf("Response Header:\n");
printf("%s\n",CkRest_responseHeader(rest));
printf("Response Body:\n");
printf("%s\n",CkStringBuilder_getAsString(sbResponseBody));
CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
CkStringBuilder_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
// See this example explaining how this memory should be used: const char * functions.
Arn = CkJsonObject_stringOf(jResp,"pipeline.arn");
CreationTime = CkJsonObject_IntOf(jResp,"pipeline.creationTime");
LastUpdateTime = CkJsonObject_IntOf(jResp,"pipeline.lastUpdateTime");
Name = CkJsonObject_stringOf(jResp,"pipeline.name");
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"pipeline.activities");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
v_String = CkJsonObject_stringOf(jResp,"pipeline.activities[i].addAttributes.attributes.string");
addAttributesName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].addAttributes.name");
v_Next = CkJsonObject_stringOf(jResp,"pipeline.activities[i].addAttributes.next");
ChannelName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].channel.channelName");
channelName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].channel.name");
channelNext = CkJsonObject_stringOf(jResp,"pipeline.activities[i].channel.next");
DatastoreName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].datastore.datastoreName");
datastoreName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].datastore.name");
Attribute = CkJsonObject_stringOf(jResp,"pipeline.activities[i].deviceRegistryEnrich.attribute");
deviceRegistryEnrichName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].deviceRegistryEnrich.name");
deviceRegistryEnrichNext = CkJsonObject_stringOf(jResp,"pipeline.activities[i].deviceRegistryEnrich.next");
RoleArn = CkJsonObject_stringOf(jResp,"pipeline.activities[i].deviceRegistryEnrich.roleArn");
ThingName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].deviceRegistryEnrich.thingName");
deviceShadowEnrichAttribute = CkJsonObject_stringOf(jResp,"pipeline.activities[i].deviceShadowEnrich.attribute");
deviceShadowEnrichName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].deviceShadowEnrich.name");
deviceShadowEnrichNext = CkJsonObject_stringOf(jResp,"pipeline.activities[i].deviceShadowEnrich.next");
deviceShadowEnrichRoleArn = CkJsonObject_stringOf(jResp,"pipeline.activities[i].deviceShadowEnrich.roleArn");
deviceShadowEnrichThingName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].deviceShadowEnrich.thingName");
Filter = CkJsonObject_stringOf(jResp,"pipeline.activities[i].filter.filter");
filterName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].filter.name");
filterNext = CkJsonObject_stringOf(jResp,"pipeline.activities[i].filter.next");
BatchSize = CkJsonObject_IntOf(jResp,"pipeline.activities[i].lambda.batchSize");
LambdaName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].lambda.lambdaName");
lambdaName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].lambda.name");
lambdaNext = CkJsonObject_stringOf(jResp,"pipeline.activities[i].lambda.next");
mathAttribute = CkJsonObject_stringOf(jResp,"pipeline.activities[i].math.attribute");
Math = CkJsonObject_stringOf(jResp,"pipeline.activities[i].math.math");
mathName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].math.name");
mathNext = CkJsonObject_stringOf(jResp,"pipeline.activities[i].math.next");
removeAttributesName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].removeAttributes.name");
removeAttributesNext = CkJsonObject_stringOf(jResp,"pipeline.activities[i].removeAttributes.next");
selectAttributesName = CkJsonObject_stringOf(jResp,"pipeline.activities[i].selectAttributes.name");
selectAttributesNext = CkJsonObject_stringOf(jResp,"pipeline.activities[i].selectAttributes.next");
j = 0;
count_j = CkJsonObject_SizeOfArray(jResp,"pipeline.activities[i].removeAttributes.attributes");
while (j < count_j) {
CkJsonObject_putJ(jResp,j);
strVal = CkJsonObject_stringOf(jResp,"pipeline.activities[i].removeAttributes.attributes[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObject_SizeOfArray(jResp,"pipeline.activities[i].selectAttributes.attributes");
while (j < count_j) {
CkJsonObject_putJ(jResp,j);
strVal = CkJsonObject_stringOf(jResp,"pipeline.activities[i].selectAttributes.attributes[j]");
j = j + 1;
}
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"pipeline.reprocessingSummaries");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
creationTime = CkJsonObject_IntOf(jResp,"pipeline.reprocessingSummaries[i].creationTime");
id = CkJsonObject_stringOf(jResp,"pipeline.reprocessingSummaries[i].id");
status = CkJsonObject_stringOf(jResp,"pipeline.reprocessingSummaries[i].status");
i = i + 1;
}
// A sample JSON response body parsed by the above code:
// {
// "pipeline": {
// "activities": [
// {
// "addAttributes": {
// "attributes": {
// "string": "string"
// },
// "name": "string",
// "next": "string"
// },
// "channel": {
// "channelName": "string",
// "name": "string",
// "next": "string"
// },
// "datastore": {
// "datastoreName": "string",
// "name": "string"
// },
// "deviceRegistryEnrich": {
// "attribute": "string",
// "name": "string",
// "next": "string",
// "roleArn": "string",
// "thingName": "string"
// },
// "deviceShadowEnrich": {
// "attribute": "string",
// "name": "string",
// "next": "string",
// "roleArn": "string",
// "thingName": "string"
// },
// "filter": {
// "filter": "string",
// "name": "string",
// "next": "string"
// },
// "lambda": {
// "batchSize": number,
// "lambdaName": "string",
// "name": "string",
// "next": "string"
// },
// "math": {
// "attribute": "string",
// "math": "string",
// "name": "string",
// "next": "string"
// },
// "removeAttributes": {
// "attributes": [
// "string"
// ],
// "name": "string",
// "next": "string"
// },
// "selectAttributes": {
// "attributes": [
// "string"
// ],
// "name": "string",
// "next": "string"
// }
// }
// ],
// "arn": "string",
// "creationTime": number,
// "lastUpdateTime": number,
// "name": "string",
// "reprocessingSummaries": [
// {
// "creationTime": number,
// "id": "string",
// "status": "string"
// }
// ]
// }
// }
CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
}