Chilkat Online Tools

RetryBuildBatch VB.NET 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
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
    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("id","string")
json.UpdateString("idempotencyToken","string")
json.UpdateString("retryType","string")

' The JSON request body created by the above code:

' {
'   "id": "string",
'   "idempotencyToken": "string",
'   "retryType": "string"
' }

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

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 currentBuildSummaryArn As String
Dim BuildStatus As String
Dim Identifier As String
Dim PrimaryArtifactLocation As String
Dim PrimaryArtifactType As String
Dim RequestedOn As Integer
Dim identifier As String
Dim ignoreFailure As Integer
Dim j As Integer
Dim count_j As Integer
Dim location As String
Dim v_type As String
Dim arn As String
Dim buildStatus As String
Dim primaryArtifactIdentifier As String
Dim primaryArtifactLocation As String
Dim primaryArtifactType As String
Dim requestedOn As Integer
Dim k As Integer
Dim count_k As Integer
Dim name As String
Dim value As String
Dim mountOptions As String
Dim mountPoint As String
Dim durationInSeconds As Integer
Dim endTime As Integer
Dim phaseStatus As String
Dim phaseType As String
Dim startTime As Integer
Dim message As String
Dim statusCode As String
Dim artifactIdentifier As String
Dim bucketOwnerAccess As String
Dim encryptionDisabled As Integer
Dim md5sum As String
Dim overrideArtifactName As Integer
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 Integer
Dim gitSubmodulesConfigFetchSubmodules As Integer
Dim insecureSsl As Integer
Dim reportBuildStatus As Integer
Dim sourceIdentifier As String
Dim sourceVersion As String

