Chilkat Online Tools

RetryBuild VB6 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 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 = "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,1,1)
If (success <> 1) Then
    Debug.Print "ConnectFailReason: " & rest.ConnectFailReason
    Debug.Print 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 ChilkatJsonObject
success = json.UpdateString("id","string")
success = json.UpdateString("idempotencyToken","string")

' The JSON request body created by the above code:

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

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

Dim sbRequestBody As New ChilkatStringBuilder
success = json.EmitSb(sbRequestBody)
Dim sbResponseBody As New ChilkatStringBuilder
success = rest.FullRequestSb("POST","/",sbRequestBody,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 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 Long
Dim endTime As Long
Dim phaseStatus As String
Dim phaseType As String
Dim startTime As Long
Dim j As Long
Dim count_j As Long
Dim message As String
Dim statusCode As String
Dim artifactIdentifier As String
Dim bucketOwnerAccess As String
Dim encryptionDisabled As Long
Dim md5sum As String
Dim overrideArtifactName As Long
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 Long
Dim gitSubmodulesConfigFetchSubmodules As Long
Dim insecureSsl As Long
Dim reportBuildStatus As Long
Dim sourceIdentifier As String
Dim sourceVersion As String

Dim Arn As String
Arn = jResp.StringOf("build.arn")
Dim ArtifactIdentifier As String
ArtifactIdentifier = jResp.StringOf("build.artifacts.artifactIdentifier")
Dim BucketOwnerAccess As String
BucketOwnerAccess = jResp.StringOf("build.artifacts.bucketOwnerAccess")
Dim EncryptionDisabled As Long
EncryptionDisabled = jResp.IntOf("build.artifacts.encryptionDisabled")
Dim Location As String
Location = jResp.StringOf("build.artifacts.location")
Dim Md5sum As String
Md5sum = jResp.StringOf("build.artifacts.md5sum")
Dim OverrideArtifactName As Long
OverrideArtifactName = jResp.IntOf("build.artifacts.overrideArtifactName")
Dim Sha256sum As String
Sha256sum = jResp.StringOf("build.artifacts.sha256sum")
Dim BuildBatchArn As String
BuildBatchArn = jResp.StringOf("build.buildBatchArn")
Dim BuildComplete As Long
BuildComplete = jResp.IntOf("build.buildComplete")
Dim BuildNumber As Long
BuildNumber = jResp.IntOf("build.buildNumber")
Dim BuildStatus As String
BuildStatus = jResp.StringOf("build.buildStatus")
Dim CacheLocation As String
CacheLocation = jResp.StringOf("build.cache.location")
Dim v_Type As String
v_Type = jResp.StringOf("build.cache.type")
Dim CurrentPhase As String
CurrentPhase = jResp.StringOf("build.currentPhase")
Dim SessionEnabled As Long
SessionEnabled = jResp.IntOf("build.debugSession.sessionEnabled")
Dim SessionTarget As String
SessionTarget = jResp.StringOf("build.debugSession.sessionTarget")
Dim EncryptionKey As String
EncryptionKey = jResp.StringOf("build.encryptionKey")
Dim EndTime As Long
EndTime = jResp.IntOf("build.endTime")
Dim Certificate As String
Certificate = jResp.StringOf("build.environment.certificate")
Dim ComputeType As String
ComputeType = jResp.StringOf("build.environment.computeType")
Dim Image As String
Image = jResp.StringOf("build.environment.image")
Dim ImagePullCredentialsType As String
ImagePullCredentialsType = jResp.StringOf("build.environment.imagePullCredentialsType")
Dim PrivilegedMode As Long
PrivilegedMode = jResp.IntOf("build.environment.privilegedMode")
Dim Credential As String
Credential = jResp.StringOf("build.environment.registryCredential.credential")
Dim CredentialProvider As String
CredentialProvider = jResp.StringOf("build.environment.registryCredential.credentialProvider")
Dim EnvironmentType As String
EnvironmentType = jResp.StringOf("build.environment.type")
Dim Id As String
Id = jResp.StringOf("build.id")
Dim Initiator As String
Initiator = jResp.StringOf("build.initiator")
Dim GroupName As String
GroupName = jResp.StringOf("build.logs.cloudWatchLogs.groupName")
Dim Status As String
Status = jResp.StringOf("build.logs.cloudWatchLogs.status")
Dim StreamName As String
StreamName = jResp.StringOf("build.logs.cloudWatchLogs.streamName")
Dim CloudWatchLogsArn As String
CloudWatchLogsArn = jResp.StringOf("build.logs.cloudWatchLogsArn")
Dim DeepLink As String
DeepLink = jResp.StringOf("build.logs.deepLink")
Dim LogsGroupName As String
LogsGroupName = jResp.StringOf("build.logs.groupName")
Dim S3DeepLink As String
S3DeepLink = jResp.StringOf("build.logs.s3DeepLink")
Dim S3LogsBucketOwnerAccess As String
S3LogsBucketOwnerAccess = jResp.StringOf("build.logs.s3Logs.bucketOwnerAccess")
Dim S3LogsEncryptionDisabled As Long
S3LogsEncryptionDisabled = jResp.IntOf("build.logs.s3Logs.encryptionDisabled")
Dim S3LogsLocation As String
S3LogsLocation = jResp.StringOf("build.logs.s3Logs.location")
Dim S3LogsStatus As String
S3LogsStatus = jResp.StringOf("build.logs.s3Logs.status")
Dim S3LogsArn As String
S3LogsArn = jResp.StringOf("build.logs.s3LogsArn")
Dim LogsStreamName As String
LogsStreamName = jResp.StringOf("build.logs.streamName")
Dim NetworkInterfaceId As String
NetworkInterfaceId = jResp.StringOf("build.networkInterface.networkInterfaceId")
Dim SubnetId As String
SubnetId = jResp.StringOf("build.networkInterface.subnetId")
Dim ProjectName As String
ProjectName = jResp.StringOf("build.projectName")
Dim QueuedTimeoutInMinutes As Long
QueuedTimeoutInMinutes = jResp.IntOf("build.queuedTimeoutInMinutes")
Dim ResolvedSourceVersion As String
ResolvedSourceVersion = jResp.StringOf("build.resolvedSourceVersion")
Dim ServiceRole As String
ServiceRole = jResp.StringOf("build.serviceRole")
Dim Resource As String
Resource = jResp.StringOf("build.source.auth.resource")
Dim AuthType As String
AuthType = jResp.StringOf("build.source.auth.type")
Dim Buildspec As String
Buildspec = jResp.StringOf("build.source.buildspec")
Dim Context As String
Context = jResp.StringOf("build.source.buildStatusConfig.context")
Dim TargetUrl As String
TargetUrl = jResp.StringOf("build.source.buildStatusConfig.targetUrl")
Dim GitCloneDepth As Long
GitCloneDepth = jResp.IntOf("build.source.gitCloneDepth")
Dim FetchSubmodules As Long
FetchSubmodules = jResp.IntOf("build.source.gitSubmodulesConfig.fetchSubmodules")
Dim InsecureSsl As Long
InsecureSsl = jResp.IntOf("build.source.insecureSsl")
Dim SourceLocation As String
SourceLocation = jResp.StringOf("build.source.location")
Dim ReportBuildStatus As Long
ReportBuildStatus = jResp.IntOf("build.source.reportBuildStatus")
Dim SourceIdentifier As String
SourceIdentifier = jResp.StringOf("build.source.sourceIdentifier")
Dim SourceType As String
SourceType = jResp.StringOf("build.source.type")
Dim SourceVersion As String
SourceVersion = jResp.StringOf("build.sourceVersion")
Dim StartTime As Long
StartTime = jResp.IntOf("build.startTime")
Dim TimeoutInMinutes As Long
TimeoutInMinutes = jResp.IntOf("build.timeoutInMinutes")
Dim VpcId As String
VpcId = jResp.StringOf("build.vpcConfig.vpcId")
Dim i As Long
i = 0
Dim count_i As Long
count_i = jResp.SizeOfArray("build.cache.modes")
Do While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("build.cache.modes[i]")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("build.environment.environmentVariables")
Do While i < count_i
    jResp.I = i
    name = jResp.StringOf("build.environment.environmentVariables[i].name")
    v_type = jResp.StringOf("build.environment.environmentVariables[i].type")
    value = jResp.StringOf("build.environment.environmentVariables[i].value")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("build.exportedEnvironmentVariables")
Do While i < count_i
    jResp.I = i
    name = jResp.StringOf("build.exportedEnvironmentVariables[i].name")
    value = jResp.StringOf("build.exportedEnvironmentVariables[i].value")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("build.fileSystemLocations")
Do While i < count_i
    jResp.I = i
    identifier = jResp.StringOf("build.fileSystemLocations[i].identifier")
    location = jResp.StringOf("build.fileSystemLocations[i].location")
    mountOptions = jResp.StringOf("build.fileSystemLocations[i].mountOptions")
    mountPoint = jResp.StringOf("build.fileSystemLocations[i].mountPoint")
    v_type = jResp.StringOf("build.fileSystemLocations[i].type")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("build.phases")
Do While i < count_i
    jResp.I = i
    durationInSeconds = jResp.IntOf("build.phases[i].durationInSeconds")
    endTime = jResp.IntOf("build.phases[i].endTime")
    phaseStatus = jResp.StringOf("build.phases[i].phaseStatus")
    phaseType = jResp.StringOf("build.phases[i].phaseType")
    startTime = jResp.IntOf("build.phases[i].startTime")
    j = 0
    count_j = jResp.SizeOfArray("build.phases[i].contexts")
    Do While j < count_j
        jResp.J = j
        message = jResp.StringOf("build.phases[i].contexts[j].message")
        statusCode = jResp.StringOf("build.phases[i].contexts[j].statusCode")
        j = j + 1
    Loop
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("build.reportArns")
Do While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("build.reportArns[i]")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("build.secondaryArtifacts")
Do While i < count_i
    jResp.I = i
    artifactIdentifier = jResp.StringOf("build.secondaryArtifacts[i].artifactIdentifier")
    bucketOwnerAccess = jResp.StringOf("build.secondaryArtifacts[i].bucketOwnerAccess")
    encryptionDisabled = jResp.IntOf("build.secondaryArtifacts[i].encryptionDisabled")
    location = jResp.StringOf("build.secondaryArtifacts[i].location")
    md5sum = jResp.StringOf("build.secondaryArtifacts[i].md5sum")
    overrideArtifactName = jResp.IntOf("build.secondaryArtifacts[i].overrideArtifactName")
    sha256sum = jResp.StringOf("build.secondaryArtifacts[i].sha256sum")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("build.secondarySources")
Do While i < count_i
    jResp.I = i
    authResource = jResp.StringOf("build.secondarySources[i].auth.resource")
    authType = jResp.StringOf("build.secondarySources[i].auth.type")
    buildspec = jResp.StringOf("build.secondarySources[i].buildspec")
    buildStatusConfigContext = jResp.StringOf("build.secondarySources[i].buildStatusConfig.context")
    buildStatusConfigTargetUrl = jResp.StringOf("build.secondarySources[i].buildStatusConfig.targetUrl")
    gitCloneDepth = jResp.IntOf("build.secondarySources[i].gitCloneDepth")
    gitSubmodulesConfigFetchSubmodules = jResp.IntOf("build.secondarySources[i].gitSubmodulesConfig.fetchSubmodules")
    insecureSsl = jResp.IntOf("build.secondarySources[i].insecureSsl")
    location = jResp.StringOf("build.secondarySources[i].location")
    reportBuildStatus = jResp.IntOf("build.secondarySources[i].reportBuildStatus")
    sourceIdentifier = jResp.StringOf("build.secondarySources[i].sourceIdentifier")
    v_type = jResp.StringOf("build.secondarySources[i].type")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("build.secondarySourceVersions")
Do While i < count_i
    jResp.I = i
    sourceIdentifier = jResp.StringOf("build.secondarySourceVersions[i].sourceIdentifier")
    sourceVersion = jResp.StringOf("build.secondarySourceVersions[i].sourceVersion")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("build.vpcConfig.securityGroupIds")
Do While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("build.vpcConfig.securityGroupIds[i]")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("build.vpcConfig.subnets")
Do While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("build.vpcConfig.subnets[i]")
    i = i + 1
Loop

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

' {
'   "build": {
'     "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"
'     }
'   }
' }