Chilkat Online Tools

ListJobs autoit Example

AWS Device Farm

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

$oRest = ObjCreate("Chilkat_9_5_0.Rest")
Local $bSuccess

$oAuthAws = ObjCreate("Chilkat_9_5_0.AuthAws")
$oAuthAws.AccessKey = "AWS_ACCESS_KEY"
$oAuthAws.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.)
$oAuthAws.Region = "us-west-2"
$oAuthAws.ServiceName = "devicefarm"
; SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
$oRest.SetAuthAws($oAuthAws)

; URL: https://devicefarm.us-west-2.amazonaws.com/
; Use the same region as specified above.
$bSuccess = $oRest.Connect("devicefarm.us-west-2.amazonaws.com",443,True,True)
If ($bSuccess <> True) Then
    ConsoleWrite("ConnectFailReason: " & $oRest.ConnectFailReason & @CRLF)
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
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

$oJson = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJson.UpdateString("arn","string")
$oJson.UpdateString("nextToken","string")

; The JSON request body created by the above code:

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

$oRest.AddHeader("Content-Type","application/x-amz-json-1.1")
$oRest.AddHeader("X-Amz-Target","DeviceFarm_20150623.ListJobs")

$oSbRequestBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$oJson.EmitSb($oSbRequestBody)
$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestSb("POST","/",$oSbRequestBody,$oSbResponseBody)
If ($bSuccess <> True) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

Local $iRespStatusCode = $oRest.ResponseStatusCode
ConsoleWrite("response status code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode <> 200) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oRest.ResponseHeader & @CRLF)
    ConsoleWrite("Response Body:" & @CRLF)
    ConsoleWrite($oSbResponseBody.GetAsString() & @CRLF)
    Exit
EndIf

$oJResp = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJResp.LoadSb($oSbResponseBody)

; 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

Local $sArn
Local $iErrored
Local $iFailed
Local $iPassed
Local $iSkipped
Local $iStopped
Local $iTotal
Local $iWarned
Local $iCreated
Local $sArn
Local $sAvailability
Local $sCarrier
Local $sArchitecture
Local $iClock
Local $sFrequency
Local $sFleetName
Local $sFleetType
Local $sFormFactor
Local $iHeapSize
Local $sImage
Local $sManufacturer
Local $iMemory
Local $sModel
Local $sModelId
Local $sName
Local $sOs
Local $sPlatform
Local $sRadio
Local $iRemoteAccessEnabled
Local $iRemoteDebugEnabled
Local $iHeight
Local $iWidth
Local $iMetered
Local $iDeviceMinutesTotal
Local $iUnmetered
Local $sInstanceArn
Local $sMessage
Local $sName
Local $sResult
Local $iStarted
Local $status
Local $iStopped
Local $sV_type
Local $iVideoCapture
Local $sVideoEndpoint
Local $iJ
Local $iCount_j
Local $sDeviceArn
Local $sInstanceProfileArn
Local $sDescription
Local $sInstanceProfileName
Local $iPackageCleanup
Local $iRebootAfterUse
Local $sUdid
Local $iK
Local $iCount_k
Local $strVal

Local $sNextToken = $oJResp.StringOf("nextToken")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("jobs")
While $i < $iCount_i
    $oJResp.I = $i
    $sArn = $oJResp.StringOf("jobs[i].arn")
    $iErrored = $oJResp.IntOf("jobs[i].counters.errored")
    $iFailed = $oJResp.IntOf("jobs[i].counters.failed")
    $iPassed = $oJResp.IntOf("jobs[i].counters.passed")
    $iSkipped = $oJResp.IntOf("jobs[i].counters.skipped")
    $iStopped = $oJResp.IntOf("jobs[i].counters.stopped")
    $iTotal = $oJResp.IntOf("jobs[i].counters.total")
    $iWarned = $oJResp.IntOf("jobs[i].counters.warned")
    $iCreated = $oJResp.IntOf("jobs[i].created")
    $sArn = $oJResp.StringOf("jobs[i].device.arn")
    $sAvailability = $oJResp.StringOf("jobs[i].device.availability")
    $sCarrier = $oJResp.StringOf("jobs[i].device.carrier")
    $sArchitecture = $oJResp.StringOf("jobs[i].device.cpu.architecture")
    $iClock = $oJResp.IntOf("jobs[i].device.cpu.clock")
    $sFrequency = $oJResp.StringOf("jobs[i].device.cpu.frequency")
    $sFleetName = $oJResp.StringOf("jobs[i].device.fleetName")
    $sFleetType = $oJResp.StringOf("jobs[i].device.fleetType")
    $sFormFactor = $oJResp.StringOf("jobs[i].device.formFactor")
    $iHeapSize = $oJResp.IntOf("jobs[i].device.heapSize")
    $sImage = $oJResp.StringOf("jobs[i].device.image")
    $sManufacturer = $oJResp.StringOf("jobs[i].device.manufacturer")
    $iMemory = $oJResp.IntOf("jobs[i].device.memory")
    $sModel = $oJResp.StringOf("jobs[i].device.model")
    $sModelId = $oJResp.StringOf("jobs[i].device.modelId")
    $sName = $oJResp.StringOf("jobs[i].device.name")
    $sOs = $oJResp.StringOf("jobs[i].device.os")
    $sPlatform = $oJResp.StringOf("jobs[i].device.platform")
    $sRadio = $oJResp.StringOf("jobs[i].device.radio")
    $iRemoteAccessEnabled = $oJResp.IntOf("jobs[i].device.remoteAccessEnabled")
    $iRemoteDebugEnabled = $oJResp.IntOf("jobs[i].device.remoteDebugEnabled")
    $iHeight = $oJResp.IntOf("jobs[i].device.resolution.height")
    $iWidth = $oJResp.IntOf("jobs[i].device.resolution.width")
    $iMetered = $oJResp.IntOf("jobs[i].deviceMinutes.metered")
    $iDeviceMinutesTotal = $oJResp.IntOf("jobs[i].deviceMinutes.total")
    $iUnmetered = $oJResp.IntOf("jobs[i].deviceMinutes.unmetered")
    $sInstanceArn = $oJResp.StringOf("jobs[i].instanceArn")
    $sMessage = $oJResp.StringOf("jobs[i].message")
    $sName = $oJResp.StringOf("jobs[i].name")
    $sResult = $oJResp.StringOf("jobs[i].result")
    $iStarted = $oJResp.IntOf("jobs[i].started")
    $status = $oJResp.StringOf("jobs[i].status")
    $iStopped = $oJResp.IntOf("jobs[i].stopped")
    $sV_type = $oJResp.StringOf("jobs[i].type")
    $iVideoCapture = $oJResp.IntOf("jobs[i].videoCapture")
    $sVideoEndpoint = $oJResp.StringOf("jobs[i].videoEndpoint")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("jobs[i].device.instances")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sArn = $oJResp.StringOf("jobs[i].device.instances[j].arn")
        $sDeviceArn = $oJResp.StringOf("jobs[i].device.instances[j].deviceArn")
        $sInstanceProfileArn = $oJResp.StringOf("jobs[i].device.instances[j].instanceProfile.arn")
        $sDescription = $oJResp.StringOf("jobs[i].device.instances[j].instanceProfile.description")
        $sInstanceProfileName = $oJResp.StringOf("jobs[i].device.instances[j].instanceProfile.name")
        $iPackageCleanup = $oJResp.IntOf("jobs[i].device.instances[j].instanceProfile.packageCleanup")
        $iRebootAfterUse = $oJResp.IntOf("jobs[i].device.instances[j].instanceProfile.rebootAfterUse")
        $status = $oJResp.StringOf("jobs[i].device.instances[j].status")
        $sUdid = $oJResp.StringOf("jobs[i].device.instances[j].udid")
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("jobs[i].device.instances[j].instanceProfile.excludeAppPackagesFromCleanup")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $strVal = $oJResp.StringOf("jobs[i].device.instances[j].instanceProfile.excludeAppPackagesFromCleanup[k]")
            $iK = $iK + 1
        Wend
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("jobs[i].device.instances[j].labels")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $strVal = $oJResp.StringOf("jobs[i].device.instances[j].labels[k]")
            $iK = $iK + 1
        Wend
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend

; 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"
; }