Chilkat Online Tools

GetRun VB6 Example

AWS Device Farm

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

Dim rest As New ChilkatRest
Dim success As Long

Dim authAws As New ChilkatAuthAws
authAws.AccessKey = "AWS_ACCESS_KEY"
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.)
authAws.Region = "us-west-2"
authAws.ServiceName = "devicefarm"
' SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
success = rest.SetAuthAws(authAws)

' URL: https://devicefarm.us-west-2.amazonaws.com/
' Use the same region as specified above.
success = rest.Connect("devicefarm.us-west-2.amazonaws.com",443,1,1)
If (success <> 1) Then
    Debug.Print "ConnectFailReason: " & rest.ConnectFailReason
    Debug.Print rest.LastErrorText
    Exit Sub
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

Dim json As New ChilkatJsonObject
success = json.UpdateString("arn","string")

' The JSON request body created by the above code:

' {
'   "arn": "string"
' }

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

Dim sbRequestBody As New ChilkatStringBuilder
success = json.EmitSb(sbRequestBody)
Dim sbResponseBody As New ChilkatStringBuilder
success = rest.FullRequestSb("POST","/",sbRequestBody,sbResponseBody)
If (success <> 1) Then
    Debug.Print rest.LastErrorText
    Exit Sub
End If

Dim respStatusCode As Long
respStatusCode = rest.ResponseStatusCode
Debug.Print "response status code = " & respStatusCode
If (respStatusCode <> 200) Then
    Debug.Print "Response Header:"
    Debug.Print rest.ResponseHeader
    Debug.Print "Response Body:"
    Debug.Print sbResponseBody.GetAsString()
    Exit Sub
End If

