Chilkat Online Tools

GetJob Xojo 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 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 = "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,True,True)
If (success <> True) Then
    System.DebugLog("ConnectFailReason: " + Str(rest.ConnectFailReason))
    System.DebugLog(rest.LastErrorText)
    Return
End If

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

Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestNoBodySb("GET","/job/{jobArn}",sbResponseBody)
If (success <> True) Then
    System.DebugLog(rest.LastErrorText)
    Return
End If

Dim respStatusCode As Int32
respStatusCode = rest.ResponseStatusCode
System.DebugLog("response status code = " + Str(respStatusCode))
If (respStatusCode <> 200) Then
    System.DebugLog("Response Header:")
    System.DebugLog(rest.ResponseHeader)
    System.DebugLog("Response Body:")
    System.DebugLog(sbResponseBody.GetAsString())
    Return
End If

Dim jResp As New Chilkat.JsonObject
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 Int32
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 Int32
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 Int32
createdAt = jResp.IntOf("createdAt")
Dim Device As String
Device = jResp.StringOf("deviceConfig.device")
Dim endedAt As Int32
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 Int32
InstanceCount = jResp.IntOf("instanceConfig.instanceCount")
Dim InstanceType As String
InstanceType = jResp.StringOf("instanceConfig.instanceType")
Dim VolumeSizeInGb As Int32
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 Int32
startedAt = jResp.IntOf("startedAt")
Dim status As String
status = jResp.StringOf("status")
Dim MaxRuntimeInSeconds As Int32
MaxRuntimeInSeconds = jResp.IntOf("stoppingCondition.maxRuntimeInSeconds")
Dim tagsString As String
tagsString = jResp.StringOf("tags.string")
Dim i As Int32
i = 0
Dim count_i As Int32
count_i = jResp.SizeOfArray("events")
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
Wend
i = 0
count_i = jResp.SizeOfArray("inputDataConfig")
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
Wend

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