Dim Arn As String = jResp.StringOf("buildBatch.arn")
Dim ArtifactIdentifier As String = jResp.StringOf("buildBatch.artifacts.artifactIdentifier")
Dim BucketOwnerAccess As String = jResp.StringOf("buildBatch.artifacts.bucketOwnerAccess")
Dim EncryptionDisabled As Integer = jResp.IntOf("buildBatch.artifacts.encryptionDisabled")
Dim Location As String = jResp.StringOf("buildBatch.artifacts.location")
Dim Md5sum As String = jResp.StringOf("buildBatch.artifacts.md5sum")
Dim OverrideArtifactName As Integer = jResp.IntOf("buildBatch.artifacts.overrideArtifactName")
Dim Sha256sum As String = jResp.StringOf("buildBatch.artifacts.sha256sum")
Dim BatchReportMode As String = jResp.StringOf("buildBatch.buildBatchConfig.batchReportMode")
Dim CombineArtifacts As Integer = jResp.IntOf("buildBatch.buildBatchConfig.combineArtifacts")
Dim MaximumBuildsAllowed As Integer = jResp.IntOf("buildBatch.buildBatchConfig.restrictions.maximumBuildsAllowed")
Dim ServiceRole As String = jResp.StringOf("buildBatch.buildBatchConfig.serviceRole")
Dim TimeoutInMins As Integer = jResp.IntOf("buildBatch.buildBatchConfig.timeoutInMins")
Dim BuildBatchNumber As Integer = jResp.IntOf("buildBatch.buildBatchNumber")
Dim BuildBatchStatus As String = jResp.StringOf("buildBatch.buildBatchStatus")
Dim BuildTimeoutInMinutes As Integer = jResp.IntOf("buildBatch.buildTimeoutInMinutes")
Dim CacheLocation As String = jResp.StringOf("buildBatch.cache.location")
Dim v_Type As String = jResp.StringOf("buildBatch.cache.type")
Dim Complete As Integer = jResp.IntOf("buildBatch.complete")
Dim CurrentPhase As String = jResp.StringOf("buildBatch.currentPhase")
Dim DebugSessionEnabled As Integer = jResp.IntOf("buildBatch.debugSessionEnabled")
Dim EncryptionKey As String = jResp.StringOf("buildBatch.encryptionKey")
Dim EndTime As Integer = jResp.IntOf("buildBatch.endTime")
Dim Certificate As String = jResp.StringOf("buildBatch.environment.certificate")
Dim ComputeType As String = jResp.StringOf("buildBatch.environment.computeType")
Dim Image As String = jResp.StringOf("buildBatch.environment.image")
Dim ImagePullCredentialsType As String = jResp.StringOf("buildBatch.environment.imagePullCredentialsType")
Dim PrivilegedMode As Integer = jResp.IntOf("buildBatch.environment.privilegedMode")
Dim Credential As String = jResp.StringOf("buildBatch.environment.registryCredential.credential")
Dim CredentialProvider As String = jResp.StringOf("buildBatch.environment.registryCredential.credentialProvider")
Dim EnvironmentType As String = jResp.StringOf("buildBatch.environment.type")
Dim Id As String = jResp.StringOf("buildBatch.id")
Dim Initiator As String = jResp.StringOf("buildBatch.initiator")
Dim GroupName As String = jResp.StringOf("buildBatch.logConfig.cloudWatchLogs.groupName")
Dim Status As String = jResp.StringOf("buildBatch.logConfig.cloudWatchLogs.status")
Dim StreamName As String = jResp.StringOf("buildBatch.logConfig.cloudWatchLogs.streamName")
Dim S3LogsBucketOwnerAccess As String = jResp.StringOf("buildBatch.logConfig.s3Logs.bucketOwnerAccess")
Dim S3LogsEncryptionDisabled As Integer = jResp.IntOf("buildBatch.logConfig.s3Logs.encryptionDisabled")
Dim S3LogsLocation As String = jResp.StringOf("buildBatch.logConfig.s3Logs.location")
Dim S3LogsStatus As String = jResp.StringOf("buildBatch.logConfig.s3Logs.status")
Dim ProjectName As String = jResp.StringOf("buildBatch.projectName")
Dim QueuedTimeoutInMinutes As Integer = jResp.IntOf("buildBatch.queuedTimeoutInMinutes")
Dim ResolvedSourceVersion As String = jResp.StringOf("buildBatch.resolvedSourceVersion")
Dim buildBatchServiceRole As String = jResp.StringOf("buildBatch.serviceRole")
Dim Resource As String = jResp.StringOf("buildBatch.source.auth.resource")
Dim AuthType As String = jResp.StringOf("buildBatch.source.auth.type")
Dim Buildspec As String = jResp.StringOf("buildBatch.source.buildspec")
Dim Context As String = jResp.StringOf("buildBatch.source.buildStatusConfig.context")
Dim TargetUrl As String = jResp.StringOf("buildBatch.source.buildStatusConfig.targetUrl")
Dim GitCloneDepth As Integer = jResp.IntOf("buildBatch.source.gitCloneDepth")
Dim FetchSubmodules As Integer = jResp.IntOf("buildBatch.source.gitSubmodulesConfig.fetchSubmodules")
Dim InsecureSsl As Integer = jResp.IntOf("buildBatch.source.insecureSsl")
Dim SourceLocation As String = jResp.StringOf("buildBatch.source.location")
Dim ReportBuildStatus As Integer = jResp.IntOf("buildBatch.source.reportBuildStatus")
Dim SourceIdentifier As String = jResp.StringOf("buildBatch.source.sourceIdentifier")
Dim SourceType As String = jResp.StringOf("buildBatch.source.type")
Dim SourceVersion As String = jResp.StringOf("buildBatch.sourceVersion")
Dim StartTime As Integer = jResp.IntOf("buildBatch.startTime")
Dim VpcId As String = jResp.StringOf("buildBatch.vpcConfig.vpcId")
Dim i As Integer = 0
Dim count_i As Integer = jResp.SizeOfArray("buildBatch.buildBatchConfig.restrictions.computeTypesAllowed")
While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("buildBatch.buildBatchConfig.restrictions.computeTypesAllowed[i]")
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("buildBatch.buildGroups")
While i < count_i
    jResp.I = i
    currentBuildSummaryArn = jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.arn")
    BuildStatus = jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.buildStatus")
    Identifier = jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.primaryArtifact.identifier")
    PrimaryArtifactLocation = jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.primaryArtifact.location")
    PrimaryArtifactType = jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.primaryArtifact.type")
    RequestedOn = jResp.IntOf("buildBatch.buildGroups[i].currentBuildSummary.requestedOn")
    identifier = jResp.StringOf("buildBatch.buildGroups[i].identifier")
    ignoreFailure = jResp.IntOf("buildBatch.buildGroups[i].ignoreFailure")
    j = 0
    count_j = jResp.SizeOfArray("buildBatch.buildGroups[i].currentBuildSummary.secondaryArtifacts")
    While j < count_j
        jResp.J = j
        identifier = jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.secondaryArtifacts[j].identifier")
        location = jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.secondaryArtifacts[j].location")
        v_type = jResp.StringOf("buildBatch.buildGroups[i].currentBuildSummary.secondaryArtifacts[j].type")
        j = j + 1
    End While
    j = 0
    count_j = jResp.SizeOfArray("buildBatch.buildGroups[i].dependsOn")
    While j < count_j
        jResp.J = j
        strVal = jResp.StringOf("buildBatch.buildGroups[i].dependsOn[j]")
        j = j + 1
    End While
    j = 0
    count_j = jResp.SizeOfArray("buildBatch.buildGroups[i].priorBuildSummaryList")
    While j < count_j
        jResp.J = j
        arn = jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].arn")
        buildStatus = jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].buildStatus")
        primaryArtifactIdentifier = jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].primaryArtifact.identifier")
        primaryArtifactLocation = jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].primaryArtifact.location")
        primaryArtifactType = jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].primaryArtifact.type")
        requestedOn = jResp.IntOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].requestedOn")
        k = 0
        count_k = jResp.SizeOfArray("buildBatch.buildGroups[i].priorBuildSummaryList[j].secondaryArtifacts")
        While k < count_k
            jResp.K = k
            identifier = jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].secondaryArtifacts[k].identifier")
            location = jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].secondaryArtifacts[k].location")
            v_type = jResp.StringOf("buildBatch.buildGroups[i].priorBuildSummaryList[j].secondaryArtifacts[k].type")
            k = k + 1
        End While
        j = j + 1
    End While
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("buildBatch.cache.modes")
While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("buildBatch.cache.modes[i]")
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("buildBatch.environment.environmentVariables")
While i < count_i
    jResp.I = i
    name = jResp.StringOf("buildBatch.environment.environmentVariables[i].name")
    v_type = jResp.StringOf("buildBatch.environment.environmentVariables[i].type")
    value = jResp.StringOf("buildBatch.environment.environmentVariables[i].value")
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("buildBatch.fileSystemLocations")
While i < count_i
    jResp.I = i
    identifier = jResp.StringOf("buildBatch.fileSystemLocations[i].identifier")
    location = jResp.StringOf("buildBatch.fileSystemLocations[i].location")
    mountOptions = jResp.StringOf("buildBatch.fileSystemLocations[i].mountOptions")
    mountPoint = jResp.StringOf("buildBatch.fileSystemLocations[i].mountPoint")
    v_type = jResp.StringOf("buildBatch.fileSystemLocations[i].type")
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("buildBatch.phases")
While i < count_i
    jResp.I = i
    durationInSeconds = jResp.IntOf("buildBatch.phases[i].durationInSeconds")
    endTime = jResp.IntOf("buildBatch.phases[i].endTime")
    phaseStatus = jResp.StringOf("buildBatch.phases[i].phaseStatus")
    phaseType = jResp.StringOf("buildBatch.phases[i].phaseType")
    startTime = jResp.IntOf("buildBatch.phases[i].startTime")
    j = 0
    count_j = jResp.SizeOfArray("buildBatch.phases[i].contexts")
    While j < count_j
        jResp.J = j
        message = jResp.StringOf("buildBatch.phases[i].contexts[j].message")
        statusCode = jResp.StringOf("buildBatch.phases[i].contexts[j].statusCode")
        j = j + 1
    End While
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("buildBatch.secondaryArtifacts")
While i < count_i
    jResp.I = i
    artifactIdentifier = jResp.StringOf("buildBatch.secondaryArtifacts[i].artifactIdentifier")
    bucketOwnerAccess = jResp.StringOf("buildBatch.secondaryArtifacts[i].bucketOwnerAccess")
    encryptionDisabled = jResp.IntOf("buildBatch.secondaryArtifacts[i].encryptionDisabled")
    location = jResp.StringOf("buildBatch.secondaryArtifacts[i].location")
    md5sum = jResp.StringOf("buildBatch.secondaryArtifacts[i].md5sum")
    overrideArtifactName = jResp.IntOf("buildBatch.secondaryArtifacts[i].overrideArtifactName")
    sha256sum = jResp.StringOf("buildBatch.secondaryArtifacts[i].sha256sum")
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("buildBatch.secondarySources")
While i < count_i
    jResp.I = i
    authResource = jResp.StringOf("buildBatch.secondarySources[i].auth.resource")
    authType = jResp.StringOf("buildBatch.secondarySources[i].auth.type")
    buildspec = jResp.StringOf("buildBatch.secondarySources[i].buildspec")
    buildStatusConfigContext = jResp.StringOf("buildBatch.secondarySources[i].buildStatusConfig.context")
    buildStatusConfigTargetUrl = jResp.StringOf("buildBatch.secondarySources[i].buildStatusConfig.targetUrl")
    gitCloneDepth = jResp.IntOf("buildBatch.secondarySources[i].gitCloneDepth")
    gitSubmodulesConfigFetchSubmodules = jResp.IntOf("buildBatch.secondarySources[i].gitSubmodulesConfig.fetchSubmodules")
    insecureSsl = jResp.IntOf("buildBatch.secondarySources[i].insecureSsl")
    location = jResp.StringOf("buildBatch.secondarySources[i].location")
    reportBuildStatus = jResp.IntOf("buildBatch.secondarySources[i].reportBuildStatus")
    sourceIdentifier = jResp.StringOf("buildBatch.secondarySources[i].sourceIdentifier")
    v_type = jResp.StringOf("buildBatch.secondarySources[i].type")
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("buildBatch.secondarySourceVersions")
While i < count_i
    jResp.I = i
    sourceIdentifier = jResp.StringOf("buildBatch.secondarySourceVersions[i].sourceIdentifier")
    sourceVersion = jResp.StringOf("buildBatch.secondarySourceVersions[i].sourceVersion")
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("buildBatch.vpcConfig.securityGroupIds")
While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("buildBatch.vpcConfig.securityGroupIds[i]")
    i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("buildBatch.vpcConfig.subnets")
