Chilkat Online Tools

GetRun 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_StrVal
string ls_Attribute
string ls_Operator
integer j
integer li_Count_j
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_NetworkProfileArn
string ls_Description
integer li_DownlinkBandwidthBits
integer li_DownlinkDelayMs
integer li_DownlinkJitterMs
integer li_DownlinkLossPercent
string ls_NetworkProfileName
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_RunStopped
string ls_TestSpecArn
integer li_TotalJobs
string ls_RunType
string ls_WebUrl
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")

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

// {
//   "arn": "string"
// }

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

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

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


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