GetRun VB.NET Example
' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
Dim rest As New Chilkat.Rest
Dim success As Boolean
Dim authAws As New Chilkat.AuthAws
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
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,True,True)
If (success <> True) Then
Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
Debug.WriteLine(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 Chilkat.JsonObject
json.UpdateString("arn","string")
' The JSON request body created by the above code:
' {
' "arn": "string"
' }
rest.AddHeader("Content-Type","application/x-amz-json-1.1")
rest.AddHeader("X-Amz-Target","DeviceFarm_20150623.GetRun")
Dim sbRequestBody As New Chilkat.StringBuilder
json.EmitSb(sbRequestBody)
Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestSb("POST","/",sbRequestBody,sbResponseBody)
If (success <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
Dim respStatusCode As Integer = rest.ResponseStatusCode
Debug.WriteLine("response status code = " & respStatusCode)
If (respStatusCode <> 200) Then
Debug.WriteLine("Response Header:")
Debug.WriteLine(rest.ResponseHeader)
Debug.WriteLine("Response Body:")
Debug.WriteLine(sbResponseBody.GetAsString())
Exit Sub
End If
Dim jResp As New Chilkat.JsonObject
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 Integer
Dim count_j As Integer
Dim AppUpload As String = jResp.StringOf("run.appUpload")
Dim Arn As String = jResp.StringOf("run.arn")
Dim BillingMethod As String = jResp.StringOf("run.billingMethod")
Dim CompletedJobs As Integer = jResp.IntOf("run.completedJobs")
Dim Errored As Integer = jResp.IntOf("run.counters.errored")
Dim Failed As Integer = jResp.IntOf("run.counters.failed")
Dim Passed As Integer = jResp.IntOf("run.counters.passed")
Dim Skipped As Integer = jResp.IntOf("run.counters.skipped")
Dim Stopped As Integer = jResp.IntOf("run.counters.stopped")
Dim Total As Integer = jResp.IntOf("run.counters.total")
Dim Warned As Integer = jResp.IntOf("run.counters.warned")
Dim Created As Integer = jResp.IntOf("run.created")
Dim Metered As Integer = jResp.IntOf("run.deviceMinutes.metered")
Dim DeviceMinutesTotal As Integer = jResp.IntOf("run.deviceMinutes.total")
Dim Unmetered As Integer = jResp.IntOf("run.deviceMinutes.unmetered")
Dim DevicePoolArn As String = jResp.StringOf("run.devicePoolArn")
Dim MatchedDevicesCount As Integer = jResp.IntOf("run.deviceSelectionResult.matchedDevicesCount")
Dim MaxDevices As Integer = jResp.IntOf("run.deviceSelectionResult.maxDevices")
Dim EventCount As Integer = jResp.IntOf("run.eventCount")
Dim JobTimeoutMinutes As Integer = jResp.IntOf("run.jobTimeoutMinutes")
Dim Locale As String = jResp.StringOf("run.locale")
Dim Latitude As Integer = jResp.IntOf("run.location.latitude")
Dim Longitude As Integer = jResp.IntOf("run.location.longitude")
Dim Message As String = jResp.StringOf("run.message")
Dim Name As String = jResp.StringOf("run.name")
Dim NetworkProfileArn As String = jResp.StringOf("run.networkProfile.arn")
Dim Description As String = jResp.StringOf("run.networkProfile.description")
Dim DownlinkBandwidthBits As Integer = jResp.IntOf("run.networkProfile.downlinkBandwidthBits")
Dim DownlinkDelayMs As Integer = jResp.IntOf("run.networkProfile.downlinkDelayMs")
Dim DownlinkJitterMs As Integer = jResp.IntOf("run.networkProfile.downlinkJitterMs")
Dim DownlinkLossPercent As Integer = jResp.IntOf("run.networkProfile.downlinkLossPercent")
Dim NetworkProfileName As String = jResp.StringOf("run.networkProfile.name")
Dim v_Type As String = jResp.StringOf("run.networkProfile.type")
Dim UplinkBandwidthBits As Integer = jResp.IntOf("run.networkProfile.uplinkBandwidthBits")
Dim UplinkDelayMs As Integer = jResp.IntOf("run.networkProfile.uplinkDelayMs")
Dim UplinkJitterMs As Integer = jResp.IntOf("run.networkProfile.uplinkJitterMs")
Dim UplinkLossPercent As Integer = jResp.IntOf("run.networkProfile.uplinkLossPercent")
Dim ParsingResultUrl As String = jResp.StringOf("run.parsingResultUrl")
Dim Platform As String = jResp.StringOf("run.platform")
Dim Bluetooth As Integer = jResp.IntOf("run.radios.bluetooth")
Dim Gps As Integer = jResp.IntOf("run.radios.gps")
Dim Nfc As Integer = jResp.IntOf("run.radios.nfc")
Dim Wifi As Integer = jResp.IntOf("run.radios.wifi")
Dim Result As String = jResp.StringOf("run.result")
Dim ResultCode As String = jResp.StringOf("run.resultCode")
Dim Seed As Integer = jResp.IntOf("run.seed")
Dim SkipAppResign As Integer = jResp.IntOf("run.skipAppResign")
Dim Started As Integer = jResp.IntOf("run.started")
Dim Status As String = jResp.StringOf("run.status")
Dim runStopped As Integer = jResp.IntOf("run.stopped")
Dim TestSpecArn As String = jResp.StringOf("run.testSpecArn")
Dim TotalJobs As Integer = jResp.IntOf("run.totalJobs")
Dim runType As String = jResp.StringOf("run.type")
Dim WebUrl As String = jResp.StringOf("run.webUrl")
Dim i As Integer = 0
Dim count_i As Integer = jResp.SizeOfArray("run.customerArtifactPaths.androidPaths")
While i < count_i
jResp.I = i
strVal = jResp.StringOf("run.customerArtifactPaths.androidPaths[i]")
i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("run.customerArtifactPaths.deviceHostPaths")
While i < count_i
jResp.I = i
strVal = jResp.StringOf("run.customerArtifactPaths.deviceHostPaths[i]")
i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("run.customerArtifactPaths.iosPaths")
While i < count_i
jResp.I = i
strVal = jResp.StringOf("run.customerArtifactPaths.iosPaths[i]")
i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("run.deviceSelectionResult.filters")
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")
While j < count_j
jResp.J = j
strVal = jResp.StringOf("run.deviceSelectionResult.filters[i].values[j]")
j = j + 1
End While
i = i + 1
End While
' 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"
' }
' }