Chilkat Online Tools

DescribePipeline unicodeCpp Example

AWS IoT Analytics

#include <CkRestW.h>
#include <CkAuthAwsW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkRestW rest;
    bool success;

    CkAuthAwsW authAws;
    authAws.put_AccessKey(L"AWS_ACCESS_KEY");
    authAws.put_SecretKey(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.)
    authAws.put_Region(L"us-west-2");
    authAws.put_ServiceName(L"iotanalytics");
    // SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
    rest.SetAuthAws(authAws);

    // URL: https://iotanalytics.us-west-2.amazonaws.com/
    // Use the same region as specified above.
    success = rest.Connect(L"iotanalytics.us-west-2.amazonaws.com",443,true,true);
    if (success != true) {
        wprintf(L"ConnectFailReason: %d\n",rest.get_ConnectFailReason());
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    rest.AddHeader(L"Content-Type",L"application/x-amz-json-1.1");
    rest.AddHeader(L"X-Amz-Target",L"DescribePipeline");

    CkStringBuilderW sbResponseBody;
    success = rest.FullRequestNoBodySb(L"GET",L"/pipelines/{pipelineName}",sbResponseBody);
    if (success != true) {
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    int respStatusCode = rest.get_ResponseStatusCode();
    wprintf(L"response status code = %d\n",respStatusCode);
    if (respStatusCode != 200) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",rest.responseHeader());
        wprintf(L"Response Body:\n");
        wprintf(L"%s\n",sbResponseBody.getAsString());
        return;
    }

    CkJsonObjectW jResp;
    jResp.LoadSb(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.

    const wchar_t *v_String = 0;
    const wchar_t *addAttributesName = 0;
    const wchar_t *v_Next = 0;
    const wchar_t *ChannelName = 0;
    const wchar_t *channelName = 0;
    const wchar_t *channelNext = 0;
    const wchar_t *DatastoreName = 0;
    const wchar_t *datastoreName = 0;
    const wchar_t *Attribute = 0;
    const wchar_t *deviceRegistryEnrichName = 0;
    const wchar_t *deviceRegistryEnrichNext = 0;
    const wchar_t *RoleArn = 0;
    const wchar_t *ThingName = 0;
    const wchar_t *deviceShadowEnrichAttribute = 0;
    const wchar_t *deviceShadowEnrichName = 0;
    const wchar_t *deviceShadowEnrichNext = 0;
    const wchar_t *deviceShadowEnrichRoleArn = 0;
    const wchar_t *deviceShadowEnrichThingName = 0;
    const wchar_t *Filter = 0;
    const wchar_t *filterName = 0;
    const wchar_t *filterNext = 0;
    int BatchSize;
    const wchar_t *LambdaName = 0;
    const wchar_t *lambdaName = 0;
    const wchar_t *lambdaNext = 0;
    const wchar_t *mathAttribute = 0;
    const wchar_t *Math = 0;
    const wchar_t *mathName = 0;
    const wchar_t *mathNext = 0;
    const wchar_t *removeAttributesName = 0;
    const wchar_t *removeAttributesNext = 0;
    const wchar_t *selectAttributesName = 0;
    const wchar_t *selectAttributesNext = 0;
    int j;
    int count_j;
    const wchar_t *strVal = 0;
    int creationTime;
    const wchar_t *id = 0;
    const wchar_t *status = 0;

    const wchar_t *Arn = jResp.stringOf(L"pipeline.arn");
    int CreationTime = jResp.IntOf(L"pipeline.creationTime");
    int LastUpdateTime = jResp.IntOf(L"pipeline.lastUpdateTime");
    const wchar_t *Name = jResp.stringOf(L"pipeline.name");
    int i = 0;
    int count_i = jResp.SizeOfArray(L"pipeline.activities");
    while (i < count_i) {
        jResp.put_I(i);
        v_String = jResp.stringOf(L"pipeline.activities[i].addAttributes.attributes.string");
        addAttributesName = jResp.stringOf(L"pipeline.activities[i].addAttributes.name");
        v_Next = jResp.stringOf(L"pipeline.activities[i].addAttributes.next");
        ChannelName = jResp.stringOf(L"pipeline.activities[i].channel.channelName");
        channelName = jResp.stringOf(L"pipeline.activities[i].channel.name");
        channelNext = jResp.stringOf(L"pipeline.activities[i].channel.next");
        DatastoreName = jResp.stringOf(L"pipeline.activities[i].datastore.datastoreName");
        datastoreName = jResp.stringOf(L"pipeline.activities[i].datastore.name");
        Attribute = jResp.stringOf(L"pipeline.activities[i].deviceRegistryEnrich.attribute");
        deviceRegistryEnrichName = jResp.stringOf(L"pipeline.activities[i].deviceRegistryEnrich.name");
        deviceRegistryEnrichNext = jResp.stringOf(L"pipeline.activities[i].deviceRegistryEnrich.next");
        RoleArn = jResp.stringOf(L"pipeline.activities[i].deviceRegistryEnrich.roleArn");
        ThingName = jResp.stringOf(L"pipeline.activities[i].deviceRegistryEnrich.thingName");
        deviceShadowEnrichAttribute = jResp.stringOf(L"pipeline.activities[i].deviceShadowEnrich.attribute");
        deviceShadowEnrichName = jResp.stringOf(L"pipeline.activities[i].deviceShadowEnrich.name");
        deviceShadowEnrichNext = jResp.stringOf(L"pipeline.activities[i].deviceShadowEnrich.next");
        deviceShadowEnrichRoleArn = jResp.stringOf(L"pipeline.activities[i].deviceShadowEnrich.roleArn");
        deviceShadowEnrichThingName = jResp.stringOf(L"pipeline.activities[i].deviceShadowEnrich.thingName");
        Filter = jResp.stringOf(L"pipeline.activities[i].filter.filter");
        filterName = jResp.stringOf(L"pipeline.activities[i].filter.name");
        filterNext = jResp.stringOf(L"pipeline.activities[i].filter.next");
        BatchSize = jResp.IntOf(L"pipeline.activities[i].lambda.batchSize");
        LambdaName = jResp.stringOf(L"pipeline.activities[i].lambda.lambdaName");
        lambdaName = jResp.stringOf(L"pipeline.activities[i].lambda.name");
        lambdaNext = jResp.stringOf(L"pipeline.activities[i].lambda.next");
        mathAttribute = jResp.stringOf(L"pipeline.activities[i].math.attribute");
        Math = jResp.stringOf(L"pipeline.activities[i].math.math");
        mathName = jResp.stringOf(L"pipeline.activities[i].math.name");
        mathNext = jResp.stringOf(L"pipeline.activities[i].math.next");
        removeAttributesName = jResp.stringOf(L"pipeline.activities[i].removeAttributes.name");
        removeAttributesNext = jResp.stringOf(L"pipeline.activities[i].removeAttributes.next");
        selectAttributesName = jResp.stringOf(L"pipeline.activities[i].selectAttributes.name");
        selectAttributesNext = jResp.stringOf(L"pipeline.activities[i].selectAttributes.next");
        j = 0;
        count_j = jResp.SizeOfArray(L"pipeline.activities[i].removeAttributes.attributes");
        while (j < count_j) {
            jResp.put_J(j);
            strVal = jResp.stringOf(L"pipeline.activities[i].removeAttributes.attributes[j]");
            j = j + 1;
        }

        j = 0;
        count_j = jResp.SizeOfArray(L"pipeline.activities[i].selectAttributes.attributes");
        while (j < count_j) {
            jResp.put_J(j);
            strVal = jResp.stringOf(L"pipeline.activities[i].selectAttributes.attributes[j]");
            j = j + 1;
        }

        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray(L"pipeline.reprocessingSummaries");
    while (i < count_i) {
        jResp.put_I(i);
        creationTime = jResp.IntOf(L"pipeline.reprocessingSummaries[i].creationTime");
        id = jResp.stringOf(L"pipeline.reprocessingSummaries[i].id");
        status = jResp.stringOf(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"
    //       }
    //     ]
    //   }
    // }
    }