DescribeDataset TCL Example
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" "DescribeDataset"
set sbResponseBody [new_CkStringBuilder]
set success [CkRest_FullRequestNoBodySb $rest "GET" "/datasets/{datasetName}" $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 "dataset.arn"]
set CreationTime [CkJsonObject_IntOf $jResp "dataset.creationTime"]
set LastUpdateTime [CkJsonObject_IntOf $jResp "dataset.lastUpdateTime"]
set Name [CkJsonObject_stringOf $jResp "dataset.name"]
set NumberOfDays [CkJsonObject_IntOf $jResp "dataset.retentionPeriod.numberOfDays"]
set Unlimited [CkJsonObject_IntOf $jResp "dataset.retentionPeriod.unlimited"]
set Status [CkJsonObject_stringOf $jResp "dataset.status"]
set MaxVersions [CkJsonObject_IntOf $jResp "dataset.versioningConfiguration.maxVersions"]
set VersioningConfigurationUnlimited [CkJsonObject_IntOf $jResp "dataset.versioningConfiguration.unlimited"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "dataset.actions"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set actionName [CkJsonObject_stringOf $jResp "dataset.actions[i].actionName"]
set ExecutionRoleArn [CkJsonObject_stringOf $jResp "dataset.actions[i].containerAction.executionRoleArn"]
set Image [CkJsonObject_stringOf $jResp "dataset.actions[i].containerAction.image"]
set ComputeType [CkJsonObject_stringOf $jResp "dataset.actions[i].containerAction.resourceConfiguration.computeType"]
set VolumeSizeInGB [CkJsonObject_IntOf $jResp "dataset.actions[i].containerAction.resourceConfiguration.volumeSizeInGB"]
set SqlQuery [CkJsonObject_stringOf $jResp "dataset.actions[i].queryAction.sqlQuery"]
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "dataset.actions[i].containerAction.variables"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set DatasetName [CkJsonObject_stringOf $jResp "dataset.actions[i].containerAction.variables[j].datasetContentVersionValue.datasetName"]
set doubleValue [CkJsonObject_IntOf $jResp "dataset.actions[i].containerAction.variables[j].doubleValue"]
set name [CkJsonObject_stringOf $jResp "dataset.actions[i].containerAction.variables[j].name"]
set FileName [CkJsonObject_stringOf $jResp "dataset.actions[i].containerAction.variables[j].outputFileUriValue.fileName"]
set stringValue [CkJsonObject_stringOf $jResp "dataset.actions[i].containerAction.variables[j].stringValue"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "dataset.actions[i].queryAction.filters"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set OffsetSeconds [CkJsonObject_IntOf $jResp "dataset.actions[i].queryAction.filters[j].deltaTime.offsetSeconds"]
set TimeExpression [CkJsonObject_stringOf $jResp "dataset.actions[i].queryAction.filters[j].deltaTime.timeExpression"]
set j [expr $j + 1]
}
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "dataset.contentDeliveryRules"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set InputName [CkJsonObject_stringOf $jResp "dataset.contentDeliveryRules[i].destination.iotEventsDestinationConfiguration.inputName"]
set RoleArn [CkJsonObject_stringOf $jResp "dataset.contentDeliveryRules[i].destination.iotEventsDestinationConfiguration.roleArn"]
set Bucket [CkJsonObject_stringOf $jResp "dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.bucket"]
set DatabaseName [CkJsonObject_stringOf $jResp "dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.glueConfiguration.databaseName"]
set TableName [CkJsonObject_stringOf $jResp "dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.glueConfiguration.tableName"]
set Key [CkJsonObject_stringOf $jResp "dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.key"]
set S3DestinationConfigurationRoleArn [CkJsonObject_stringOf $jResp "dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.roleArn"]
set entryName [CkJsonObject_stringOf $jResp "dataset.contentDeliveryRules[i].entryName"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "dataset.lateDataRules"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set TimeoutInMinutes [CkJsonObject_IntOf $jResp "dataset.lateDataRules[i].ruleConfiguration.deltaTimeSessionWindowConfiguration.timeoutInMinutes"]
set ruleName [CkJsonObject_stringOf $jResp "dataset.lateDataRules[i].ruleName"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "dataset.triggers"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set datasetName [CkJsonObject_stringOf $jResp "dataset.triggers[i].dataset.name"]
set Expression [CkJsonObject_stringOf $jResp "dataset.triggers[i].schedule.expression"]
set i [expr $i + 1]
}
# A sample JSON response body parsed by the above code:
# {
# "dataset": {
# "actions": [
# {
# "actionName": "string",
# "containerAction": {
# "executionRoleArn": "string",
# "image": "string",
# "resourceConfiguration": {
# "computeType": "string",
# "volumeSizeInGB": number
# },
# "variables": [
# {
# "datasetContentVersionValue": {
# "datasetName": "string"
# },
# "doubleValue": number,
# "name": "string",
# "outputFileUriValue": {
# "fileName": "string"
# },
# "stringValue": "string"
# }
# ]
# },
# "queryAction": {
# "filters": [
# {
# "deltaTime": {
# "offsetSeconds": number,
# "timeExpression": "string"
# }
# }
# ],
# "sqlQuery": "string"
# }
# }
# ],
# "arn": "string",
# "contentDeliveryRules": [
# {
# "destination": {
# "iotEventsDestinationConfiguration": {
# "inputName": "string",
# "roleArn": "string"
# },
# "s3DestinationConfiguration": {
# "bucket": "string",
# "glueConfiguration": {
# "databaseName": "string",
# "tableName": "string"
# },
# "key": "string",
# "roleArn": "string"
# }
# },
# "entryName": "string"
# }
# ],
# "creationTime": number,
# "lastUpdateTime": number,
# "lateDataRules": [
# {
# "ruleConfiguration": {
# "deltaTimeSessionWindowConfiguration": {
# "timeoutInMinutes": number
# }
# },
# "ruleName": "string"
# }
# ],
# "name": "string",
# "retentionPeriod": {
# "numberOfDays": number,
# "unlimited": boolean
# },
# "status": "string",
# "triggers": [
# {
# "dataset": {
# "name": "string"
# },
# "schedule": {
# "expression": "string"
# }
# }
# ],
# "versioningConfiguration": {
# "maxVersions": number,
# "unlimited": boolean
# }
# }
# }
delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp