Chilkat Online Tools

ListUniqueProblems 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.ListUniqueProblems")

$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 $sMessage
Local $iJ
Local $iCount_j
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 $sJobArn
Local $sJobName
Local $sResult
Local $sRunArn
Local $sRunName
Local $suiteArn
Local $suiteName
Local $sTestArn
Local $sTestName
Local $iK
Local $iCount_k
Local $sArn
Local $sDeviceArn
Local $sInstanceProfileArn
Local $sDescription
Local $sInstanceProfileName
Local $iPackageCleanup
Local $iRebootAfterUse
Local $status
Local $sUdid
Local $oJson1
Local $i1
Local $iCount_i1
Local $strVal

Local $sNextToken = $oJResp.StringOf("nextToken")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("uniqueProblems.string")
While $i < $iCount_i
    $oJResp.I = $i
    $sMessage = $oJResp.StringOf("uniqueProblems.string[i].message")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("uniqueProblems.string[i].problems")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sArn = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.arn")
        $sAvailability = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.availability")
        $sCarrier = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.carrier")
        $sArchitecture = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.cpu.architecture")
        $iClock = $oJResp.IntOf("uniqueProblems.string[i].problems[j].device.cpu.clock")
        $sFrequency = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.cpu.frequency")
        $sFleetName = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.fleetName")
        $sFleetType = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.fleetType")
        $sFormFactor = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.formFactor")
        $iHeapSize = $oJResp.IntOf("uniqueProblems.string[i].problems[j].device.heapSize")
        $sImage = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.image")
        $sManufacturer = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.manufacturer")
        $iMemory = $oJResp.IntOf("uniqueProblems.string[i].problems[j].device.memory")
        $sModel = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.model")
        $sModelId = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.modelId")
        $sName = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.name")
        $sOs = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.os")
        $sPlatform = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.platform")
        $sRadio = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.radio")
        $iRemoteAccessEnabled = $oJResp.IntOf("uniqueProblems.string[i].problems[j].device.remoteAccessEnabled")
        $iRemoteDebugEnabled = $oJResp.IntOf("uniqueProblems.string[i].problems[j].device.remoteDebugEnabled")
        $iHeight = $oJResp.IntOf("uniqueProblems.string[i].problems[j].device.resolution.height")
        $iWidth = $oJResp.IntOf("uniqueProblems.string[i].problems[j].device.resolution.width")
        $sJobArn = $oJResp.StringOf("uniqueProblems.string[i].problems[j].job.arn")
        $sJobName = $oJResp.StringOf("uniqueProblems.string[i].problems[j].job.name")
        $sMessage = $oJResp.StringOf("uniqueProblems.string[i].problems[j].message")
        $sResult = $oJResp.StringOf("uniqueProblems.string[i].problems[j].result")
        $sRunArn = $oJResp.StringOf("uniqueProblems.string[i].problems[j].run.arn")
        $sRunName = $oJResp.StringOf("uniqueProblems.string[i].problems[j].run.name")
        $suiteArn = $oJResp.StringOf("uniqueProblems.string[i].problems[j].suite.arn")
        $suiteName = $oJResp.StringOf("uniqueProblems.string[i].problems[j].suite.name")
        $sTestArn = $oJResp.StringOf("uniqueProblems.string[i].problems[j].test.arn")
        $sTestName = $oJResp.StringOf("uniqueProblems.string[i].problems[j].test.name")
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("uniqueProblems.string[i].problems[j].device.instances")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $sArn = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.instances[k].arn")
            $sDeviceArn = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.instances[k].deviceArn")
            $sInstanceProfileArn = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.instances[k].instanceProfile.arn")
            $sDescription = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.instances[k].instanceProfile.description")
            $sInstanceProfileName = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.instances[k].instanceProfile.name")
            $iPackageCleanup = $oJResp.IntOf("uniqueProblems.string[i].problems[j].device.instances[k].instanceProfile.packageCleanup")
            $iRebootAfterUse = $oJResp.IntOf("uniqueProblems.string[i].problems[j].device.instances[k].instanceProfile.rebootAfterUse")
            $status = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.instances[k].status")
            $sUdid = $oJResp.StringOf("uniqueProblems.string[i].problems[j].device.instances[k].udid")

            $oJson1 = $oJResp.ObjectOf("uniqueProblems.string[i].problems[j].device.instances[k]")
            $i1 = 0
            $iCount_i1 = $oJson1.SizeOfArray("instanceProfile.excludeAppPackagesFromCleanup")
            While $i1 < $iCount_i1
                $oJson1.I = $i1
                $strVal = $oJson1.StringOf("instanceProfile.excludeAppPackagesFromCleanup[i]")
                $i1 = $i1 + 1
            Wend

            $oJson1 = $oJResp.ObjectOf("uniqueProblems.string[i].problems[j].device.instances[k]")
            $i1 = 0
            $iCount_i1 = $oJson1.SizeOfArray("labels")
            While $i1 < $iCount_i1
                $oJson1.I = $i1
                $strVal = $oJson1.StringOf("labels[i]")
                $i1 = $i1 + 1
            Wend

            $iK = $iK + 1
        Wend
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend

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

; {
;   "nextToken": "string",
;   "uniqueProblems": {
;     "string": [
;       {
;         "message": "string",
;         "problems": [
;           {
;             "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
;               }
;             },
;             "job": {
;               "arn": "string",
;               "name": "string"
;             },
;             "message": "string",
;             "result": "string",
;             "run": {
;               "arn": "string",
;               "name": "string"
;             },
;             "suite": {
;               "arn": "string",
;               "name": "string"
;             },
;             "test": {
;               "arn": "string",
;               "name": "string"
;             }
;           }
;         ]
;       }
;     ]
;   }
; }