While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("buildBatch.vpcConfig.subnets[i]")
    i = i + 1
End While


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

' {
'   "buildBatch": {
'     "arn": "string",
'     "artifacts": {
'       "artifactIdentifier": "string",
'       "bucketOwnerAccess": "string",
'       "encryptionDisabled": boolean,
'       "location": "string",
'       "md5sum": "string",
'       "overrideArtifactName": boolean,
'       "sha256sum": "string"
'     },
'     "buildBatchConfig": {
'       "batchReportMode": "string",
'       "combineArtifacts": boolean,
'       "restrictions": {
'         "computeTypesAllowed": [
'           "string"
'         ],
'         "maximumBuildsAllowed": number
'       },
'       "serviceRole": "string",
'       "timeoutInMins": number
'     },
'     "buildBatchNumber": number,
'     "buildBatchStatus": "string",
'     "buildGroups": [
'       {
'         "currentBuildSummary": {
'           "arn": "string",
'           "buildStatus": "string",
'           "primaryArtifact": {
'             "identifier": "string",
'             "location": "string",
'             "type": "string"
'           },
'           "requestedOn": number,
'           "secondaryArtifacts": [
'             {
'               "identifier": "string",
'               "location": "string",
'               "type": "string"
'             }
'           ]
'         },
'         "dependsOn": [
'           "string"
'         ],
'         "identifier": "string",
'         "ignoreFailure": boolean,
'         "priorBuildSummaryList": [
'           {
'             "arn": "string",
'             "buildStatus": "string",
'             "primaryArtifact": {
'               "identifier": "string",
'               "location": "string",
'               "type": "string"
'             },
'             "requestedOn": number,
'             "secondaryArtifacts": [
'               {
'                 "identifier": "string",
'                 "location": "string",
'                 "type": "string"
'               }
'             ]
'           }
'         ]
'       }
'     ],
'     "buildTimeoutInMinutes": number,
'     "cache": {
'       "location": "string",
'       "modes": [
'         "string"
'       ],
'       "type": "string"
'     },
'     "complete": boolean,
'     "currentPhase": "string",
'     "debugSessionEnabled": boolean,
'     "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"
'     },
'     "fileSystemLocations": [
'       {
'         "identifier": "string",
'         "location": "string",
'         "mountOptions": "string",
'         "mountPoint": "string",
'         "type": "string"
'       }
'     ],
'     "id": "string",
'     "initiator": "string",
'     "logConfig": {
'       "cloudWatchLogs": {
'         "groupName": "string",
'         "status": "string",
'         "streamName": "string"
'       },
'       "s3Logs": {
'         "bucketOwnerAccess": "string",
'         "encryptionDisabled": boolean,
'         "location": "string",
'         "status": "string"
'       }
'     },
'     "phases": [
'       {
'         "contexts": [
'           {
'             "message": "string",
'             "statusCode": "string"
'           }
'         ],
'         "durationInSeconds": number,
'         "endTime": number,
'         "phaseStatus": "string",
'         "phaseType": "string",
'         "startTime": number
'       }
'     ],
'     "projectName": "string",
'     "queuedTimeoutInMinutes": number,
'     "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,
'     "vpcConfig": {
'       "securityGroupIds": [
'         "string"
'       ],
'       "subnets": [
'         "string"
'       ],
'       "vpcId": "string"
'     }
'   }
' }