DescribePipeline unicodeC Example
#include <C_CkRestW.h>
#include <C_CkAuthAwsW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkRestW rest;
BOOL success;
HCkAuthAwsW authAws;
HCkStringBuilderW sbResponseBody;
int respStatusCode;
HCkJsonObjectW jResp;
const wchar_t *v_String;
const wchar_t *addAttributesName;
const wchar_t *v_Next;
const wchar_t *ChannelName;
const wchar_t *channelName;
const wchar_t *channelNext;
const wchar_t *DatastoreName;
const wchar_t *datastoreName;
const wchar_t *Attribute;
const wchar_t *deviceRegistryEnrichName;
const wchar_t *deviceRegistryEnrichNext;
const wchar_t *RoleArn;
const wchar_t *ThingName;
const wchar_t *deviceShadowEnrichAttribute;
const wchar_t *deviceShadowEnrichName;
const wchar_t *deviceShadowEnrichNext;
const wchar_t *deviceShadowEnrichRoleArn;
const wchar_t *deviceShadowEnrichThingName;
const wchar_t *Filter;
const wchar_t *filterName;
const wchar_t *filterNext;
int BatchSize;
const wchar_t *LambdaName;
const wchar_t *lambdaName;
const wchar_t *lambdaNext;
const wchar_t *mathAttribute;
const wchar_t *Math;
const wchar_t *mathName;
const wchar_t *mathNext;
const wchar_t *removeAttributesName;
const wchar_t *removeAttributesNext;
const wchar_t *selectAttributesName;
const wchar_t *selectAttributesNext;
int j;
int count_j;
const wchar_t *strVal;
int creationTime;
const wchar_t *id;
const wchar_t *status;
const wchar_t *Arn;
int CreationTime;
int LastUpdateTime;
const wchar_t *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 = CkRestW_Create();
authAws = CkAuthAwsW_Create();
CkAuthAwsW_putAccessKey(authAws,L"AWS_ACCESS_KEY");
CkAuthAwsW_putSecretKey(authAws,L"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.)
CkAuthAwsW_putRegion(authAws,L"us-west-2");
CkAuthAwsW_putServiceName(authAws,L"iotanalytics");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRestW_SetAuthAws(rest,authAws);
// URL: https://iotanalytics.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = CkRestW_Connect(rest,L"iotanalytics.us-west-2.amazonaws.com",443,TRUE,TRUE);
if (success != TRUE) {
wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
return;
}
CkRestW_AddHeader(rest,L"Content-Type",L"application/x-amz-json-1.1");
CkRestW_AddHeader(rest,L"X-Amz-Target",L"DescribePipeline");
sbResponseBody = CkStringBuilderW_Create();
success = CkRestW_FullRequestNoBodySb(rest,L"GET",L"/pipelines/{pipelineName}",sbResponseBody);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
respStatusCode = CkRestW_getResponseStatusCode(rest);
wprintf(L"response status code = %d\n",respStatusCode);
if (respStatusCode != 200) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkRestW_responseHeader(rest));
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkStringBuilderW_getAsString(sbResponseBody));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObjectW_Create();
CkJsonObjectW_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 = CkJsonObjectW_stringOf(jResp,L"pipeline.arn");
CreationTime = CkJsonObjectW_IntOf(jResp,L"pipeline.creationTime");
LastUpdateTime = CkJsonObjectW_IntOf(jResp,L"pipeline.lastUpdateTime");
Name = CkJsonObjectW_stringOf(jResp,L"pipeline.name");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"pipeline.activities");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
v_String = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].addAttributes.attributes.string");
addAttributesName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].addAttributes.name");
v_Next = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].addAttributes.next");
ChannelName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].channel.channelName");
channelName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].channel.name");
channelNext = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].channel.next");
DatastoreName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].datastore.datastoreName");
datastoreName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].datastore.name");
Attribute = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].deviceRegistryEnrich.attribute");
deviceRegistryEnrichName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].deviceRegistryEnrich.name");
deviceRegistryEnrichNext = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].deviceRegistryEnrich.next");
RoleArn = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].deviceRegistryEnrich.roleArn");
ThingName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].deviceRegistryEnrich.thingName");
deviceShadowEnrichAttribute = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].deviceShadowEnrich.attribute");
deviceShadowEnrichName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].deviceShadowEnrich.name");
deviceShadowEnrichNext = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].deviceShadowEnrich.next");
deviceShadowEnrichRoleArn = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].deviceShadowEnrich.roleArn");
deviceShadowEnrichThingName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].deviceShadowEnrich.thingName");
Filter = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].filter.filter");
filterName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].filter.name");
filterNext = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].filter.next");
BatchSize = CkJsonObjectW_IntOf(jResp,L"pipeline.activities[i].lambda.batchSize");
LambdaName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].lambda.lambdaName");
lambdaName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].lambda.name");
lambdaNext = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].lambda.next");
mathAttribute = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].math.attribute");
Math = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].math.math");
mathName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].math.name");
mathNext = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].math.next");
removeAttributesName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].removeAttributes.name");
removeAttributesNext = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].removeAttributes.next");
selectAttributesName = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].selectAttributes.name");
selectAttributesNext = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].selectAttributes.next");
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"pipeline.activities[i].removeAttributes.attributes");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].removeAttributes.attributes[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"pipeline.activities[i].selectAttributes.attributes");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"pipeline.activities[i].selectAttributes.attributes[j]");
j = j + 1;
}
i = i + 1;
}
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"pipeline.reprocessingSummaries");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
creationTime = CkJsonObjectW_IntOf(jResp,L"pipeline.reprocessingSummaries[i].creationTime");
id = CkJsonObjectW_stringOf(jResp,L"pipeline.reprocessingSummaries[i].id");
status = CkJsonObjectW_stringOf(jResp,L"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"
// }
// ]
// }
// }
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}