Chilkat Online Tools

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

$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 $sBillingMethod
Local $sClientId
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 $iTotal
Local $iUnmetered
Local $sDeviceUdid
Local $sEndpoint
Local $sHostAddress
Local $sInstanceArn
Local $sInteractionMode
Local $sMessage
Local $sName
Local $iRemoteDebugEnabled
Local $sRemoteRecordAppArn
Local $iRemoteRecordEnabled
Local $sResult
Local $iSkipAppResign
Local $iStarted
Local $status
Local $iStopped
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("remoteAccessSessions")
While $i < $iCount_i
    $oJResp.I = $i
    $sArn = $oJResp.StringOf("remoteAccessSessions[i].arn")
    $sBillingMethod = $oJResp.StringOf("remoteAccessSessions[i].billingMethod")
    $sClientId = $oJResp.StringOf("remoteAccessSessions[i].clientId")
    $iCreated = $oJResp.IntOf("remoteAccessSessions[i].created")
    $sArn = $oJResp.StringOf("remoteAccessSessions[i].device.arn")
    $sAvailability = $oJResp.StringOf("remoteAccessSessions[i].device.availability")
    $sCarrier = $oJResp.StringOf("remoteAccessSessions[i].device.carrier")
    $sArchitecture = $oJResp.StringOf("remoteAccessSessions[i].device.cpu.architecture")
    $iClock = $oJResp.IntOf("remoteAccessSessions[i].device.cpu.clock")
    $sFrequency = $oJResp.StringOf("remoteAccessSessions[i].device.cpu.frequency")
    $sFleetName = $oJResp.StringOf("remoteAccessSessions[i].device.fleetName")
    $sFleetType = $oJResp.StringOf("remoteAccessSessions[i].device.fleetType")
    $sFormFactor = $oJResp.StringOf("remoteAccessSessions[i].device.formFactor")
    $iHeapSize = $oJResp.IntOf("remoteAccessSessions[i].device.heapSize")
    $sImage = $oJResp.StringOf("remoteAccessSessions[i].device.image")
    $sManufacturer = $oJResp.StringOf("remoteAccessSessions[i].device.manufacturer")
    $iMemory = $oJResp.IntOf("remoteAccessSessions[i].device.memory")
    $sModel = $oJResp.StringOf("remoteAccessSessions[i].device.model")
    $sModelId = $oJResp.StringOf("remoteAccessSessions[i].device.modelId")
    $sName = $oJResp.StringOf("remoteAccessSessions[i].device.name")
    $sOs = $oJResp.StringOf("remoteAccessSessions[i].device.os")
    $sPlatform = $oJResp.StringOf("remoteAccessSessions[i].device.platform")
    $sRadio = $oJResp.StringOf("remoteAccessSessions[i].device.radio")
    $iRemoteAccessEnabled = $oJResp.IntOf("remoteAccessSessions[i].device.remoteAccessEnabled")
    $iRemoteDebugEnabled = $oJResp.IntOf("remoteAccessSessions[i].device.remoteDebugEnabled")
    $iHeight = $oJResp.IntOf("remoteAccessSessions[i].device.resolution.height")
    $iWidth = $oJResp.IntOf("remoteAccessSessions[i].device.resolution.width")
    $iMetered = $oJResp.IntOf("remoteAccessSessions[i].deviceMinutes.metered")
    $iTotal = $oJResp.IntOf("remoteAccessSessions[i].deviceMinutes.total")
    $iUnmetered = $oJResp.IntOf("remoteAccessSessions[i].deviceMinutes.unmetered")
    $sDeviceUdid = $oJResp.StringOf("remoteAccessSessions[i].deviceUdid")
    $sEndpoint = $oJResp.StringOf("remoteAccessSessions[i].endpoint")
    $sHostAddress = $oJResp.StringOf("remoteAccessSessions[i].hostAddress")
    $sInstanceArn = $oJResp.StringOf("remoteAccessSessions[i].instanceArn")
    $sInteractionMode = $oJResp.StringOf("remoteAccessSessions[i].interactionMode")
    $sMessage = $oJResp.StringOf("remoteAccessSessions[i].message")
    $sName = $oJResp.StringOf("remoteAccessSessions[i].name")
    $iRemoteDebugEnabled = $oJResp.IntOf("remoteAccessSessions[i].remoteDebugEnabled")
    $sRemoteRecordAppArn = $oJResp.StringOf("remoteAccessSessions[i].remoteRecordAppArn")
    $iRemoteRecordEnabled = $oJResp.IntOf("remoteAccessSessions[i].remoteRecordEnabled")
    $sResult = $oJResp.StringOf("remoteAccessSessions[i].result")
    $iSkipAppResign = $oJResp.IntOf("remoteAccessSessions[i].skipAppResign")
    $iStarted = $oJResp.IntOf("remoteAccessSessions[i].started")
    $status = $oJResp.StringOf("remoteAccessSessions[i].status")
    $iStopped = $oJResp.IntOf("remoteAccessSessions[i].stopped")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("remoteAccessSessions[i].device.instances")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sArn = $oJResp.StringOf("remoteAccessSessions[i].device.instances[j].arn")
        $sDeviceArn = $oJResp.StringOf("remoteAccessSessions[i].device.instances[j].deviceArn")
        $sInstanceProfileArn = $oJResp.StringOf("remoteAccessSessions[i].device.instances[j].instanceProfile.arn")
        $sDescription = $oJResp.StringOf("remoteAccessSessions[i].device.instances[j].instanceProfile.description")
        $sInstanceProfileName = $oJResp.StringOf("remoteAccessSessions[i].device.instances[j].instanceProfile.name")
        $iPackageCleanup = $oJResp.IntOf("remoteAccessSessions[i].device.instances[j].instanceProfile.packageCleanup")
        $iRebootAfterUse = $oJResp.IntOf("remoteAccessSessions[i].device.instances[j].instanceProfile.rebootAfterUse")
        $status = $oJResp.StringOf("remoteAccessSessions[i].device.instances[j].status")
        $sUdid = $oJResp.StringOf("remoteAccessSessions[i].device.instances[j].udid")
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("remoteAccessSessions[i].device.instances[j].instanceProfile.excludeAppPackagesFromCleanup")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $strVal = $oJResp.StringOf("remoteAccessSessions[i].device.instances[j].instanceProfile.excludeAppPackagesFromCleanup[k]")
            $iK = $iK + 1
        Wend
        $iK = 0
        $iCount_k = $oJResp.SizeOfArray("remoteAccessSessions[i].device.instances[j].labels")
        While $iK < $iCount_k
            $oJResp.K = $iK
            $strVal = $oJResp.StringOf("remoteAccessSessions[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:

; {
;   "nextToken": "string",
;   "remoteAccessSessions": [
;     {
;       "arn": "string",
;       "billingMethod": "string",
;       "clientId": "string",
;       "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
;       },
;       "deviceUdid": "string",
;       "endpoint": "string",
;       "hostAddress": "string",
;       "instanceArn": "string",
;       "interactionMode": "string",
;       "message": "string",
;       "name": "string",
;       "remoteDebugEnabled": boolean,
;       "remoteRecordAppArn": "string",
;       "remoteRecordEnabled": boolean,
;       "result": "string",
;       "skipAppResign": boolean,
;       "started": number,
;       "status": "string",
;       "stopped": number
;     }
;   ]
; }