ListRuns Foxpro Example
LOCAL loRest
LOCAL lnSuccess
LOCAL loAuthAws
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJResp
LOCAL lcAppUpload
LOCAL lcArn
LOCAL lcBillingMethod
LOCAL lnCompletedJobs
LOCAL lnErrored
LOCAL lnFailed
LOCAL lnPassed
LOCAL lnSkipped
LOCAL lnStopped
LOCAL lnTotal
LOCAL lnWarned
LOCAL lnCreated
LOCAL lnMetered
LOCAL lnDeviceMinutesTotal
LOCAL lnUnmetered
LOCAL lcDevicePoolArn
LOCAL lnMatchedDevicesCount
LOCAL lnMaxDevices
LOCAL lnEventCount
LOCAL lnJobTimeoutMinutes
LOCAL lcLocale
LOCAL lnLatitude
LOCAL lnLongitude
LOCAL lcMessage
LOCAL lcName
LOCAL lcArn
LOCAL lcDescription
LOCAL lnDownlinkBandwidthBits
LOCAL lnDownlinkDelayMs
LOCAL lnDownlinkJitterMs
LOCAL lnDownlinkLossPercent
LOCAL lcName
LOCAL lcV_Type
LOCAL lnUplinkBandwidthBits
LOCAL lnUplinkDelayMs
LOCAL lnUplinkJitterMs
LOCAL lnUplinkLossPercent
LOCAL lcParsingResultUrl
LOCAL lcPlatform
LOCAL lnBluetooth
LOCAL lnGps
LOCAL lnNfc
LOCAL lnWifi
LOCAL lcResult
LOCAL lcResultCode
LOCAL lnSeed
LOCAL lnSkipAppResign
LOCAL lnStarted
LOCAL lcStatus
LOCAL lnStopped
LOCAL lcTestSpecArn
LOCAL lnTotalJobs
LOCAL lcV_type
LOCAL lcWebUrl
LOCAL j
LOCAL lnCount_j
LOCAL lcStrVal
LOCAL lcAttribute
LOCAL lcOperator
LOCAL k
LOCAL lnCount_k
LOCAL lcNextToken
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 = "devicefarm"
* SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loRest.SetAuthAws(loAuthAws)
* URL: https://devicefarm.us-west-2.amazonaws.com/
* Use the same region as specified above.
lnSuccess = loRest.Connect("devicefarm.us-west-2.amazonaws.com",443,1,1)
IF (lnSuccess <> 1) THEN
? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
? loRest.LastErrorText
RELEASE loRest
RELEASE loAuthAws
CANCEL
ENDIF
* 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
loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateString("arn","string")
loJson.UpdateString("nextToken","string")
* The JSON request body created by the above code:
* {
* "arn": "string",
* "nextToken": "string"
* }
loRest.AddHeader("Content-Type","application/x-amz-json-1.1")
loRest.AddHeader("X-Amz-Target","DeviceFarm_20150623.ListRuns")
loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestSb("POST","/",loSbRequestBody,loSbResponseBody)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
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 loJson
RELEASE loSbRequestBody
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
lcNextToken = loJResp.StringOf("nextToken")
i = 0
lnCount_i = loJResp.SizeOfArray("runs")
DO WHILE i < lnCount_i
loJResp.I = i
lcAppUpload = loJResp.StringOf("runs[i].appUpload")
lcArn = loJResp.StringOf("runs[i].arn")
lcBillingMethod = loJResp.StringOf("runs[i].billingMethod")
lnCompletedJobs = loJResp.IntOf("runs[i].completedJobs")
lnErrored = loJResp.IntOf("runs[i].counters.errored")
lnFailed = loJResp.IntOf("runs[i].counters.failed")
lnPassed = loJResp.IntOf("runs[i].counters.passed")
lnSkipped = loJResp.IntOf("runs[i].counters.skipped")
lnStopped = loJResp.IntOf("runs[i].counters.stopped")
lnTotal = loJResp.IntOf("runs[i].counters.total")
lnWarned = loJResp.IntOf("runs[i].counters.warned")
lnCreated = loJResp.IntOf("runs[i].created")
lnMetered = loJResp.IntOf("runs[i].deviceMinutes.metered")
lnDeviceMinutesTotal = loJResp.IntOf("runs[i].deviceMinutes.total")
lnUnmetered = loJResp.IntOf("runs[i].deviceMinutes.unmetered")
lcDevicePoolArn = loJResp.StringOf("runs[i].devicePoolArn")
lnMatchedDevicesCount = loJResp.IntOf("runs[i].deviceSelectionResult.matchedDevicesCount")
lnMaxDevices = loJResp.IntOf("runs[i].deviceSelectionResult.maxDevices")
lnEventCount = loJResp.IntOf("runs[i].eventCount")
lnJobTimeoutMinutes = loJResp.IntOf("runs[i].jobTimeoutMinutes")
lcLocale = loJResp.StringOf("runs[i].locale")
lnLatitude = loJResp.IntOf("runs[i].location.latitude")
lnLongitude = loJResp.IntOf("runs[i].location.longitude")
lcMessage = loJResp.StringOf("runs[i].message")
lcName = loJResp.StringOf("runs[i].name")
lcArn = loJResp.StringOf("runs[i].networkProfile.arn")
lcDescription = loJResp.StringOf("runs[i].networkProfile.description")
lnDownlinkBandwidthBits = loJResp.IntOf("runs[i].networkProfile.downlinkBandwidthBits")
lnDownlinkDelayMs = loJResp.IntOf("runs[i].networkProfile.downlinkDelayMs")
lnDownlinkJitterMs = loJResp.IntOf("runs[i].networkProfile.downlinkJitterMs")
lnDownlinkLossPercent = loJResp.IntOf("runs[i].networkProfile.downlinkLossPercent")
lcName = loJResp.StringOf("runs[i].networkProfile.name")
lcV_Type = loJResp.StringOf("runs[i].networkProfile.type")
lnUplinkBandwidthBits = loJResp.IntOf("runs[i].networkProfile.uplinkBandwidthBits")
lnUplinkDelayMs = loJResp.IntOf("runs[i].networkProfile.uplinkDelayMs")
lnUplinkJitterMs = loJResp.IntOf("runs[i].networkProfile.uplinkJitterMs")
lnUplinkLossPercent = loJResp.IntOf("runs[i].networkProfile.uplinkLossPercent")
lcParsingResultUrl = loJResp.StringOf("runs[i].parsingResultUrl")
lcPlatform = loJResp.StringOf("runs[i].platform")
lnBluetooth = loJResp.IntOf("runs[i].radios.bluetooth")
lnGps = loJResp.IntOf("runs[i].radios.gps")
lnNfc = loJResp.IntOf("runs[i].radios.nfc")
lnWifi = loJResp.IntOf("runs[i].radios.wifi")
lcResult = loJResp.StringOf("runs[i].result")
lcResultCode = loJResp.StringOf("runs[i].resultCode")
lnSeed = loJResp.IntOf("runs[i].seed")
lnSkipAppResign = loJResp.IntOf("runs[i].skipAppResign")
lnStarted = loJResp.IntOf("runs[i].started")
lcStatus = loJResp.StringOf("runs[i].status")
lnStopped = loJResp.IntOf("runs[i].stopped")
lcTestSpecArn = loJResp.StringOf("runs[i].testSpecArn")
lnTotalJobs = loJResp.IntOf("runs[i].totalJobs")
lcV_type = loJResp.StringOf("runs[i].type")
lcWebUrl = loJResp.StringOf("runs[i].webUrl")
j = 0
lnCount_j = loJResp.SizeOfArray("runs[i].customerArtifactPaths.androidPaths")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("runs[i].customerArtifactPaths.androidPaths[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("runs[i].customerArtifactPaths.deviceHostPaths")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("runs[i].customerArtifactPaths.deviceHostPaths[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("runs[i].customerArtifactPaths.iosPaths")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("runs[i].customerArtifactPaths.iosPaths[j]")
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("runs[i].deviceSelectionResult.filters")
DO WHILE j < lnCount_j
loJResp.J = j
lcAttribute = loJResp.StringOf("runs[i].deviceSelectionResult.filters[j].attribute")
lcOperator = loJResp.StringOf("runs[i].deviceSelectionResult.filters[j].operator")
k = 0
lnCount_k = loJResp.SizeOfArray("runs[i].deviceSelectionResult.filters[j].values")
DO WHILE k < lnCount_k
loJResp.K = k
lcStrVal = loJResp.StringOf("runs[i].deviceSelectionResult.filters[j].values[k]")
k = k + 1
ENDDO
j = j + 1
ENDDO
i = i + 1
ENDDO
* 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"
* }
* ]
* }
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp