Chilkat Online Tools

DescribeDataset Foxpro Example

AWS IoT Analytics

LOCAL loRest
LOCAL lnSuccess
LOCAL loAuthAws
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJResp
LOCAL lcActionName
LOCAL lcExecutionRoleArn
LOCAL lcImage
LOCAL lcComputeType
LOCAL lnVolumeSizeInGB
LOCAL lcSqlQuery
LOCAL j
LOCAL lnCount_j
LOCAL lcDatasetName
LOCAL lnDoubleValue
LOCAL lcName
LOCAL lcFileName
LOCAL lcStringValue
LOCAL lnOffsetSeconds
LOCAL lcTimeExpression
LOCAL lcInputName
LOCAL lcRoleArn
LOCAL lcBucket
LOCAL lcDatabaseName
LOCAL lcTableName
LOCAL lcKey
LOCAL lcS3DestinationConfigurationRoleArn
LOCAL lcEntryName
LOCAL lnTimeoutInMinutes
LOCAL lcRuleName
LOCAL lcDatasetName
LOCAL lcExpression
LOCAL lcArn
LOCAL lnCreationTime
LOCAL lnLastUpdateTime
LOCAL lcName
LOCAL lnNumberOfDays
LOCAL lnUnlimited
LOCAL lcStatus
LOCAL lnMaxVersions
LOCAL lnVersioningConfigurationUnlimited
LOCAL i
LOCAL lnCount_i

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

loRest = CreateObject('Chilkat_9_5_0.Rest')

loAuthAws = CreateObject('Chilkat_9_5_0.AuthAws')
loAuthAws.AccessKey = "AWS_ACCESS_KEY"
loAuthAws.SecretKey = "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.)
loAuthAws.Region = "us-west-2"
loAuthAws.ServiceName = "iotanalytics"
* SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loRest.SetAuthAws(loAuthAws)

* URL: https://iotanalytics.us-west-2.amazonaws.com/
* Use the same region as specified above.
lnSuccess = loRest.Connect("iotanalytics.us-west-2.amazonaws.com",443,1,1)
IF (lnSuccess <> 1) THEN
    ? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loAuthAws
    CANCEL
ENDIF

loRest.AddHeader("Content-Type","application/x-amz-json-1.1")
loRest.AddHeader("X-Amz-Target","DescribeDataset")

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/datasets/{datasetName}",loSbResponseBody)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loAuthAws
    RELEASE loSbResponseBody
    CANCEL
ENDIF

lnRespStatusCode = loRest.ResponseStatusCode
? "response status code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode <> 200) THEN
    ? "Response Header:"
    ? loRest.ResponseHeader
    ? "Response Body:"
    ? loSbResponseBody.GetAsString()
    RELEASE loRest
    RELEASE loAuthAws
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)

* 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

lcArn = loJResp.StringOf("dataset.arn")
lnCreationTime = loJResp.IntOf("dataset.creationTime")
lnLastUpdateTime = loJResp.IntOf("dataset.lastUpdateTime")
lcName = loJResp.StringOf("dataset.name")
lnNumberOfDays = loJResp.IntOf("dataset.retentionPeriod.numberOfDays")
lnUnlimited = loJResp.IntOf("dataset.retentionPeriod.unlimited")
lcStatus = loJResp.StringOf("dataset.status")
lnMaxVersions = loJResp.IntOf("dataset.versioningConfiguration.maxVersions")
lnVersioningConfigurationUnlimited = loJResp.IntOf("dataset.versioningConfiguration.unlimited")
i = 0
lnCount_i = loJResp.SizeOfArray("dataset.actions")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcActionName = loJResp.StringOf("dataset.actions[i].actionName")
    lcExecutionRoleArn = loJResp.StringOf("dataset.actions[i].containerAction.executionRoleArn")
    lcImage = loJResp.StringOf("dataset.actions[i].containerAction.image")
    lcComputeType = loJResp.StringOf("dataset.actions[i].containerAction.resourceConfiguration.computeType")
    lnVolumeSizeInGB = loJResp.IntOf("dataset.actions[i].containerAction.resourceConfiguration.volumeSizeInGB")
    lcSqlQuery = loJResp.StringOf("dataset.actions[i].queryAction.sqlQuery")
    j = 0
    lnCount_j = loJResp.SizeOfArray("dataset.actions[i].containerAction.variables")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcDatasetName = loJResp.StringOf("dataset.actions[i].containerAction.variables[j].datasetContentVersionValue.datasetName")
        lnDoubleValue = loJResp.IntOf("dataset.actions[i].containerAction.variables[j].doubleValue")
        lcName = loJResp.StringOf("dataset.actions[i].containerAction.variables[j].name")
        lcFileName = loJResp.StringOf("dataset.actions[i].containerAction.variables[j].outputFileUriValue.fileName")
        lcStringValue = loJResp.StringOf("dataset.actions[i].containerAction.variables[j].stringValue")
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("dataset.actions[i].queryAction.filters")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lnOffsetSeconds = loJResp.IntOf("dataset.actions[i].queryAction.filters[j].deltaTime.offsetSeconds")
        lcTimeExpression = loJResp.StringOf("dataset.actions[i].queryAction.filters[j].deltaTime.timeExpression")
        j = j + 1
    ENDDO
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("dataset.contentDeliveryRules")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcInputName = loJResp.StringOf("dataset.contentDeliveryRules[i].destination.iotEventsDestinationConfiguration.inputName")
    lcRoleArn = loJResp.StringOf("dataset.contentDeliveryRules[i].destination.iotEventsDestinationConfiguration.roleArn")
    lcBucket = loJResp.StringOf("dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.bucket")
    lcDatabaseName = loJResp.StringOf("dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.glueConfiguration.databaseName")
    lcTableName = loJResp.StringOf("dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.glueConfiguration.tableName")
    lcKey = loJResp.StringOf("dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.key")
    lcS3DestinationConfigurationRoleArn = loJResp.StringOf("dataset.contentDeliveryRules[i].destination.s3DestinationConfiguration.roleArn")
    lcEntryName = loJResp.StringOf("dataset.contentDeliveryRules[i].entryName")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("dataset.lateDataRules")
DO WHILE i < lnCount_i
    loJResp.I = i
    lnTimeoutInMinutes = loJResp.IntOf("dataset.lateDataRules[i].ruleConfiguration.deltaTimeSessionWindowConfiguration.timeoutInMinutes")
    lcRuleName = loJResp.StringOf("dataset.lateDataRules[i].ruleName")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("dataset.triggers")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcDatasetName = loJResp.StringOf("dataset.triggers[i].dataset.name")
    lcExpression = loJResp.StringOf("dataset.triggers[i].schedule.expression")
    i = i + 1
ENDDO

* 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
*     }
*   }
* }

RELEASE loRest
RELEASE loAuthAws
RELEASE loSbResponseBody
RELEASE loJResp