ListJobs Foxpro Example
LOCAL loRest
LOCAL lnSuccess
LOCAL loAuthAws
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJResp
LOCAL lcArn
LOCAL lnErrored
LOCAL lnFailed
LOCAL lnPassed
LOCAL lnSkipped
LOCAL lnStopped
LOCAL lnTotal
LOCAL lnWarned
LOCAL lnCreated
LOCAL lcArn
LOCAL lcAvailability
LOCAL lcCarrier
LOCAL lcArchitecture
LOCAL lnClock
LOCAL lcFrequency
LOCAL lcFleetName
LOCAL lcFleetType
LOCAL lcFormFactor
LOCAL lnHeapSize
LOCAL lcImage
LOCAL lcManufacturer
LOCAL lnMemory
LOCAL lcModel
LOCAL lcModelId
LOCAL lcName
LOCAL lcOs
LOCAL lcPlatform
LOCAL lcRadio
LOCAL lnRemoteAccessEnabled
LOCAL lnRemoteDebugEnabled
LOCAL lnHeight
LOCAL lnWidth
LOCAL lnMetered
LOCAL lnDeviceMinutesTotal
LOCAL lnUnmetered
LOCAL lcInstanceArn
LOCAL lcMessage
LOCAL lcName
LOCAL lcResult
LOCAL lnStarted
LOCAL lcStatus
LOCAL lnStopped
LOCAL lcV_type
LOCAL lnVideoCapture
LOCAL lcVideoEndpoint
LOCAL j
LOCAL lnCount_j
LOCAL lcDeviceArn
LOCAL lcInstanceProfileArn
LOCAL lcDescription
LOCAL lcInstanceProfileName
LOCAL lnPackageCleanup
LOCAL lnRebootAfterUse
LOCAL lcUdid
LOCAL k
LOCAL lnCount_k
LOCAL lcStrVal
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.ListJobs")
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("jobs")
DO WHILE i < lnCount_i
loJResp.I = i
lcArn = loJResp.StringOf("jobs[i].arn")
lnErrored = loJResp.IntOf("jobs[i].counters.errored")
lnFailed = loJResp.IntOf("jobs[i].counters.failed")
lnPassed = loJResp.IntOf("jobs[i].counters.passed")
lnSkipped = loJResp.IntOf("jobs[i].counters.skipped")
lnStopped = loJResp.IntOf("jobs[i].counters.stopped")
lnTotal = loJResp.IntOf("jobs[i].counters.total")
lnWarned = loJResp.IntOf("jobs[i].counters.warned")
lnCreated = loJResp.IntOf("jobs[i].created")
lcArn = loJResp.StringOf("jobs[i].device.arn")
lcAvailability = loJResp.StringOf("jobs[i].device.availability")
lcCarrier = loJResp.StringOf("jobs[i].device.carrier")
lcArchitecture = loJResp.StringOf("jobs[i].device.cpu.architecture")
lnClock = loJResp.IntOf("jobs[i].device.cpu.clock")
lcFrequency = loJResp.StringOf("jobs[i].device.cpu.frequency")
lcFleetName = loJResp.StringOf("jobs[i].device.fleetName")
lcFleetType = loJResp.StringOf("jobs[i].device.fleetType")
lcFormFactor = loJResp.StringOf("jobs[i].device.formFactor")
lnHeapSize = loJResp.IntOf("jobs[i].device.heapSize")
lcImage = loJResp.StringOf("jobs[i].device.image")
lcManufacturer = loJResp.StringOf("jobs[i].device.manufacturer")
lnMemory = loJResp.IntOf("jobs[i].device.memory")
lcModel = loJResp.StringOf("jobs[i].device.model")
lcModelId = loJResp.StringOf("jobs[i].device.modelId")
lcName = loJResp.StringOf("jobs[i].device.name")
lcOs = loJResp.StringOf("jobs[i].device.os")
lcPlatform = loJResp.StringOf("jobs[i].device.platform")
lcRadio = loJResp.StringOf("jobs[i].device.radio")
lnRemoteAccessEnabled = loJResp.IntOf("jobs[i].device.remoteAccessEnabled")
lnRemoteDebugEnabled = loJResp.IntOf("jobs[i].device.remoteDebugEnabled")
lnHeight = loJResp.IntOf("jobs[i].device.resolution.height")
lnWidth = loJResp.IntOf("jobs[i].device.resolution.width")
lnMetered = loJResp.IntOf("jobs[i].deviceMinutes.metered")
lnDeviceMinutesTotal = loJResp.IntOf("jobs[i].deviceMinutes.total")
lnUnmetered = loJResp.IntOf("jobs[i].deviceMinutes.unmetered")
lcInstanceArn = loJResp.StringOf("jobs[i].instanceArn")
lcMessage = loJResp.StringOf("jobs[i].message")
lcName = loJResp.StringOf("jobs[i].name")
lcResult = loJResp.StringOf("jobs[i].result")
lnStarted = loJResp.IntOf("jobs[i].started")
lcStatus = loJResp.StringOf("jobs[i].status")
lnStopped = loJResp.IntOf("jobs[i].stopped")
lcV_type = loJResp.StringOf("jobs[i].type")
lnVideoCapture = loJResp.IntOf("jobs[i].videoCapture")
lcVideoEndpoint = loJResp.StringOf("jobs[i].videoEndpoint")
j = 0
lnCount_j = loJResp.SizeOfArray("jobs[i].device.instances")
DO WHILE j < lnCount_j
loJResp.J = j
lcArn = loJResp.StringOf("jobs[i].device.instances[j].arn")
lcDeviceArn = loJResp.StringOf("jobs[i].device.instances[j].deviceArn")
lcInstanceProfileArn = loJResp.StringOf("jobs[i].device.instances[j].instanceProfile.arn")
lcDescription = loJResp.StringOf("jobs[i].device.instances[j].instanceProfile.description")
lcInstanceProfileName = loJResp.StringOf("jobs[i].device.instances[j].instanceProfile.name")
lnPackageCleanup = loJResp.IntOf("jobs[i].device.instances[j].instanceProfile.packageCleanup")
lnRebootAfterUse = loJResp.IntOf("jobs[i].device.instances[j].instanceProfile.rebootAfterUse")
lcStatus = loJResp.StringOf("jobs[i].device.instances[j].status")
lcUdid = loJResp.StringOf("jobs[i].device.instances[j].udid")
k = 0
lnCount_k = loJResp.SizeOfArray("jobs[i].device.instances[j].instanceProfile.excludeAppPackagesFromCleanup")
DO WHILE k < lnCount_k
loJResp.K = k
lcStrVal = loJResp.StringOf("jobs[i].device.instances[j].instanceProfile.excludeAppPackagesFromCleanup[k]")
k = k + 1
ENDDO
k = 0
lnCount_k = loJResp.SizeOfArray("jobs[i].device.instances[j].labels")
DO WHILE k < lnCount_k
loJResp.K = k
lcStrVal = loJResp.StringOf("jobs[i].device.instances[j].labels[k]")
k = k + 1
ENDDO
j = j + 1
ENDDO
i = i + 1
ENDDO
* A sample JSON response body parsed by the above code:
* {
* "jobs": [
* {
* "arn": "string",
* "counters": {
* "errored": number,
* "failed": number,
* "passed": number,
* "skipped": number,
* "stopped": number,
* "total": number,
* "warned": number
* },
* "created": number,
* "device": {
* "arn": "string",
* "availability": "string",
* "carrier": "string",
* "cpu": {
* "architecture": "string",
* "clock": number,
* "frequency": "string"
* },
* "fleetName": "string",
* "fleetType": "string",
* "formFactor": "string",
* "heapSize": number,
* "image": "string",
* "instances": [
* {
* "arn": "string",
* "deviceArn": "string",
* "instanceProfile": {
* "arn": "string",
* "description": "string",
* "excludeAppPackagesFromCleanup": [
* "string"
* ],
* "name": "string",
* "packageCleanup": boolean,
* "rebootAfterUse": boolean
* },
* "labels": [
* "string"
* ],
* "status": "string",
* "udid": "string"
* }
* ],
* "manufacturer": "string",
* "memory": number,
* "model": "string",
* "modelId": "string",
* "name": "string",
* "os": "string",
* "platform": "string",
* "radio": "string",
* "remoteAccessEnabled": boolean,
* "remoteDebugEnabled": boolean,
* "resolution": {
* "height": number,
* "width": number
* }
* },
* "deviceMinutes": {
* "metered": number,
* "total": number,
* "unmetered": number
* },
* "instanceArn": "string",
* "message": "string",
* "name": "string",
* "result": "string",
* "started": number,
* "status": "string",
* "stopped": number,
* "type": "string",
* "videoCapture": boolean,
* "videoEndpoint": "string"
* }
* ],
* "nextToken": "string"
* }
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp