Chilkat Online Tools

ListRuns PowerBuilder Example

AWS Device Farm

integer li_rc
oleobject loo_Rest
integer li_Success
oleobject loo_AuthAws
oleobject loo_Json
oleobject loo_SbRequestBody
oleobject loo_SbResponseBody
integer li_RespStatusCode
oleobject loo_JResp
string ls_AppUpload
string ls_Arn
string ls_BillingMethod
integer li_CompletedJobs
integer li_Errored
integer li_Failed
integer li_Passed
integer li_Skipped
integer li_Stopped
integer li_Total
integer li_Warned
integer li_Created
integer li_Metered
integer li_DeviceMinutesTotal
integer li_Unmetered
string ls_DevicePoolArn
integer li_MatchedDevicesCount
integer li_MaxDevices
integer li_EventCount
integer li_JobTimeoutMinutes
string ls_Locale
integer li_Latitude
integer li_Longitude
string ls_Message
string ls_Name
string ls_Arn
string ls_Description
integer li_DownlinkBandwidthBits
integer li_DownlinkDelayMs
integer li_DownlinkJitterMs
integer li_DownlinkLossPercent
string ls_Name
string ls_V_Type
integer li_UplinkBandwidthBits
integer li_UplinkDelayMs
integer li_UplinkJitterMs
integer li_UplinkLossPercent
string ls_ParsingResultUrl
string ls_Platform
integer li_Bluetooth
integer li_Gps
integer li_Nfc
integer li_Wifi
string ls_Result
string ls_ResultCode
integer li_Seed
integer li_SkipAppResign
integer li_Started
string ls_Status
integer li_Stopped
string ls_TestSpecArn
integer li_TotalJobs
string ls_V_type
string ls_WebUrl
integer j
integer li_Count_j
string ls_StrVal
string ls_Attribute
string ls_Operator
integer k
integer li_Count_k
string ls_NextToken
integer i
integer li_Count_i

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

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")
if li_rc < 0 then
    destroy loo_Rest
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_AuthAws = create oleobject
li_rc = loo_AuthAws.ConnectToNewObject("Chilkat_9_5_0.AuthAws")

loo_AuthAws.AccessKey = "AWS_ACCESS_KEY"
loo_AuthAws.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.)
loo_AuthAws.Region = "us-west-2"
loo_AuthAws.ServiceName = "devicefarm"
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loo_Rest.SetAuthAws(loo_AuthAws)

// URL: https://devicefarm.us-west-2.amazonaws.com/
// Use the same region as specified above.
li_Success = loo_Rest.Connect("devicefarm.us-west-2.amazonaws.com",443,1,1)
if li_Success <> 1 then
    Write-Debug "ConnectFailReason: " + string(loo_Rest.ConnectFailReason)
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_AuthAws
    return
end if

// 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

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_Json.UpdateString("arn","string")
loo_Json.UpdateString("nextToken","string")

// The JSON request body created by the above code:

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

loo_Rest.AddHeader("Content-Type","application/x-amz-json-1.1")
loo_Rest.AddHeader("X-Amz-Target","DeviceFarm_20150623.ListRuns")

loo_SbRequestBody = create oleobject
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Json.EmitSb(loo_SbRequestBody)
loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Rest.FullRequestSb("POST","/",loo_SbRequestBody,loo_SbResponseBody)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_AuthAws
    destroy loo_Json
    destroy loo_SbRequestBody
    destroy loo_SbResponseBody
    return
end if

li_RespStatusCode = loo_Rest.ResponseStatusCode
Write-Debug "response status code = " + string(li_RespStatusCode)
if li_RespStatusCode <> 200 then
    Write-Debug "Response Header:"
    Write-Debug loo_Rest.ResponseHeader
    Write-Debug "Response Body:"
    Write-Debug loo_SbResponseBody.GetAsString()
    destroy loo_Rest
    destroy loo_AuthAws
    destroy loo_Json
    destroy loo_SbRequestBody
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)

// 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

ls_NextToken = loo_JResp.StringOf("nextToken")
i = 0
li_Count_i = loo_JResp.SizeOfArray("runs")
do while i < li_Count_i
    loo_JResp.I = i
    ls_AppUpload = loo_JResp.StringOf("runs[i].appUpload")
    ls_Arn = loo_JResp.StringOf("runs[i].arn")
    ls_BillingMethod = loo_JResp.StringOf("runs[i].billingMethod")
    li_CompletedJobs = loo_JResp.IntOf("runs[i].completedJobs")
    li_Errored = loo_JResp.IntOf("runs[i].counters.errored")
    li_Failed = loo_JResp.IntOf("runs[i].counters.failed")
    li_Passed = loo_JResp.IntOf("runs[i].counters.passed")
    li_Skipped = loo_JResp.IntOf("runs[i].counters.skipped")
    li_Stopped = loo_JResp.IntOf("runs[i].counters.stopped")
    li_Total = loo_JResp.IntOf("runs[i].counters.total")
    li_Warned = loo_JResp.IntOf("runs[i].counters.warned")
    li_Created = loo_JResp.IntOf("runs[i].created")
    li_Metered = loo_JResp.IntOf("runs[i].deviceMinutes.metered")
    li_DeviceMinutesTotal = loo_JResp.IntOf("runs[i].deviceMinutes.total")
    li_Unmetered = loo_JResp.IntOf("runs[i].deviceMinutes.unmetered")
    ls_DevicePoolArn = loo_JResp.StringOf("runs[i].devicePoolArn")
    li_MatchedDevicesCount = loo_JResp.IntOf("runs[i].deviceSelectionResult.matchedDevicesCount")
    li_MaxDevices = loo_JResp.IntOf("runs[i].deviceSelectionResult.maxDevices")
    li_EventCount = loo_JResp.IntOf("runs[i].eventCount")
    li_JobTimeoutMinutes = loo_JResp.IntOf("runs[i].jobTimeoutMinutes")
    ls_Locale = loo_JResp.StringOf("runs[i].locale")
    li_Latitude = loo_JResp.IntOf("runs[i].location.latitude")
    li_Longitude = loo_JResp.IntOf("runs[i].location.longitude")
    ls_Message = loo_JResp.StringOf("runs[i].message")
    ls_Name = loo_JResp.StringOf("runs[i].name")
    ls_Arn = loo_JResp.StringOf("runs[i].networkProfile.arn")
    ls_Description = loo_JResp.StringOf("runs[i].networkProfile.description")
    li_DownlinkBandwidthBits = loo_JResp.IntOf("runs[i].networkProfile.downlinkBandwidthBits")
    li_DownlinkDelayMs = loo_JResp.IntOf("runs[i].networkProfile.downlinkDelayMs")
    li_DownlinkJitterMs = loo_JResp.IntOf("runs[i].networkProfile.downlinkJitterMs")
    li_DownlinkLossPercent = loo_JResp.IntOf("runs[i].networkProfile.downlinkLossPercent")
    ls_Name = loo_JResp.StringOf("runs[i].networkProfile.name")
    ls_V_Type = loo_JResp.StringOf("runs[i].networkProfile.type")
    li_UplinkBandwidthBits = loo_JResp.IntOf("runs[i].networkProfile.uplinkBandwidthBits")
    li_UplinkDelayMs = loo_JResp.IntOf("runs[i].networkProfile.uplinkDelayMs")
    li_UplinkJitterMs = loo_JResp.IntOf("runs[i].networkProfile.uplinkJitterMs")
    li_UplinkLossPercent = loo_JResp.IntOf("runs[i].networkProfile.uplinkLossPercent")
    ls_ParsingResultUrl = loo_JResp.StringOf("runs[i].parsingResultUrl")
    ls_Platform = loo_JResp.StringOf("runs[i].platform")
    li_Bluetooth = loo_JResp.IntOf("runs[i].radios.bluetooth")
    li_Gps = loo_JResp.IntOf("runs[i].radios.gps")
    li_Nfc = loo_JResp.IntOf("runs[i].radios.nfc")
    li_Wifi = loo_JResp.IntOf("runs[i].radios.wifi")
    ls_Result = loo_JResp.StringOf("runs[i].result")
    ls_ResultCode = loo_JResp.StringOf("runs[i].resultCode")
    li_Seed = loo_JResp.IntOf("runs[i].seed")
    li_SkipAppResign = loo_JResp.IntOf("runs[i].skipAppResign")
    li_Started = loo_JResp.IntOf("runs[i].started")
    ls_Status = loo_JResp.StringOf("runs[i].status")
    li_Stopped = loo_JResp.IntOf("runs[i].stopped")
    ls_TestSpecArn = loo_JResp.StringOf("runs[i].testSpecArn")
    li_TotalJobs = loo_JResp.IntOf("runs[i].totalJobs")
    ls_V_type = loo_JResp.StringOf("runs[i].type")
    ls_WebUrl = loo_JResp.StringOf("runs[i].webUrl")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("runs[i].customerArtifactPaths.androidPaths")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("runs[i].customerArtifactPaths.androidPaths[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("runs[i].customerArtifactPaths.deviceHostPaths")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("runs[i].customerArtifactPaths.deviceHostPaths[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("runs[i].customerArtifactPaths.iosPaths")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("runs[i].customerArtifactPaths.iosPaths[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("runs[i].deviceSelectionResult.filters")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Attribute = loo_JResp.StringOf("runs[i].deviceSelectionResult.filters[j].attribute")
        ls_Operator = loo_JResp.StringOf("runs[i].deviceSelectionResult.filters[j].operator")
        k = 0
        li_Count_k = loo_JResp.SizeOfArray("runs[i].deviceSelectionResult.filters[j].values")
        do while k < li_Count_k
            loo_JResp.K = k
            ls_StrVal = loo_JResp.StringOf("runs[i].deviceSelectionResult.filters[j].values[k]")
            k = k + 1
        loop
        j = j + 1
    loop
    i = i + 1
loop

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

// {
//   "nextToken": "string",
//   "runs": [
//     {
//       "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"
//     }
//   ]
// }


destroy loo_Rest
destroy loo_AuthAws
destroy loo_Json
destroy loo_SbRequestBody
destroy loo_SbResponseBody
destroy loo_JResp