Chilkat Online Tools

DescribePipeline DataFlex Example

AWS IoT Analytics

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
    Variant vAuthAws
    Handle hoAuthAws
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Integer iRespStatusCode
    Handle hoJResp
    String sV_String
    String sAddAttributesName
    String sV_Next
    String sChannelName
    String sChannelName
    String sChannelNext
    String sDatastoreName
    String sDatastoreName
    String sAttribute
    String sDeviceRegistryEnrichName
    String sDeviceRegistryEnrichNext
    String sRoleArn
    String sThingName
    String sDeviceShadowEnrichAttribute
    String sDeviceShadowEnrichName
    String sDeviceShadowEnrichNext
    String sDeviceShadowEnrichRoleArn
    String sDeviceShadowEnrichThingName
    String sFilter
    String sFilterName
    String sFilterNext
    Integer iBatchSize
    String sLambdaName
    String sLambdaName
    String sLambdaNext
    String sMathAttribute
    String sMath
    String sMathName
    String sMathNext
    String sRemoveAttributesName
    String sRemoveAttributesNext
    String sSelectAttributesName
    String sSelectAttributesNext
    Integer j
    Integer iCount_j
    String sStrVal
    Integer iCreationTime
    String sId
    String sStatus
    String sArn
    Integer iCreationTime
    Integer iLastUpdateTime
    String sName
    Integer i
    Integer iCount_i
    String sTemp1
    Integer iTemp1

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

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    Get Create (RefClass(cComChilkatAuthAws)) To hoAuthAws
    If (Not(IsComObjectCreated(hoAuthAws))) Begin
        Send CreateComObject of hoAuthAws
    End
    Set ComAccessKey Of hoAuthAws To "AWS_ACCESS_KEY"
    Set ComSecretKey Of hoAuthAws To "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.)
    Set ComRegion Of hoAuthAws To "us-west-2"
    Set ComServiceName Of hoAuthAws To "iotanalytics"
    // SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
    Get pvComObject of hoAuthAws to vAuthAws
    Get ComSetAuthAws Of hoRest vAuthAws To iSuccess

    // URL: https://iotanalytics.us-west-2.amazonaws.com/
    // Use the same region as specified above.
    Get ComConnect Of hoRest "iotanalytics.us-west-2.amazonaws.com" 443 True True To iSuccess
    If (iSuccess <> True) Begin
        Get ComConnectFailReason Of hoRest To iTemp1
        Showln "ConnectFailReason: " iTemp1
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComAddHeader Of hoRest "Content-Type" "application/x-amz-json-1.1" To iSuccess
    Get ComAddHeader Of hoRest "X-Amz-Target" "DescribePipeline" To iSuccess

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComFullRequestNoBodySb Of hoRest "GET" "/pipelines/{pipelineName}" vSbResponseBody To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iRespStatusCode
    Showln "response status code = " iRespStatusCode
    If (iRespStatusCode <> 200) Begin
        Showln "Response Header:"
        Get ComResponseHeader Of hoRest To sTemp1
        Showln sTemp1
        Showln "Response Body:"
        Get ComGetAsString Of hoSbResponseBody To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess

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

    Get ComStringOf Of hoJResp "pipeline.arn" To sArn
    Get ComIntOf Of hoJResp "pipeline.creationTime" To iCreationTime
    Get ComIntOf Of hoJResp "pipeline.lastUpdateTime" To iLastUpdateTime
    Get ComStringOf Of hoJResp "pipeline.name" To sName
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "pipeline.activities" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "pipeline.activities[i].addAttributes.attributes.string" To sV_String
        Get ComStringOf Of hoJResp "pipeline.activities[i].addAttributes.name" To sAddAttributesName
        Get ComStringOf Of hoJResp "pipeline.activities[i].addAttributes.next" To sV_Next
        Get ComStringOf Of hoJResp "pipeline.activities[i].channel.channelName" To sChannelName
        Get ComStringOf Of hoJResp "pipeline.activities[i].channel.name" To sChannelName
        Get ComStringOf Of hoJResp "pipeline.activities[i].channel.next" To sChannelNext
        Get ComStringOf Of hoJResp "pipeline.activities[i].datastore.datastoreName" To sDatastoreName
        Get ComStringOf Of hoJResp "pipeline.activities[i].datastore.name" To sDatastoreName
        Get ComStringOf Of hoJResp "pipeline.activities[i].deviceRegistryEnrich.attribute" To sAttribute
        Get ComStringOf Of hoJResp "pipeline.activities[i].deviceRegistryEnrich.name" To sDeviceRegistryEnrichName
        Get ComStringOf Of hoJResp "pipeline.activities[i].deviceRegistryEnrich.next" To sDeviceRegistryEnrichNext
        Get ComStringOf Of hoJResp "pipeline.activities[i].deviceRegistryEnrich.roleArn" To sRoleArn
        Get ComStringOf Of hoJResp "pipeline.activities[i].deviceRegistryEnrich.thingName" To sThingName
        Get ComStringOf Of hoJResp "pipeline.activities[i].deviceShadowEnrich.attribute" To sDeviceShadowEnrichAttribute
        Get ComStringOf Of hoJResp "pipeline.activities[i].deviceShadowEnrich.name" To sDeviceShadowEnrichName
        Get ComStringOf Of hoJResp "pipeline.activities[i].deviceShadowEnrich.next" To sDeviceShadowEnrichNext
        Get ComStringOf Of hoJResp "pipeline.activities[i].deviceShadowEnrich.roleArn" To sDeviceShadowEnrichRoleArn
        Get ComStringOf Of hoJResp "pipeline.activities[i].deviceShadowEnrich.thingName" To sDeviceShadowEnrichThingName
        Get ComStringOf Of hoJResp "pipeline.activities[i].filter.filter" To sFilter
        Get ComStringOf Of hoJResp "pipeline.activities[i].filter.name" To sFilterName
        Get ComStringOf Of hoJResp "pipeline.activities[i].filter.next" To sFilterNext
        Get ComIntOf Of hoJResp "pipeline.activities[i].lambda.batchSize" To iBatchSize
        Get ComStringOf Of hoJResp "pipeline.activities[i].lambda.lambdaName" To sLambdaName
        Get ComStringOf Of hoJResp "pipeline.activities[i].lambda.name" To sLambdaName
        Get ComStringOf Of hoJResp "pipeline.activities[i].lambda.next" To sLambdaNext
        Get ComStringOf Of hoJResp "pipeline.activities[i].math.attribute" To sMathAttribute
        Get ComStringOf Of hoJResp "pipeline.activities[i].math.math" To sMath
        Get ComStringOf Of hoJResp "pipeline.activities[i].math.name" To sMathName
        Get ComStringOf Of hoJResp "pipeline.activities[i].math.next" To sMathNext
        Get ComStringOf Of hoJResp "pipeline.activities[i].removeAttributes.name" To sRemoveAttributesName
        Get ComStringOf Of hoJResp "pipeline.activities[i].removeAttributes.next" To sRemoveAttributesNext
        Get ComStringOf Of hoJResp "pipeline.activities[i].selectAttributes.name" To sSelectAttributesName
        Get ComStringOf Of hoJResp "pipeline.activities[i].selectAttributes.next" To sSelectAttributesNext
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "pipeline.activities[i].removeAttributes.attributes" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "pipeline.activities[i].removeAttributes.attributes[j]" To sStrVal
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJResp "pipeline.activities[i].selectAttributes.attributes" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "pipeline.activities[i].selectAttributes.attributes[j]" To sStrVal
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "pipeline.reprocessingSummaries" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComIntOf Of hoJResp "pipeline.reprocessingSummaries[i].creationTime" To iCreationTime
        Get ComStringOf Of hoJResp "pipeline.reprocessingSummaries[i].id" To sId
        Get ComStringOf Of hoJResp "pipeline.reprocessingSummaries[i].status" To sStatus
        Move (i + 1) To i
    Loop

    // 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"
    //       }
    //     ]
    //   }
    // }


End_Procedure