Chilkat Online Tools

ScheduleRun 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 sStrVal
    String sAttribute
    String sOperator
    Integer j
    Integer iCount_j
    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 sNetworkProfileArn
    String sDescription
    Integer iDownlinkBandwidthBits
    Integer iDownlinkDelayMs
    Integer iDownlinkJitterMs
    Integer iDownlinkLossPercent
    String sNetworkProfileName
    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 iRunStopped
    String sTestSpecArn
    Integer iTotalJobs
    String sRunType
    String sWebUrl
    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 "appArn" "string" To iSuccess
    Get ComUpdateString Of hoJson "configuration.auxiliaryApps[0]" "string" To iSuccess
    Get ComUpdateString Of hoJson "configuration.billingMethod" "string" To iSuccess
    Get ComUpdateString Of hoJson "configuration.customerArtifactPaths.androidPaths[0]" "string" To iSuccess
    Get ComUpdateString Of hoJson "configuration.customerArtifactPaths.deviceHostPaths[0]" "string" To iSuccess
    Get ComUpdateString Of hoJson "configuration.customerArtifactPaths.iosPaths[0]" "string" To iSuccess
    Get ComUpdateString Of hoJson "configuration.extraDataPackageArn" "string" To iSuccess
    Get ComUpdateString Of hoJson "configuration.locale" "string" To iSuccess
    Get ComUpdateInt Of hoJson "configuration.location.latitude" 123 To iSuccess
    Get ComUpdateInt Of hoJson "configuration.location.longitude" 123 To iSuccess
    Get ComUpdateString Of hoJson "configuration.networkProfileArn" "string" To iSuccess
    Get ComUpdateInt Of hoJson "configuration.radios.bluetooth" 123 To iSuccess
    Get ComUpdateInt Of hoJson "configuration.radios.gps" 123 To iSuccess
    Get ComUpdateInt Of hoJson "configuration.radios.nfc" 123 To iSuccess
    Get ComUpdateInt Of hoJson "configuration.radios.wifi" 123 To iSuccess
    Get ComUpdateString Of hoJson "configuration.vpceConfigurationArns[0]" "string" To iSuccess
    Get ComUpdateString Of hoJson "devicePoolArn" "string" To iSuccess
    Get ComUpdateString Of hoJson "deviceSelectionConfiguration.filters[0].attribute" "string" To iSuccess
    Get ComUpdateString Of hoJson "deviceSelectionConfiguration.filters[0].operator" "string" To iSuccess
    Get ComUpdateString Of hoJson "deviceSelectionConfiguration.filters[0].values[0]" "string" To iSuccess
    Get ComUpdateInt Of hoJson "deviceSelectionConfiguration.maxDevices" 123 To iSuccess
    Get ComUpdateInt Of hoJson "executionConfiguration.accountsCleanup" 123 To iSuccess
    Get ComUpdateInt Of hoJson "executionConfiguration.appPackagesCleanup" 123 To iSuccess
    Get ComUpdateInt Of hoJson "executionConfiguration.jobTimeoutMinutes" 123 To iSuccess
    Get ComUpdateInt Of hoJson "executionConfiguration.skipAppResign" 123 To iSuccess
    Get ComUpdateInt Of hoJson "executionConfiguration.videoCapture" 123 To iSuccess
    Get ComUpdateString Of hoJson "name" "string" To iSuccess
    Get ComUpdateString Of hoJson "projectArn" "string" To iSuccess
    Get ComUpdateString Of hoJson "test.filter" "string" To iSuccess
    Get ComUpdateString Of hoJson "test.parameters.string" "string" To iSuccess
    Get ComUpdateString Of hoJson "test.testPackageArn" "string" To iSuccess
    Get ComUpdateString Of hoJson "test.testSpecArn" "string" To iSuccess
    Get ComUpdateString Of hoJson "test.type" "string" To iSuccess

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

    // {
    //   "appArn": "string",
    //   "configuration": {
    //     "auxiliaryApps": [
    //       "string"
    //     ],
    //     "billingMethod": "string",
    //     "customerArtifactPaths": {
    //       "androidPaths": [
    //         "string"
    //       ],
    //       "deviceHostPaths": [
    //         "string"
    //       ],
    //       "iosPaths": [
    //         "string"
    //       ]
    //     },
    //     "extraDataPackageArn": "string",
    //     "locale": "string",
    //     "location": {
    //       "latitude": number,
    //       "longitude": number
    //     },
    //     "networkProfileArn": "string",
    //     "radios": {
    //       "bluetooth": boolean,
    //       "gps": boolean,
    //       "nfc": boolean,
    //       "wifi": boolean
    //     },
    //     "vpceConfigurationArns": [
    //       "string"
    //     ]
    //   },
    //   "devicePoolArn": "string",
    //   "deviceSelectionConfiguration": {
    //     "filters": [
    //       {
    //         "attribute": "string",
    //         "operator": "string",
    //         "values": [
    //           "string"
    //         ]
    //       }
    //     ],
    //     "maxDevices": number
    //   },
    //   "executionConfiguration": {
    //     "accountsCleanup": boolean,
    //     "appPackagesCleanup": boolean,
    //     "jobTimeoutMinutes": number,
    //     "skipAppResign": boolean,
    //     "videoCapture": boolean
    //   },
    //   "name": "string",
    //   "projectArn": "string",
    //   "test": {
    //     "filter": "string",
    //     "parameters": {
    //       "string": "string"
    //     },
    //     "testPackageArn": "string",
    //     "testSpecArn": "string",
    //     "type": "string"
    //   }
    // }

    Get ComAddHeader Of hoRest "Content-Type" "application/x-amz-json-1.1" To iSuccess
    Get ComAddHeader Of hoRest "X-Amz-Target" "DeviceFarm_20150623.ScheduleRun" 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 "run.appUpload" To sAppUpload
    Get ComStringOf Of hoJResp "run.arn" To sArn
    Get ComStringOf Of hoJResp "run.billingMethod" To sBillingMethod
    Get ComIntOf Of hoJResp "run.completedJobs" To iCompletedJobs
    Get ComIntOf Of hoJResp "run.counters.errored" To iErrored
    Get ComIntOf Of hoJResp "run.counters.failed" To iFailed
    Get ComIntOf Of hoJResp "run.counters.passed" To iPassed
    Get ComIntOf Of hoJResp "run.counters.skipped" To iSkipped
    Get ComIntOf Of hoJResp "run.counters.stopped" To iStopped
    Get ComIntOf Of hoJResp "run.counters.total" To iTotal
    Get ComIntOf Of hoJResp "run.counters.warned" To iWarned
    Get ComIntOf Of hoJResp "run.created" To iCreated
    Get ComIntOf Of hoJResp "run.deviceMinutes.metered" To iMetered
    Get ComIntOf Of hoJResp "run.deviceMinutes.total" To iDeviceMinutesTotal
    Get ComIntOf Of hoJResp "run.deviceMinutes.unmetered" To iUnmetered
    Get ComStringOf Of hoJResp "run.devicePoolArn" To sDevicePoolArn
    Get ComIntOf Of hoJResp "run.deviceSelectionResult.matchedDevicesCount" To iMatchedDevicesCount
    Get ComIntOf Of hoJResp "run.deviceSelectionResult.maxDevices" To iMaxDevices
    Get ComIntOf Of hoJResp "run.eventCount" To iEventCount
    Get ComIntOf Of hoJResp "run.jobTimeoutMinutes" To iJobTimeoutMinutes
    Get ComStringOf Of hoJResp "run.locale" To sLocale
    Get ComIntOf Of hoJResp "run.location.latitude" To iLatitude
    Get ComIntOf Of hoJResp "run.location.longitude" To iLongitude
    Get ComStringOf Of hoJResp "run.message" To sMessage
    Get ComStringOf Of hoJResp "run.name" To sName
    Get ComStringOf Of hoJResp "run.networkProfile.arn" To sNetworkProfileArn
    Get ComStringOf Of hoJResp "run.networkProfile.description" To sDescription
    Get ComIntOf Of hoJResp "run.networkProfile.downlinkBandwidthBits" To iDownlinkBandwidthBits
    Get ComIntOf Of hoJResp "run.networkProfile.downlinkDelayMs" To iDownlinkDelayMs
    Get ComIntOf Of hoJResp "run.networkProfile.downlinkJitterMs" To iDownlinkJitterMs
    Get ComIntOf Of hoJResp "run.networkProfile.downlinkLossPercent" To iDownlinkLossPercent
    Get ComStringOf Of hoJResp "run.networkProfile.name" To sNetworkProfileName
    Get ComStringOf Of hoJResp "run.networkProfile.type" To sV_Type
    Get ComIntOf Of hoJResp "run.networkProfile.uplinkBandwidthBits" To iUplinkBandwidthBits
    Get ComIntOf Of hoJResp "run.networkProfile.uplinkDelayMs" To iUplinkDelayMs
    Get ComIntOf Of hoJResp "run.networkProfile.uplinkJitterMs" To iUplinkJitterMs
    Get ComIntOf Of hoJResp "run.networkProfile.uplinkLossPercent" To iUplinkLossPercent
    Get ComStringOf Of hoJResp "run.parsingResultUrl" To sParsingResultUrl
    Get ComStringOf Of hoJResp "run.platform" To sPlatform
    Get ComIntOf Of hoJResp "run.radios.bluetooth" To iBluetooth
    Get ComIntOf Of hoJResp "run.radios.gps" To iGps
    Get ComIntOf Of hoJResp "run.radios.nfc" To iNfc
    Get ComIntOf Of hoJResp "run.radios.wifi" To iWifi
    Get ComStringOf Of hoJResp "run.result" To sResult
    Get ComStringOf Of hoJResp "run.resultCode" To sResultCode
    Get ComIntOf Of hoJResp "run.seed" To iSeed
    Get ComIntOf Of hoJResp "run.skipAppResign" To iSkipAppResign
    Get ComIntOf Of hoJResp "run.started" To iStarted
    Get ComStringOf Of hoJResp "run.status" To sStatus
    Get ComIntOf Of hoJResp "run.stopped" To iRunStopped
    Get ComStringOf Of hoJResp "run.testSpecArn" To sTestSpecArn
    Get ComIntOf Of hoJResp "run.totalJobs" To iTotalJobs
    Get ComStringOf Of hoJResp "run.type" To sRunType
    Get ComStringOf Of hoJResp "run.webUrl" To sWebUrl
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "run.customerArtifactPaths.androidPaths" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "run.customerArtifactPaths.androidPaths[i]" To sStrVal
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "run.customerArtifactPaths.deviceHostPaths" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "run.customerArtifactPaths.deviceHostPaths[i]" To sStrVal
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "run.customerArtifactPaths.iosPaths" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "run.customerArtifactPaths.iosPaths[i]" To sStrVal
        Move (i + 1) To i
    Loop

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

        Move (i + 1) To i
    Loop

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

    // {
    //   "run": {
    //     "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