Chilkat Online Tools

DescribePipeline TCL Example

AWS IoT Analytics

load ./chilkat.dll

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

set rest [new_CkRest]

set authAws [new_CkAuthAws]

CkAuthAws_put_AccessKey $authAws "AWS_ACCESS_KEY"
CkAuthAws_put_SecretKey $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_put_Region $authAws "us-west-2"
CkAuthAws_put_ServiceName $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.
set success [CkRest_Connect $rest "iotanalytics.us-west-2.amazonaws.com" 443 1 1]
if {$success != 1} then {
    puts "ConnectFailReason: [CkRest_get_ConnectFailReason $rest]"
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkAuthAws $authAws
    exit
}

CkRest_AddHeader $rest "Content-Type" "application/x-amz-json-1.1"
CkRest_AddHeader $rest "X-Amz-Target" "DescribePipeline"

set sbResponseBody [new_CkStringBuilder]

set success [CkRest_FullRequestNoBodySb $rest "GET" "/pipelines/{pipelineName}" $sbResponseBody]
if {$success != 1} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkAuthAws $authAws
    delete_CkStringBuilder $sbResponseBody
    exit
}

set respStatusCode [CkRest_get_ResponseStatusCode $rest]
puts "response status code = $respStatusCode"
if {$respStatusCode != 200} then {
    puts "Response Header:"
    puts [CkRest_responseHeader $rest]
    puts "Response Body:"
    puts [CkStringBuilder_getAsString $sbResponseBody]
    delete_CkRest $rest
    delete_CkAuthAws $authAws
    delete_CkStringBuilder $sbResponseBody
    exit
}

set jResp [new_CkJsonObject]

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

set Arn [CkJsonObject_stringOf $jResp "pipeline.arn"]
set CreationTime [CkJsonObject_IntOf $jResp "pipeline.creationTime"]
set LastUpdateTime [CkJsonObject_IntOf $jResp "pipeline.lastUpdateTime"]
set Name [CkJsonObject_stringOf $jResp "pipeline.name"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "pipeline.activities"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set v_String [CkJsonObject_stringOf $jResp "pipeline.activities[i].addAttributes.attributes.string"]
    set addAttributesName [CkJsonObject_stringOf $jResp "pipeline.activities[i].addAttributes.name"]
    set v_Next [CkJsonObject_stringOf $jResp "pipeline.activities[i].addAttributes.next"]
    set ChannelName [CkJsonObject_stringOf $jResp "pipeline.activities[i].channel.channelName"]
    set channelName [CkJsonObject_stringOf $jResp "pipeline.activities[i].channel.name"]
    set channelNext [CkJsonObject_stringOf $jResp "pipeline.activities[i].channel.next"]
    set DatastoreName [CkJsonObject_stringOf $jResp "pipeline.activities[i].datastore.datastoreName"]
    set datastoreName [CkJsonObject_stringOf $jResp "pipeline.activities[i].datastore.name"]
    set Attribute [CkJsonObject_stringOf $jResp "pipeline.activities[i].deviceRegistryEnrich.attribute"]
    set deviceRegistryEnrichName [CkJsonObject_stringOf $jResp "pipeline.activities[i].deviceRegistryEnrich.name"]
    set deviceRegistryEnrichNext [CkJsonObject_stringOf $jResp "pipeline.activities[i].deviceRegistryEnrich.next"]
    set RoleArn [CkJsonObject_stringOf $jResp "pipeline.activities[i].deviceRegistryEnrich.roleArn"]
    set ThingName [CkJsonObject_stringOf $jResp "pipeline.activities[i].deviceRegistryEnrich.thingName"]
    set deviceShadowEnrichAttribute [CkJsonObject_stringOf $jResp "pipeline.activities[i].deviceShadowEnrich.attribute"]
    set deviceShadowEnrichName [CkJsonObject_stringOf $jResp "pipeline.activities[i].deviceShadowEnrich.name"]
    set deviceShadowEnrichNext [CkJsonObject_stringOf $jResp "pipeline.activities[i].deviceShadowEnrich.next"]
    set deviceShadowEnrichRoleArn [CkJsonObject_stringOf $jResp "pipeline.activities[i].deviceShadowEnrich.roleArn"]
    set deviceShadowEnrichThingName [CkJsonObject_stringOf $jResp "pipeline.activities[i].deviceShadowEnrich.thingName"]
    set Filter [CkJsonObject_stringOf $jResp "pipeline.activities[i].filter.filter"]
    set filterName [CkJsonObject_stringOf $jResp "pipeline.activities[i].filter.name"]
    set filterNext [CkJsonObject_stringOf $jResp "pipeline.activities[i].filter.next"]
    set BatchSize [CkJsonObject_IntOf $jResp "pipeline.activities[i].lambda.batchSize"]
    set LambdaName [CkJsonObject_stringOf $jResp "pipeline.activities[i].lambda.lambdaName"]
    set lambdaName [CkJsonObject_stringOf $jResp "pipeline.activities[i].lambda.name"]
    set lambdaNext [CkJsonObject_stringOf $jResp "pipeline.activities[i].lambda.next"]
    set mathAttribute [CkJsonObject_stringOf $jResp "pipeline.activities[i].math.attribute"]
    set Math [CkJsonObject_stringOf $jResp "pipeline.activities[i].math.math"]
    set mathName [CkJsonObject_stringOf $jResp "pipeline.activities[i].math.name"]
    set mathNext [CkJsonObject_stringOf $jResp "pipeline.activities[i].math.next"]
    set removeAttributesName [CkJsonObject_stringOf $jResp "pipeline.activities[i].removeAttributes.name"]
    set removeAttributesNext [CkJsonObject_stringOf $jResp "pipeline.activities[i].removeAttributes.next"]
    set selectAttributesName [CkJsonObject_stringOf $jResp "pipeline.activities[i].selectAttributes.name"]
    set selectAttributesNext [CkJsonObject_stringOf $jResp "pipeline.activities[i].selectAttributes.next"]
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "pipeline.activities[i].removeAttributes.attributes"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "pipeline.activities[i].removeAttributes.attributes[j]"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "pipeline.activities[i].selectAttributes.attributes"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "pipeline.activities[i].selectAttributes.attributes[j]"]
        set j [expr $j + 1]
    }
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "pipeline.reprocessingSummaries"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set creationTime [CkJsonObject_IntOf $jResp "pipeline.reprocessingSummaries[i].creationTime"]
    set id [CkJsonObject_stringOf $jResp "pipeline.reprocessingSummaries[i].id"]
    set status [CkJsonObject_stringOf $jResp "pipeline.reprocessingSummaries[i].status"]
    set i [expr $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"
#       }
#     ]
#   }
# }

delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp