Chilkat Online Tools

DescribePipeline delphiDll Example

AWS IoT Analytics

var
rest: HCkRest;
success: Boolean;
authAws: HCkAuthAws;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
jResp: HCkJsonObject;
v_String: PWideChar;
addAttributesName: PWideChar;
v_Next: PWideChar;
ChannelName: PWideChar;
channelName: PWideChar;
channelNext: PWideChar;
DatastoreName: PWideChar;
datastoreName: PWideChar;
Attribute: PWideChar;
deviceRegistryEnrichName: PWideChar;
deviceRegistryEnrichNext: PWideChar;
RoleArn: PWideChar;
ThingName: PWideChar;
deviceShadowEnrichAttribute: PWideChar;
deviceShadowEnrichName: PWideChar;
deviceShadowEnrichNext: PWideChar;
deviceShadowEnrichRoleArn: PWideChar;
deviceShadowEnrichThingName: PWideChar;
Filter: PWideChar;
filterName: PWideChar;
filterNext: PWideChar;
BatchSize: Integer;
LambdaName: PWideChar;
lambdaName: PWideChar;
lambdaNext: PWideChar;
mathAttribute: PWideChar;
Math: PWideChar;
mathName: PWideChar;
mathNext: PWideChar;
removeAttributesName: PWideChar;
removeAttributesNext: PWideChar;
selectAttributesName: PWideChar;
selectAttributesNext: PWideChar;
j: Integer;
count_j: Integer;
strVal: PWideChar;
creationTime: Integer;
id: PWideChar;
status: PWideChar;
Arn: PWideChar;
CreationTime: Integer;
LastUpdateTime: Integer;
Name: PWideChar;
i: Integer;
count_i: Integer;

begin
// 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) then
  begin
    Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(CkRest_getConnectFailReason(rest)));
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

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) then
  begin
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;
respStatusCode := CkRest_getResponseStatusCode(rest);
Memo1.Lines.Add('response status code = ' + IntToStr(respStatusCode));
if (respStatusCode <> 200) then
  begin
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(CkRest__responseHeader(rest));
    Memo1.Lines.Add('Response Body:');
    Memo1.Lines.Add(CkStringBuilder__getAsString(sbResponseBody));
    Exit;
  end;

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

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 do
  begin
    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 do
      begin
        CkJsonObject_putJ(jResp,j);
        strVal := CkJsonObject__stringOf(jResp,'pipeline.activities[i].removeAttributes.attributes[j]');
        j := j + 1;
      end;

    j := 0;
    count_j := CkJsonObject_SizeOfArray(jResp,'pipeline.activities[i].selectAttributes.attributes');
    while j < count_j do
      begin
        CkJsonObject_putJ(jResp,j);
        strVal := CkJsonObject__stringOf(jResp,'pipeline.activities[i].selectAttributes.attributes[j]');
        j := j + 1;
      end;

    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'pipeline.reprocessingSummaries');
while i < count_i do
  begin
    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;
  end;

// 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);