Chilkat Online Tools

GetJob VB6 Example

Amazon Braket

' 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 = "braket"
' SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
success = rest.SetAuthAws(authAws)

' URL: https://braket.us-west-2.amazonaws.com/
' Use the same region as specified above.
success = rest.Connect("braket.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

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

Dim sbResponseBody As New ChilkatStringBuilder
success = rest.FullRequestNoBodySb("GET","/job/{jobArn}",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 eventType As String
Dim message As String
Dim timeOfEvent As Long
Dim channelName As String
Dim contentType As String
Dim S3DataSourceS3Uri As String

Dim Uri As String
Uri = jResp.StringOf("algorithmSpecification.containerImage.uri")
Dim CompressionType As String
CompressionType = jResp.StringOf("algorithmSpecification.scriptModeConfig.compressionType")
Dim EntryPoint As String
EntryPoint = jResp.StringOf("algorithmSpecification.scriptModeConfig.entryPoint")
Dim S3Uri As String
S3Uri = jResp.StringOf("algorithmSpecification.scriptModeConfig.s3Uri")
Dim billableDuration As Long
billableDuration = jResp.IntOf("billableDuration")
Dim LocalPath As String
LocalPath = jResp.StringOf("checkpointConfig.localPath")
Dim checkpointConfigS3Uri As String
checkpointConfigS3Uri = jResp.StringOf("checkpointConfig.s3Uri")
Dim createdAt As Long
createdAt = jResp.IntOf("createdAt")
Dim Device As String
Device = jResp.StringOf("deviceConfig.device")
Dim endedAt As Long
endedAt = jResp.IntOf("endedAt")
Dim failureReason As String
failureReason = jResp.StringOf("failureReason")
Dim v_String As String
v_String = jResp.StringOf("hyperParameters.string")
Dim InstanceCount As Long
InstanceCount = jResp.IntOf("instanceConfig.instanceCount")
Dim InstanceType As String
InstanceType = jResp.StringOf("instanceConfig.instanceType")
Dim VolumeSizeInGb As Long
VolumeSizeInGb = jResp.IntOf("instanceConfig.volumeSizeInGb")
Dim jobArn As String
jobArn = jResp.StringOf("jobArn")
Dim jobName As String
jobName = jResp.StringOf("jobName")
Dim KmsKeyId As String
KmsKeyId = jResp.StringOf("outputDataConfig.kmsKeyId")
Dim S3Path As String
S3Path = jResp.StringOf("outputDataConfig.s3Path")
Dim roleArn As String
roleArn = jResp.StringOf("roleArn")
Dim startedAt As Long
startedAt = jResp.IntOf("startedAt")
Dim status As String
status = jResp.StringOf("status")
Dim MaxRuntimeInSeconds As Long
MaxRuntimeInSeconds = jResp.IntOf("stoppingCondition.maxRuntimeInSeconds")
Dim tagsString As String
tagsString = jResp.StringOf("tags.string")
Dim i As Long
i = 0
Dim count_i As Long
count_i = jResp.SizeOfArray("events")
Do While i < count_i
    jResp.I = i
    eventType = jResp.StringOf("events[i].eventType")
    message = jResp.StringOf("events[i].message")
    timeOfEvent = jResp.IntOf("events[i].timeOfEvent")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("inputDataConfig")
Do While i < count_i
    jResp.I = i
    channelName = jResp.StringOf("inputDataConfig[i].channelName")
    contentType = jResp.StringOf("inputDataConfig[i].contentType")
    S3DataSourceS3Uri = jResp.StringOf("inputDataConfig[i].dataSource.s3DataSource.s3Uri")
    i = i + 1
Loop

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

' {
'   "algorithmSpecification": {
'     "containerImage": {
'       "uri": "string"
'     },
'     "scriptModeConfig": {
'       "compressionType": "string",
'       "entryPoint": "string",
'       "s3Uri": "string"
'     }
'   },
'   "billableDuration": number,
'   "checkpointConfig": {
'     "localPath": "string",
'     "s3Uri": "string"
'   },
'   "createdAt": number,
'   "deviceConfig": {
'     "device": "string"
'   },
'   "endedAt": number,
'   "events": [
'     {
'       "eventType": "string",
'       "message": "string",
'       "timeOfEvent": number
'     }
'   ],
'   "failureReason": "string",
'   "hyperParameters": {
'     "string": "string"
'   },
'   "inputDataConfig": [
'     {
'       "channelName": "string",
'       "contentType": "string",
'       "dataSource": {
'         "s3DataSource": {
'           "s3Uri": "string"
'         }
'       }
'     }
'   ],
'   "instanceConfig": {
'     "instanceCount": number,
'     "instanceType": "string",
'     "volumeSizeInGb": number
'   },
'   "jobArn": "string",
'   "jobName": "string",
'   "outputDataConfig": {
'     "kmsKeyId": "string",
'     "s3Path": "string"
'   },
'   "roleArn": "string",
'   "startedAt": number,
'   "status": "string",
'   "stoppingCondition": {
'     "maxRuntimeInSeconds": number
'   },
'   "tags": {
'     "string": "string"
'   }
' }