Dim jResp As New ChilkatJsonObject
success = jResp.LoadSb(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

Dim strVal As String
Dim attribute As String
Dim operator As String
Dim j As Long
Dim count_j As Long

Dim AppUpload As String
AppUpload = jResp.StringOf("run.appUpload")
Dim Arn As String
Arn = jResp.StringOf("run.arn")
Dim BillingMethod As String
BillingMethod = jResp.StringOf("run.billingMethod")
Dim CompletedJobs As Long
CompletedJobs = jResp.IntOf("run.completedJobs")
Dim Errored As Long
Errored = jResp.IntOf("run.counters.errored")
Dim Failed As Long
Failed = jResp.IntOf("run.counters.failed")
Dim Passed As Long
Passed = jResp.IntOf("run.counters.passed")
Dim Skipped As Long
Skipped = jResp.IntOf("run.counters.skipped")
Dim Stopped As Long
Stopped = jResp.IntOf("run.counters.stopped")
Dim Total As Long
Total = jResp.IntOf("run.counters.total")
Dim Warned As Long
Warned = jResp.IntOf("run.counters.warned")
Dim Created As Long
Created = jResp.IntOf("run.created")
Dim Metered As Long
Metered = jResp.IntOf("run.deviceMinutes.metered")
Dim DeviceMinutesTotal As Long
DeviceMinutesTotal = jResp.IntOf("run.deviceMinutes.total")
Dim Unmetered As Long
Unmetered = jResp.IntOf("run.deviceMinutes.unmetered")
Dim DevicePoolArn As String
DevicePoolArn = jResp.StringOf("run.devicePoolArn")
Dim MatchedDevicesCount As Long
MatchedDevicesCount = jResp.IntOf("run.deviceSelectionResult.matchedDevicesCount")
Dim MaxDevices As Long
MaxDevices = jResp.IntOf("run.deviceSelectionResult.maxDevices")
Dim EventCount As Long
EventCount = jResp.IntOf("run.eventCount")
Dim JobTimeoutMinutes As Long
JobTimeoutMinutes = jResp.IntOf("run.jobTimeoutMinutes")
Dim Locale As String
Locale = jResp.StringOf("run.locale")
Dim Latitude As Long
Latitude = jResp.IntOf("run.location.latitude")
Dim Longitude As Long
Longitude = jResp.IntOf("run.location.longitude")
Dim Message As String
Message = jResp.StringOf("run.message")
Dim Name As String
Name = jResp.StringOf("run.name")
Dim NetworkProfileArn As String
NetworkProfileArn = jResp.StringOf("run.networkProfile.arn")
Dim Description As String
Description = jResp.StringOf("run.networkProfile.description")
Dim DownlinkBandwidthBits As Long
DownlinkBandwidthBits = jResp.IntOf("run.networkProfile.downlinkBandwidthBits")
Dim DownlinkDelayMs As Long
DownlinkDelayMs = jResp.IntOf("run.networkProfile.downlinkDelayMs")
Dim DownlinkJitterMs As Long
DownlinkJitterMs = jResp.IntOf("run.networkProfile.downlinkJitterMs")
Dim DownlinkLossPercent As Long
DownlinkLossPercent = jResp.IntOf("run.networkProfile.downlinkLossPercent")
Dim NetworkProfileName As String
NetworkProfileName = jResp.StringOf("run.networkProfile.name")
Dim v_Type As String
v_Type = jResp.StringOf("run.networkProfile.type")
Dim UplinkBandwidthBits As Long
UplinkBandwidthBits = jResp.IntOf("run.networkProfile.uplinkBandwidthBits")
Dim UplinkDelayMs As Long
UplinkDelayMs = jResp.IntOf("run.networkProfile.uplinkDelayMs")
Dim UplinkJitterMs As Long
UplinkJitterMs = jResp.IntOf("run.networkProfile.uplinkJitterMs")
Dim UplinkLossPercent As Long
UplinkLossPercent = jResp.IntOf("run.networkProfile.uplinkLossPercent")
Dim ParsingResultUrl As String
ParsingResultUrl = jResp.StringOf("run.parsingResultUrl")
Dim Platform As String
Platform = jResp.StringOf("run.platform")
Dim Bluetooth As Long
Bluetooth = jResp.IntOf("run.radios.bluetooth")
Dim Gps As Long
Gps = jResp.IntOf("run.radios.gps")
Dim Nfc As Long
Nfc = jResp.IntOf("run.radios.nfc")
Dim Wifi As Long
Wifi = jResp.IntOf("run.radios.wifi")
Dim Result As String
Result = jResp.StringOf("run.result")
Dim ResultCode As String
ResultCode = jResp.StringOf("run.resultCode")
Dim Seed As Long
Seed = jResp.IntOf("run.seed")
Dim SkipAppResign As Long
SkipAppResign = jResp.IntOf("run.skipAppResign")
Dim Started As Long
Started = jResp.IntOf("run.started")
Dim Status As String
Status = jResp.StringOf("run.status")
Dim runStopped As Long
runStopped = jResp.IntOf("run.stopped")
Dim TestSpecArn As String
TestSpecArn = jResp.StringOf("run.testSpecArn")
Dim TotalJobs As Long
TotalJobs = jResp.IntOf("run.totalJobs")
Dim runType As String
runType = jResp.StringOf("run.type")
Dim WebUrl As String
WebUrl = jResp.StringOf("run.webUrl")
Dim i As Long
i = 0
Dim count_i As Long
count_i = jResp.SizeOfArray("run.customerArtifactPaths.androidPaths")
Do While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("run.customerArtifactPaths.androidPaths[i]")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("run.customerArtifactPaths.deviceHostPaths")
Do While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("run.customerArtifactPaths.deviceHostPaths[i]")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("run.customerArtifactPaths.iosPaths")
Do While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("run.customerArtifactPaths.iosPaths[i]")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("run.deviceSelectionResult.filters")
Do While i < count_i
    jResp.I = i
    attribute = jResp.StringOf("run.deviceSelectionResult.filters[i].attribute")
    operator = jResp.StringOf("run.deviceSelectionResult.filters[i].operator")
    j = 0
    count_j = jResp.SizeOfArray("run.deviceSelectionResult.filters[i].values")
    Do While j < count_j
        jResp.J = j
        strVal = 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"
'   }
' }