Chilkat Online Tools

ListRuns DataFlex Example

AWS Device Farm

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
    Variant vAuthAws
    Handle hoAuthAws
    Handle hoJson
    Variant vSbRequestBody
    Handle hoSbRequestBody
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Integer iRespStatusCode
    Handle hoJResp
    String sAppUpload
    String sArn
    String sBillingMethod
    Integer iCompletedJobs
    Integer iErrored
    Integer iFailed
    Integer iPassed
    Integer iSkipped
    Integer iStopped
    Integer iTotal
    Integer iWarned
    Integer iCreated
    Integer iMetered
    Integer iDeviceMinutesTotal
    Integer iUnmetered
    String sDevicePoolArn
    Integer iMatchedDevicesCount
    Integer iMaxDevices
    Integer iEventCount
    Integer iJobTimeoutMinutes
    String sLocale
    Integer iLatitude
    Integer iLongitude
    String sMessage
    String sName
    String sArn
    String sDescription
    Integer iDownlinkBandwidthBits
    Integer iDownlinkDelayMs
    Integer iDownlinkJitterMs
    Integer iDownlinkLossPercent
    String sName
    String sV_Type
    Integer iUplinkBandwidthBits
    Integer iUplinkDelayMs
    Integer iUplinkJitterMs
    Integer iUplinkLossPercent
    String sParsingResultUrl
    String sPlatform
    Integer iBluetooth
    Integer iGps
    Integer iNfc
    Integer iWifi
    String sResult
    String sResultCode
    Integer iSeed
    Integer iSkipAppResign
    Integer iStarted
    String sStatus
    Integer iStopped
    String sTestSpecArn
    Integer iTotalJobs
    String sV_type
    String sWebUrl
    Integer j
    Integer iCount_j
    String sStrVal
    String sAttribute
    String sOperator
    Integer k
    Integer iCount_k
    String sNextToken
    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 "devicefarm"
    // 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://devicefarm.us-west-2.amazonaws.com/
    // Use the same region as specified above.
    Get ComConnect Of hoRest "devicefarm.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

    // The following code creates the JSON request body.
    // The JSON created by this code is shown below.

    // Use this online tool to generate code from sample JSON:
    // Generate Code to Create JSON

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "arn" "string" To iSuccess
    Get ComUpdateString Of hoJson "nextToken" "string" To iSuccess

    // The JSON request body created by the above code:

    // {
    //   "arn": "string",
    //   "nextToken": "string"
    // }

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

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbRequestBody
    If (Not(IsComObjectCreated(hoSbRequestBody))) Begin
        Send CreateComObject of hoSbRequestBody
    End
    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get ComEmitSb Of hoJson vSbRequestBody To iSuccess
    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComFullRequestSb Of hoRest "POST" "/" vSbRequestBody 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 "nextToken" To sNextToken
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "runs" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "runs[i].appUpload" To sAppUpload
        Get ComStringOf Of hoJResp "runs[i].arn" To sArn
        Get ComStringOf Of hoJResp "runs[i].billingMethod" To sBillingMethod
        Get ComIntOf Of hoJResp "runs[i].completedJobs" To iCompletedJobs
        Get ComIntOf Of hoJResp "runs[i].counters.errored" To iErrored
        Get ComIntOf Of hoJResp "runs[i].counters.failed" To iFailed
        Get ComIntOf Of hoJResp "runs[i].counters.passed" To iPassed
        Get ComIntOf Of hoJResp "runs[i].counters.skipped" To iSkipped
        Get ComIntOf Of hoJResp "runs[i].counters.stopped" To iStopped
        Get ComIntOf Of hoJResp "runs[i].counters.total" To iTotal
        Get ComIntOf Of hoJResp "runs[i].counters.warned" To iWarned
        Get ComIntOf Of hoJResp "runs[i].created" To iCreated
        Get ComIntOf Of hoJResp "runs[i].deviceMinutes.metered" To iMetered
        Get ComIntOf Of hoJResp "runs[i].deviceMinutes.total" To iDeviceMinutesTotal
        Get ComIntOf Of hoJResp "runs[i].deviceMinutes.unmetered" To iUnmetered
        Get ComStringOf Of hoJResp "runs[i].devicePoolArn" To sDevicePoolArn
        Get ComIntOf Of hoJResp "runs[i].deviceSelectionResult.matchedDevicesCount" To iMatchedDevicesCount
        Get ComIntOf Of hoJResp "runs[i].deviceSelectionResult.maxDevices" To iMaxDevices
        Get ComIntOf Of hoJResp "runs[i].eventCount" To iEventCount
        Get ComIntOf Of hoJResp "runs[i].jobTimeoutMinutes" To iJobTimeoutMinutes
        Get ComStringOf Of hoJResp "runs[i].locale" To sLocale
        Get ComIntOf Of hoJResp "runs[i].location.latitude" To iLatitude
        Get ComIntOf Of hoJResp "runs[i].location.longitude" To iLongitude
        Get ComStringOf Of hoJResp "runs[i].message" To sMessage
        Get ComStringOf Of hoJResp "runs[i].name" To sName
        Get ComStringOf Of hoJResp "runs[i].networkProfile.arn" To sArn
        Get ComStringOf Of hoJResp "runs[i].networkProfile.description" To sDescription
        Get ComIntOf Of hoJResp "runs[i].networkProfile.downlinkBandwidthBits" To iDownlinkBandwidthBits
        Get ComIntOf Of hoJResp "runs[i].networkProfile.downlinkDelayMs" To iDownlinkDelayMs
        Get ComIntOf Of hoJResp "runs[i].networkProfile.downlinkJitterMs" To iDownlinkJitterMs
        Get ComIntOf Of hoJResp "runs[i].networkProfile.downlinkLossPercent" To iDownlinkLossPercent
        Get ComStringOf Of hoJResp "runs[i].networkProfile.name" To sName
        Get ComStringOf Of hoJResp "runs[i].networkProfile.type" To sV_Type
        Get ComIntOf Of hoJResp "runs[i].networkProfile.uplinkBandwidthBits" To iUplinkBandwidthBits
        Get ComIntOf Of hoJResp "runs[i].networkProfile.uplinkDelayMs" To iUplinkDelayMs
        Get ComIntOf Of hoJResp "runs[i].networkProfile.uplinkJitterMs" To iUplinkJitterMs
        Get ComIntOf Of hoJResp "runs[i].networkProfile.uplinkLossPercent" To iUplinkLossPercent
        Get ComStringOf Of hoJResp "runs[i].parsingResultUrl" To sParsingResultUrl
        Get ComStringOf Of hoJResp "runs[i].platform" To sPlatform
        Get ComIntOf Of hoJResp "runs[i].radios.bluetooth" To iBluetooth
        Get ComIntOf Of hoJResp "runs[i].radios.gps" To iGps
        Get ComIntOf Of hoJResp "runs[i].radios.nfc" To iNfc
        Get ComIntOf Of hoJResp "runs[i].radios.wifi" To iWifi
        Get ComStringOf Of hoJResp "runs[i].result" To sResult
        Get ComStringOf Of hoJResp "runs[i].resultCode" To sResultCode
        Get ComIntOf Of hoJResp "runs[i].seed" To iSeed
        Get ComIntOf Of hoJResp "runs[i].skipAppResign" To iSkipAppResign
        Get ComIntOf Of hoJResp "runs[i].started" To iStarted
        Get ComStringOf Of hoJResp "runs[i].status" To sStatus
        Get ComIntOf Of hoJResp "runs[i].stopped" To iStopped
        Get ComStringOf Of hoJResp "runs[i].testSpecArn" To sTestSpecArn
        Get ComIntOf Of hoJResp "runs[i].totalJobs" To iTotalJobs
        Get ComStringOf Of hoJResp "runs[i].type" To sV_type
        Get ComStringOf Of hoJResp "runs[i].webUrl" To sWebUrl
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "runs[i].customerArtifactPaths.androidPaths" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "runs[i].customerArtifactPaths.androidPaths[j]" To sStrVal
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJResp "runs[i].customerArtifactPaths.deviceHostPaths" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "runs[i].customerArtifactPaths.deviceHostPaths[j]" To sStrVal
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJResp "runs[i].customerArtifactPaths.iosPaths" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "runs[i].customerArtifactPaths.iosPaths[j]" To sStrVal
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJResp "runs[i].deviceSelectionResult.filters" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "runs[i].deviceSelectionResult.filters[j].attribute" To sAttribute
            Get ComStringOf Of hoJResp "runs[i].deviceSelectionResult.filters[j].operator" To sOperator
            Move 0 To k
            Get ComSizeOfArray Of hoJResp "runs[i].deviceSelectionResult.filters[j].values" To iCount_k
            While (k < iCount_k)
                Set ComK Of hoJResp To k
                Get ComStringOf Of hoJResp "runs[i].deviceSelectionResult.filters[j].values[k]" To sStrVal
                Move (k + 1) To k
            Loop

            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop

    // A sample JSON response body parsed by the above code:

    // {
    //   "nextToken": "string",
    //   "runs": [
    //     {
    //       "appUpload": "string",
    //       "arn": "string",
    //       "billingMethod": "string",
    //       "completedJobs": number,
    //       "counters": {
    //         "errored": number,
    //         "failed": number,
    //         "passed": number,
    //         "skipped": number,
    //         "stopped": number,
    //         "total": number,
    //         "warned": number
    //       },
    //       "created": number,
    //       "customerArtifactPaths": {
    //         "androidPaths": [
    //           "string"
    //         ],
    //         "deviceHostPaths": [
    //           "string"
    //         ],
    //         "iosPaths": [
    //           "string"
    //         ]
    //       },
    //       "deviceMinutes": {
    //         "metered": number,
    //         "total": number,
    //         "unmetered": number
    //       },
    //       "devicePoolArn": "string",
    //       "deviceSelectionResult": {
    //         "filters": [
    //           {
    //             "attribute": "string",
    //             "operator": "string",
    //             "values": [
    //               "string"
    //             ]
    //           }
    //         ],
    //         "matchedDevicesCount": number,
    //         "maxDevices": number
    //       },
    //       "eventCount": number,
    //       "jobTimeoutMinutes": number,
    //       "locale": "string",
    //       "location": {
    //         "latitude": number,
    //         "longitude": number
    //       },
    //       "message": "string",
    //       "name": "string",
    //       "networkProfile": {
    //         "arn": "string",
    //         "description": "string",
    //         "downlinkBandwidthBits": number,
    //         "downlinkDelayMs": number,
    //         "downlinkJitterMs": number,
    //         "downlinkLossPercent": number,
    //         "name": "string",
    //         "type": "string",
    //         "uplinkBandwidthBits": number,
    //         "uplinkDelayMs": number,
    //         "uplinkJitterMs": number,
    //         "uplinkLossPercent": number
    //       },
    //       "parsingResultUrl": "string",
    //       "platform": "string",
    //       "radios": {
    //         "bluetooth": boolean,
    //         "gps": boolean,
    //         "nfc": boolean,
    //         "wifi": boolean
    //       },
    //       "result": "string",
    //       "resultCode": "string",
    //       "seed": number,
    //       "skipAppResign": boolean,
    //       "started": number,
    //       "status": "string",
    //       "stopped": number,
    //       "testSpecArn": "string",
    //       "totalJobs": number,
    //       "type": "string",
    //       "webUrl": "string"
    //     }
    //   ]
    // }


End_Procedure