DescribeDataset PureBasic Example
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkRest.pb"
IncludeFile "CkAuthAws.pb"
Procedure ChilkatExample()
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
rest.i = CkRest::ckCreate()
If rest.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
authAws.i = CkAuthAws::ckCreate()
If authAws.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkAuthAws::setCkAccessKey(authAws, "AWS_ACCESS_KEY")
CkAuthAws::setCkSecretKey(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::setCkRegion(authAws, "us-west-2")
CkAuthAws::setCkServiceName(authAws, "iotanalytics")
; SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest::ckSetAuthAws(rest,authAws)
; URL: https://iotanalytics.us-west-2.amazonaws.com/
; Use the same region as specified above.
success = CkRest::ckConnect(rest,"iotanalytics.us-west-2.amazonaws.com",443,1,1)
If success <> 1
Debug "ConnectFailReason: " + Str(CkRest::ckConnectFailReason(rest))
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
CkAuthAws::ckDispose(authAws)
ProcedureReturn
EndIf
CkRest::ckAddHeader(rest,"Content-Type","application/x-amz-json-1.1")
CkRest::ckAddHeader(rest,"X-Amz-Target","DescribeDataset")
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkRest::ckFullRequestNoBodySb(rest,"GET","/datasets/{datasetName}",sbResponseBody)
If success <> 1
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
CkAuthAws::ckDispose(authAws)
CkStringBuilder::ckDispose(sbResponseBody)
ProcedureReturn
EndIf
respStatusCode.i = CkRest::ckResponseStatusCode(rest)
Debug "response status code = " + Str(respStatusCode)
If respStatusCode <> 200
Debug "Response Header:"
Debug CkRest::ckResponseHeader(rest)
Debug "Response Body:"
Debug CkStringBuilder::ckGetAsString(sbResponseBody)
CkRest::ckDispose(rest)
CkAuthAws::ckDispose(authAws)
CkStringBuilder::ckDispose(sbResponseBody)
ProcedureReturn
EndIf
jResp.i = CkJsonObject::ckCreate()
If jResp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(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
actionName.s
ExecutionRoleArn.s
Image.s
ComputeType.s
VolumeSizeInGB.i
SqlQuery.s
j.i
count_j.i
DatasetName.s
doubleValue.i
name.s
FileName.s
stringValue.s
OffsetSeconds.i
TimeExpression.s
InputName.s
RoleArn.s
Bucket.s
DatabaseName.s
TableName.s
Key.s
S3DestinationConfigurationRoleArn.s
entryName.s
TimeoutInMinutes.i
ruleName.s
datasetName.s
Expression.s
Arn.s = CkJsonObject::ckStringOf(jResp,"dataset.arn")
CreationTime.i = CkJsonObject::ckIntOf(jResp,"dataset.creationTime")
LastUpdateTime.i = CkJsonObject::ckIntOf(jResp,"dataset.lastUpdateTime")
Name.s = CkJsonObject::ckStringOf(jResp,"dataset.name")
NumberOfDays.i = CkJsonObject::ckIntOf(jResp,"dataset.retentionPeriod.numberOfDays")
Unlimited.i = CkJsonObject::ckIntOf(jResp,"dataset.retentionPeriod.unlimited")
Status.s = CkJsonObject::ckStringOf(jResp,"dataset.status")
MaxVersions.i = CkJsonObject::ckIntOf(jResp,"dataset.versioningConfiguration.maxVersions")
VersioningConfigurationUnlimited.i = CkJsonObject::ckIntOf(jResp,"dataset.versioningConfiguration.unlimited")
i.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(jResp,"dataset.actions")
While i < count_i
CkJsonObject::setCkI(jResp, i)
actionName = CkJsonObject::ckStringOf(jResp,"dataset.actions[i].actionName")
ExecutionRoleArn = CkJsonObject::ckStringOf(jResp,"dataset.actions[i].containerAction.executionRoleArn")
Image = CkJsonObject::ckStringOf(jResp,"dataset.actions[i].containerAction.image")
ComputeType = CkJsonObject::ckStringOf(jResp,"dataset.actions[i].containerAction.resourceConfiguration.computeType")
VolumeSizeInGB = CkJsonObject::ckIntOf(jResp,"dataset.actions[i].containerAction.resourceConfiguration.volumeSizeInGB")
SqlQuery = CkJsonObject::ckStringOf(jResp,"dataset.actions[i].queryAction.sqlQuery")
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"dataset.actions[i].containerAction.variables")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
DatasetName = CkJsonObject::ckStringOf(jResp,"dataset.actions[i].containerAction.variables[j].datasetContentVersionValue.datasetName")
doubleValue = CkJsonObject::ckIntOf(jResp,"dataset.actions[i].containerAction.variables[j].doubleValue")
name = CkJsonObject::ckStringOf(jResp,"dataset.actions[i].containerAction.variables[j].name")
FileName = CkJsonObject::ckStringOf(jResp,"dataset.actions[i].containerAction.variables[j].outputFileUriValue.fileName")
stringValue = CkJsonObject::ckStringOf(jResp,"dataset.actions[i].containerAction.variables[j].stringValue")
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"dataset.actions[i].queryAction.filters")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
OffsetSeconds = CkJsonObject::ckIntOf(jResp,"dataset.actions[i].queryAction.filters[j].deltaTime.offsetSeconds")
TimeExpression = CkJsonObject::ckStringOf(jResp,"dataset.actions[i].queryAction.filters[j].deltaTime.timeExpression")
j = j + 1
Wend
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(jResp,"dataset.contentDeliveryRules")
While i < count_i
CkJsonObject::setCkI(jResp, i)
InputName = CkJsonObject::ckStringOf(jResp,"dataset.contentDeliveryRules[i].destination.iotEventsDestinationConfiguration.inputName")
RoleArn = CkJsonObject::ckStringOf(jResp,"dataset.contentDeliveryRules[i].destination.iotEventsDestinationConfiguration.roleArn")
Bucket = CkJsonObject::ckStringOf(jResp,"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.bucket")
DatabaseName = CkJsonObject::ckStringOf(jResp,"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.glueConfiguration.databaseName")
TableName = CkJsonObject::ckStringOf(jResp,"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.glueConfiguration.tableName")
Key = CkJsonObject::ckStringOf(jResp,"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.key")
S3DestinationConfigurationRoleArn = CkJsonObject::ckStringOf(jResp,"dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.roleArn")
entryName = CkJsonObject::ckStringOf(jResp,"dataset.contentDeliveryRules[i].entryName")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(jResp,"dataset.lateDataRules")
While i < count_i
CkJsonObject::setCkI(jResp, i)
TimeoutInMinutes = CkJsonObject::ckIntOf(jResp,"dataset.lateDataRules[i].ruleConfiguration.deltaTimeSessionWindowConfiguration.timeoutInMinutes")
ruleName = CkJsonObject::ckStringOf(jResp,"dataset.lateDataRules[i].ruleName")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(jResp,"dataset.triggers")
While i < count_i
CkJsonObject::setCkI(jResp, i)
datasetName = CkJsonObject::ckStringOf(jResp,"dataset.triggers[i].dataset.name")
Expression = CkJsonObject::ckStringOf(jResp,"dataset.triggers[i].schedule.expression")
i = i + 1
Wend
; 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
; }
; }
; }
CkRest::ckDispose(rest)
CkAuthAws::ckDispose(authAws)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndProcedure