Chilkat Online Tools

BatchGetBuilds Xojo Example

AWS CodeBuild

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

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

// 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
success = json.UpdateString("ids[0]","string")

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

// {
//   "ids": [
//     "string"
//   ]
// }

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

Dim sbRequestBody As New Chilkat.StringBuilder
success = json.EmitSb(sbRequestBody)
Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestSb("POST","/",sbRequestBody,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 arn As String
Dim ArtifactIdentifier As String
Dim BucketOwnerAccess As String
Dim EncryptionDisabled As Int32
Dim Location As String
Dim Md5sum As String
Dim OverrideArtifactName As Int32
Dim Sha256sum As String
Dim buildBatchArn As String
Dim buildComplete As Int32
Dim buildNumber As Int32
Dim buildStatus As String
Dim cacheLocation As String
Dim v_Type As String
Dim currentPhase As String
Dim SessionEnabled As Int32
Dim SessionTarget As String
Dim encryptionKey As String
Dim endTime As Int32
Dim Certificate As String
Dim ComputeType As String
Dim Image As String
Dim ImagePullCredentialsType As String
Dim PrivilegedMode As Int32
Dim Credential As String
Dim CredentialProvider As String
Dim environmentType As String
Dim id As String
Dim initiator As String
Dim GroupName As String
Dim Status As String
Dim StreamName As String
Dim CloudWatchLogsArn As String
Dim DeepLink As String
Dim logsGroupName As String
Dim S3DeepLink As String
Dim S3LogsBucketOwnerAccess As String
Dim S3LogsEncryptionDisabled As Int32
Dim S3LogsLocation As String
Dim S3LogsStatus As String
Dim S3LogsArn As String
Dim logsStreamName As String
Dim NetworkInterfaceId As String
Dim SubnetId As String
Dim projectName As String
Dim queuedTimeoutInMinutes As Int32
Dim resolvedSourceVersion As String
Dim serviceRole As String
Dim Resource As String
Dim AuthType As String
Dim Buildspec As String
Dim Context As String
Dim TargetUrl As String
Dim GitCloneDepth As Int32
Dim FetchSubmodules As Int32
Dim InsecureSsl As Int32
Dim sourceLocation As String
Dim ReportBuildStatus As Int32
Dim SourceIdentifier As String
Dim sourceType As String
Dim sourceVersion As String
Dim startTime As Int32
Dim timeoutInMinutes As Int32
Dim VpcId As String
Dim j As Int32
Dim count_j As Int32
Dim strVal As String
Dim name As String
Dim v_type As String
Dim value As String
Dim identifier As String
Dim location As String
Dim mountOptions As String
Dim mountPoint As String
Dim durationInSeconds As Int32
Dim phaseStatus As String
Dim phaseType As String
Dim k As Int32
Dim count_k As Int32
Dim message As String
Dim statusCode As String
Dim artifactIdentifier As String
Dim bucketOwnerAccess As String
Dim encryptionDisabled As Int32
Dim md5sum As String
Dim overrideArtifactName As Int32
Dim sha256sum As String
Dim authResource As String
Dim authType As String
Dim buildspec As String
Dim buildStatusConfigContext As String
Dim buildStatusConfigTargetUrl As String
Dim gitCloneDepth As Int32
Dim gitSubmodulesConfigFetchSubmodules As Int32
Dim insecureSsl As Int32
Dim reportBuildStatus As Int32
Dim sourceIdentifier As String

Dim i As Int32
i = 0
Dim count_i As Int32
count_i = jResp.SizeOfArray("builds")
While i < count_i
    jResp.I = i
    arn = jResp.StringOf("builds[i].arn")
    ArtifactIdentifier = jResp.StringOf("builds[i].artifacts.artifactIdentifier")
    BucketOwnerAccess = jResp.StringOf("builds[i].artifacts.bucketOwnerAccess")
    EncryptionDisabled = jResp.IntOf("builds[i].artifacts.encryptionDisabled")
    Location = jResp.StringOf("builds[i].artifacts.location")
    Md5sum = jResp.StringOf("builds[i].artifacts.md5sum")
    OverrideArtifactName = jResp.IntOf("builds[i].artifacts.overrideArtifactName")
    Sha256sum = jResp.StringOf("builds[i].artifacts.sha256sum")
    buildBatchArn = jResp.StringOf("builds[i].buildBatchArn")
    buildComplete = jResp.IntOf("builds[i].buildComplete")
    buildNumber = jResp.IntOf("builds[i].buildNumber")
    buildStatus = jResp.StringOf("builds[i].buildStatus")
    cacheLocation = jResp.StringOf("builds[i].cache.location")
    v_Type = jResp.StringOf("builds[i].cache.type")
    currentPhase = jResp.StringOf("builds[i].currentPhase")
    SessionEnabled = jResp.IntOf("builds[i].debugSession.sessionEnabled")
    SessionTarget = jResp.StringOf("builds[i].debugSession.sessionTarget")
    encryptionKey = jResp.StringOf("builds[i].encryptionKey")
    endTime = jResp.IntOf("builds[i].endTime")
    Certificate = jResp.StringOf("builds[i].environment.certificate")
    ComputeType = jResp.StringOf("builds[i].environment.computeType")
    Image = jResp.StringOf("builds[i].environment.image")
    ImagePullCredentialsType = jResp.StringOf("builds[i].environment.imagePullCredentialsType")
    PrivilegedMode = jResp.IntOf("builds[i].environment.privilegedMode")
    Credential = jResp.StringOf("builds[i].environment.registryCredential.credential")
    CredentialProvider = jResp.StringOf("builds[i].environment.registryCredential.credentialProvider")
    environmentType = jResp.StringOf("builds[i].environment.type")
    id = jResp.StringOf("builds[i].id")
    initiator = jResp.StringOf("builds[i].initiator")
    GroupName = jResp.StringOf("builds[i].logs.cloudWatchLogs.groupName")
    Status = jResp.StringOf("builds[i].logs.cloudWatchLogs.status")
    StreamName = jResp.StringOf("builds[i].logs.cloudWatchLogs.streamName")
    CloudWatchLogsArn = jResp.StringOf("builds[i].logs.cloudWatchLogsArn")
    DeepLink = jResp.StringOf("builds[i].logs.deepLink")
    logsGroupName = jResp.StringOf("builds[i].logs.groupName")
    S3DeepLink = jResp.StringOf("builds[i].logs.s3DeepLink")
    S3LogsBucketOwnerAccess = jResp.StringOf("builds[i].logs.s3Logs.bucketOwnerAccess")
    S3LogsEncryptionDisabled = jResp.IntOf("builds[i].logs.s3Logs.encryptionDisabled")
    S3LogsLocation = jResp.StringOf("builds[i].logs.s3Logs.location")
    S3LogsStatus = jResp.StringOf("builds[i].logs.s3Logs.status")
    S3LogsArn = jResp.StringOf("builds[i].logs.s3LogsArn")
    logsStreamName = jResp.StringOf("builds[i].logs.streamName")
    NetworkInterfaceId = jResp.StringOf("builds[i].networkInterface.networkInterfaceId")
    SubnetId = jResp.StringOf("builds[i].networkInterface.subnetId")
    projectName = jResp.StringOf("builds[i].projectName")
    queuedTimeoutInMinutes = jResp.IntOf("builds[i].queuedTimeoutInMinutes")
    resolvedSourceVersion = jResp.StringOf("builds[i].resolvedSourceVersion")
    serviceRole = jResp.StringOf("builds[i].serviceRole")
    Resource = jResp.StringOf("builds[i].source.auth.resource")
    AuthType = jResp.StringOf("builds[i].source.auth.type")
    Buildspec = jResp.StringOf("builds[i].source.buildspec")
    Context = jResp.StringOf("builds[i].source.buildStatusConfig.context")
    TargetUrl = jResp.StringOf("builds[i].source.buildStatusConfig.targetUrl")
    GitCloneDepth = jResp.IntOf("builds[i].source.gitCloneDepth")
    FetchSubmodules = jResp.IntOf("builds[i].source.gitSubmodulesConfig.fetchSubmodules")
    InsecureSsl = jResp.IntOf("builds[i].source.insecureSsl")
    sourceLocation = jResp.StringOf("builds[i].source.location")
    ReportBuildStatus = jResp.IntOf("builds[i].source.reportBuildStatus")
    SourceIdentifier = jResp.StringOf("builds[i].source.sourceIdentifier")
    sourceType = jResp.StringOf("builds[i].source.type")
    sourceVersion = jResp.StringOf("builds[i].sourceVersion")
    startTime = jResp.IntOf("builds[i].startTime")
    timeoutInMinutes = jResp.IntOf("builds[i].timeoutInMinutes")
    VpcId = jResp.StringOf("builds[i].vpcConfig.vpcId")
    j = 0
    count_j = jResp.SizeOfArray("builds[i].cache.modes")
    While j < count_j
        jResp.J = j
        strVal = jResp.StringOf("builds[i].cache.modes[j]")
        j = j + 1
    Wend
    j = 0
    count_j = jResp.SizeOfArray("builds[i].environment.environmentVariables")
    While j < count_j
        jResp.J = j
        name = jResp.StringOf("builds[i].environment.environmentVariables[j].name")
        v_type = jResp.StringOf("builds[i].environment.environmentVariables[j].type")
        value = jResp.StringOf("builds[i].environment.environmentVariables[j].value")
        j = j + 1
    Wend
    j = 0
    count_j = jResp.SizeOfArray("builds[i].exportedEnvironmentVariables")
    While j < count_j
        jResp.J = j
        name = jResp.StringOf("builds[i].exportedEnvironmentVariables[j].name")
        value = jResp.StringOf("builds[i].exportedEnvironmentVariables[j].value")
        j = j + 1
    Wend
    j = 0
    count_j = jResp.SizeOfArray("builds[i].fileSystemLocations")
    While j < count_j
        jResp.J = j
        identifier = jResp.StringOf("builds[i].fileSystemLocations[j].identifier")
        location = jResp.StringOf("builds[i].fileSystemLocations[j].location")
        mountOptions = jResp.StringOf("builds[i].fileSystemLocations[j].mountOptions")
        mountPoint = jResp.StringOf("builds[i].fileSystemLocations[j].mountPoint")
        v_type = jResp.StringOf("builds[i].fileSystemLocations[j].type")
        j = j + 1
    Wend
    j = 0
    count_j = jResp.SizeOfArray("builds[i].phases")
    While j < count_j
        jResp.J = j
        durationInSeconds = jResp.IntOf("builds[i].phases[j].durationInSeconds")
        endTime = jResp.IntOf("builds[i].phases[j].endTime")
        phaseStatus = jResp.StringOf("builds[i].phases[j].phaseStatus")
        phaseType = jResp.StringOf("builds[i].phases[j].phaseType")
        startTime = jResp.IntOf("builds[i].phases[j].startTime")
        k = 0
        count_k = jResp.SizeOfArray("builds[i].phases[j].contexts")
        While k < count_k
            jResp.K = k
            message = jResp.StringOf("builds[i].phases[j].contexts[k].message")
            statusCode = jResp.StringOf("builds[i].phases[j].contexts[k].statusCode")
            k = k + 1
        Wend
        j = j + 1
    Wend
    j = 0
    count_j = jResp.SizeOfArray("builds[i].reportArns")
    While j < count_j
        jResp.J = j
        strVal = jResp.StringOf("builds[i].reportArns[j]")
        j = j + 1
    Wend
    j = 0
    count_j = jResp.SizeOfArray("builds[i].secondaryArtifacts")
    While j < count_j
        jResp.J = j
        artifactIdentifier = jResp.StringOf("builds[i].secondaryArtifacts[j].artifactIdentifier")
        bucketOwnerAccess = jResp.StringOf("builds[i].secondaryArtifacts[j].bucketOwnerAccess")
        encryptionDisabled = jResp.IntOf("builds[i].secondaryArtifacts[j].encryptionDisabled")
        location = jResp.StringOf("builds[i].secondaryArtifacts[j].location")
        md5sum = jResp.StringOf("builds[i].secondaryArtifacts[j].md5sum")
        overrideArtifactName = jResp.IntOf("builds[i].secondaryArtifacts[j].overrideArtifactName")
        sha256sum = jResp.StringOf("builds[i].secondaryArtifacts[j].sha256sum")
        j = j + 1
    Wend
    j = 0
    count_j = jResp.SizeOfArray("builds[i].secondarySources")
    While j < count_j
        jResp.J = j
        authResource = jResp.StringOf("builds[i].secondarySources[j].auth.resource")
        authType = jResp.StringOf("builds[i].secondarySources[j].auth.type")
        buildspec = jResp.StringOf("builds[i].secondarySources[j].buildspec")
        buildStatusConfigContext = jResp.StringOf("builds[i].secondarySources[j].buildStatusConfig.context")
        buildStatusConfigTargetUrl = jResp.StringOf("builds[i].secondarySources[j].buildStatusConfig.targetUrl")
        gitCloneDepth = jResp.IntOf("builds[i].secondarySources[j].gitCloneDepth")
        gitSubmodulesConfigFetchSubmodules = jResp.IntOf("builds[i].secondarySources[j].gitSubmodulesConfig.fetchSubmodules")
        insecureSsl = jResp.IntOf("builds[i].secondarySources[j].insecureSsl")
        location = jResp.StringOf("builds[i].secondarySources[j].location")
        reportBuildStatus = jResp.IntOf("builds[i].secondarySources[j].reportBuildStatus")
        sourceIdentifier = jResp.StringOf("builds[i].secondarySources[j].sourceIdentifier")
        v_type = jResp.StringOf("builds[i].secondarySources[j].type")
        j = j + 1
    Wend
    j = 0
    count_j = jResp.SizeOfArray("builds[i].secondarySourceVersions")
    While j < count_j
        jResp.J = j
        sourceIdentifier = jResp.StringOf("builds[i].secondarySourceVersions[j].sourceIdentifier")
        sourceVersion = jResp.StringOf("builds[i].secondarySourceVersions[j].sourceVersion")
        j = j + 1
    Wend
    j = 0
    count_j = jResp.SizeOfArray("builds[i].vpcConfig.securityGroupIds")
    While j < count_j
        jResp.J = j
        strVal = jResp.StringOf("builds[i].vpcConfig.securityGroupIds[j]")
        j = j + 1
    Wend
    j = 0
    count_j = jResp.SizeOfArray("builds[i].vpcConfig.subnets")
    While j < count_j
        jResp.J = j
        strVal = jResp.StringOf("builds[i].vpcConfig.subnets[j]")
        j = j + 1
    Wend
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("buildsNotFound")
While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("buildsNotFound[i]")
    i = i + 1
Wend

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

// {
//   "builds": [
//     {
//       "arn": "string",
//       "artifacts": {
//         "artifactIdentifier": "string",
//         "bucketOwnerAccess": "string",
//         "encryptionDisabled": boolean,
//         "location": "string",
//         "md5sum": "string",
//         "overrideArtifactName": boolean,
//         "sha256sum": "string"
//       },
//       "buildBatchArn": "string",
//       "buildComplete": boolean,
//       "buildNumber": number,
//       "buildStatus": "string",
//       "cache": {
//         "location": "string",
//         "modes": [
//           "string"
//         ],
//         "type": "string"
//       },
//       "currentPhase": "string",
//       "debugSession": {
//         "sessionEnabled": boolean,
//         "sessionTarget": "string"
//       },
//       "encryptionKey": "string",
//       "endTime": number,
//       "environment": {
//         "certificate": "string",
//         "computeType": "string",
//         "environmentVariables": [
//           {
//             "name": "string",
//             "type": "string",
//             "value": "string"
//           }
//         ],
//         "image": "string",
//         "imagePullCredentialsType": "string",
//         "privilegedMode": boolean,
//         "registryCredential": {
//           "credential": "string",
//           "credentialProvider": "string"
//         },
//         "type": "string"
//       },
//       "exportedEnvironmentVariables": [
//         {
//           "name": "string",
//           "value": "string"
//         }
//       ],
//       "fileSystemLocations": [
//         {
//           "identifier": "string",
//           "location": "string",
//           "mountOptions": "string",
//           "mountPoint": "string",
//           "type": "string"
//         }
//       ],
//       "id": "string",
//       "initiator": "string",
//       "logs": {
//         "cloudWatchLogs": {
//           "groupName": "string",
//           "status": "string",
//           "streamName": "string"
//         },
//         "cloudWatchLogsArn": "string",
//         "deepLink": "string",
//         "groupName": "string",
//         "s3DeepLink": "string",
//         "s3Logs": {
//           "bucketOwnerAccess": "string",
//           "encryptionDisabled": boolean,
//           "location": "string",
//           "status": "string"
//         },
//         "s3LogsArn": "string",
//         "streamName": "string"
//       },
//       "networkInterface": {
//         "networkInterfaceId": "string",
//         "subnetId": "string"
//       },
//       "phases": [
//         {
//           "contexts": [
//             {
//               "message": "string",
//               "statusCode": "string"
//             }
//           ],
//           "durationInSeconds": number,
//           "endTime": number,
//           "phaseStatus": "string",
//           "phaseType": "string",
//           "startTime": number
//         }
//       ],
//       "projectName": "string",
//       "queuedTimeoutInMinutes": number,
//       "reportArns": [
//         "string"
//       ],
//       "resolvedSourceVersion": "string",
//       "secondaryArtifacts": [
//         {
//           "artifactIdentifier": "string",
//           "bucketOwnerAccess": "string",
//           "encryptionDisabled": boolean,
//           "location": "string",
//           "md5sum": "string",
//           "overrideArtifactName": boolean,
//           "sha256sum": "string"
//         }
//       ],
//       "secondarySources": [
//         {
//           "auth": {
//             "resource": "string",
//             "type": "string"
//           },
//           "buildspec": "string",
//           "buildStatusConfig": {
//             "context": "string",
//             "targetUrl": "string"
//           },
//           "gitCloneDepth": number,
//           "gitSubmodulesConfig": {
//             "fetchSubmodules": boolean
//           },
//           "insecureSsl": boolean,
//           "location": "string",
//           "reportBuildStatus": boolean,
//           "sourceIdentifier": "string",
//           "type": "string"
//         }
//       ],
//       "secondarySourceVersions": [
//         {
//           "sourceIdentifier": "string",
//           "sourceVersion": "string"
//         }
//       ],
//       "serviceRole": "string",
//       "source": {
//         "auth": {
//           "resource": "string",
//           "type": "string"
//         },
//         "buildspec": "string",
//         "buildStatusConfig": {
//           "context": "string",
//           "targetUrl": "string"
//         },
//         "gitCloneDepth": number,
//         "gitSubmodulesConfig": {
//           "fetchSubmodules": boolean
//         },
//         "insecureSsl": boolean,
//         "location": "string",
//         "reportBuildStatus": boolean,
//         "sourceIdentifier": "string",
//         "type": "string"
//       },
//       "sourceVersion": "string",
//       "startTime": number,
//       "timeoutInMinutes": number,
//       "vpcConfig": {
//         "securityGroupIds": [
//           "string"
//         ],
//         "subnets": [
//           "string"
//         ],
//         "vpcId": "string"
//       }
//     }
//   ],
//   "buildsNotFound": [
//     "string"
//   ]
// }