Chilkat Online Tools

StopRun 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")

; The JSON request body created by the above code:

; {
;   "arn": "string"
; }

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

$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 $strVal
Local $sAttribute
Local $sOperator
Local $iJ
Local $iCount_j

Local $sAppUpload = $oJResp.StringOf("run.appUpload")
Local $sArn = $oJResp.StringOf("run.arn")
Local $sBillingMethod = $oJResp.StringOf("run.billingMethod")
Local $iCompletedJobs = $oJResp.IntOf("run.completedJobs")
Local $iErrored = $oJResp.IntOf("run.counters.errored")
Local $iFailed = $oJResp.IntOf("run.counters.failed")
Local $iPassed = $oJResp.IntOf("run.counters.passed")
Local $iSkipped = $oJResp.IntOf("run.counters.skipped")
Local $iStopped = $oJResp.IntOf("run.counters.stopped")
Local $iTotal = $oJResp.IntOf("run.counters.total")
Local $iWarned = $oJResp.IntOf("run.counters.warned")
Local $iCreated = $oJResp.IntOf("run.created")
Local $iMetered = $oJResp.IntOf("run.deviceMinutes.metered")
Local $iDeviceMinutesTotal = $oJResp.IntOf("run.deviceMinutes.total")
Local $iUnmetered = $oJResp.IntOf("run.deviceMinutes.unmetered")
Local $sDevicePoolArn = $oJResp.StringOf("run.devicePoolArn")
Local $iMatchedDevicesCount = $oJResp.IntOf("run.deviceSelectionResult.matchedDevicesCount")
Local $iMaxDevices = $oJResp.IntOf("run.deviceSelectionResult.maxDevices")
Local $iEventCount = $oJResp.IntOf("run.eventCount")
Local $iJobTimeoutMinutes = $oJResp.IntOf("run.jobTimeoutMinutes")
Local $sLocale = $oJResp.StringOf("run.locale")
Local $iLatitude = $oJResp.IntOf("run.location.latitude")
Local $iLongitude = $oJResp.IntOf("run.location.longitude")
Local $sMessage = $oJResp.StringOf("run.message")
Local $sName = $oJResp.StringOf("run.name")
Local $sNetworkProfileArn = $oJResp.StringOf("run.networkProfile.arn")
Local $sDescription = $oJResp.StringOf("run.networkProfile.description")
Local $iDownlinkBandwidthBits = $oJResp.IntOf("run.networkProfile.downlinkBandwidthBits")
Local $iDownlinkDelayMs = $oJResp.IntOf("run.networkProfile.downlinkDelayMs")
Local $iDownlinkJitterMs = $oJResp.IntOf("run.networkProfile.downlinkJitterMs")
Local $iDownlinkLossPercent = $oJResp.IntOf("run.networkProfile.downlinkLossPercent")
Local $sNetworkProfileName = $oJResp.StringOf("run.networkProfile.name")
Local $sV_Type = $oJResp.StringOf("run.networkProfile.type")
Local $iUplinkBandwidthBits = $oJResp.IntOf("run.networkProfile.uplinkBandwidthBits")
Local $iUplinkDelayMs = $oJResp.IntOf("run.networkProfile.uplinkDelayMs")
Local $iUplinkJitterMs = $oJResp.IntOf("run.networkProfile.uplinkJitterMs")
Local $iUplinkLossPercent = $oJResp.IntOf("run.networkProfile.uplinkLossPercent")
Local $sParsingResultUrl = $oJResp.StringOf("run.parsingResultUrl")
Local $sPlatform = $oJResp.StringOf("run.platform")
Local $iBluetooth = $oJResp.IntOf("run.radios.bluetooth")
Local $iGps = $oJResp.IntOf("run.radios.gps")
Local $iNfc = $oJResp.IntOf("run.radios.nfc")
Local $iWifi = $oJResp.IntOf("run.radios.wifi")
Local $sResult = $oJResp.StringOf("run.result")
Local $sResultCode = $oJResp.StringOf("run.resultCode")
Local $iSeed = $oJResp.IntOf("run.seed")
Local $iSkipAppResign = $oJResp.IntOf("run.skipAppResign")
Local $iStarted = $oJResp.IntOf("run.started")
Local $sStatus = $oJResp.StringOf("run.status")
Local $iRunStopped = $oJResp.IntOf("run.stopped")
Local $sTestSpecArn = $oJResp.StringOf("run.testSpecArn")
Local $iTotalJobs = $oJResp.IntOf("run.totalJobs")
Local $sRunType = $oJResp.StringOf("run.type")
Local $sWebUrl = $oJResp.StringOf("run.webUrl")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("run.customerArtifactPaths.androidPaths")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("run.customerArtifactPaths.androidPaths[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("run.customerArtifactPaths.deviceHostPaths")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("run.customerArtifactPaths.deviceHostPaths[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("run.customerArtifactPaths.iosPaths")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("run.customerArtifactPaths.iosPaths[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("run.deviceSelectionResult.filters")
While $i < $iCount_i
    $oJResp.I = $i
    $sAttribute = $oJResp.StringOf("run.deviceSelectionResult.filters[i].attribute")
    $sOperator = $oJResp.StringOf("run.deviceSelectionResult.filters[i].operator")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("run.deviceSelectionResult.filters[i].values")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("run.deviceSelectionResult.filters[i].values[j]")
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend

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

; {
;   "run": {
;     "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"
;   }
; }