Chilkat Online Tools

RetryBuild autoit Example

AWS CodeBuild

; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oRest = ObjCreate("Chilkat_9_5_0.Rest")
Local $bSuccess

$oAuthAws = ObjCreate("Chilkat_9_5_0.AuthAws")
$oAuthAws.AccessKey = "AWS_ACCESS_KEY"
$oAuthAws.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.)
$oAuthAws.Region = "us-west-2"
$oAuthAws.ServiceName = "codebuild"
; SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
$oRest.SetAuthAws($oAuthAws)

; URL: https://codebuild.us-west-2.amazonaws.com/
; Use the same region as specified above.
$bSuccess = $oRest.Connect("codebuild.us-west-2.amazonaws.com",443,True,True)
If ($bSuccess <> True) Then
    ConsoleWrite("ConnectFailReason: " & $oRest.ConnectFailReason & @CRLF)
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

; 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

$oJson = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJson.UpdateString("id","string")
$oJson.UpdateString("idempotencyToken","string")

; The JSON request body created by the above code:

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

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

$oSbRequestBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$oJson.EmitSb($oSbRequestBody)
$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestSb("POST","/",$oSbRequestBody,$oSbResponseBody)
If ($bSuccess <> True) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

Local $iRespStatusCode = $oRest.ResponseStatusCode
ConsoleWrite("response status code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode <> 200) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oRest.ResponseHeader & @CRLF)
    ConsoleWrite("Response Body:" & @CRLF)
    ConsoleWrite($oSbResponseBody.GetAsString() & @CRLF)
    Exit
EndIf

$oJResp = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJResp.LoadSb($oSbResponseBody)

; 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

Local $strVal
Local $sName
Local $sV_type
Local $sValue
Local $sIdentifier
Local $sLocation
Local $sMountOptions
Local $sMountPoint
Local $iDurationInSeconds
Local $iEndTime
Local $sPhaseStatus
Local $sPhaseType
Local $iStartTime
Local $iJ
Local $iCount_j
Local $sMessage
Local $statusCode
Local $sArtifactIdentifier
Local $sBucketOwnerAccess
Local $iEncryptionDisabled
Local $sMd5sum
Local $iOverrideArtifactName
Local $sha256sum
Local $sAuthResource
Local $sAuthType
Local $sBuildspec
Local $sBuildStatusConfigContext
Local $sBuildStatusConfigTargetUrl
Local $iGitCloneDepth
Local $iGitSubmodulesConfigFetchSubmodules
Local $insecureSsl
Local $iReportBuildStatus
Local $sourceIdentifier
Local $sourceVersion

Local $sArn = $oJResp.StringOf("build.arn")
Local $sArtifactIdentifier = $oJResp.StringOf("build.artifacts.artifactIdentifier")
Local $sBucketOwnerAccess = $oJResp.StringOf("build.artifacts.bucketOwnerAccess")
Local $iEncryptionDisabled = $oJResp.IntOf("build.artifacts.encryptionDisabled")
Local $sLocation = $oJResp.StringOf("build.artifacts.location")
Local $sMd5sum = $oJResp.StringOf("build.artifacts.md5sum")
Local $iOverrideArtifactName = $oJResp.IntOf("build.artifacts.overrideArtifactName")
Local $sSha256sum = $oJResp.StringOf("build.artifacts.sha256sum")
Local $sBuildBatchArn = $oJResp.StringOf("build.buildBatchArn")
Local $iBuildComplete = $oJResp.IntOf("build.buildComplete")
Local $iBuildNumber = $oJResp.IntOf("build.buildNumber")
Local $sBuildStatus = $oJResp.StringOf("build.buildStatus")
Local $sCacheLocation = $oJResp.StringOf("build.cache.location")
Local $sV_Type = $oJResp.StringOf("build.cache.type")
Local $sCurrentPhase = $oJResp.StringOf("build.currentPhase")
Local $iSessionEnabled = $oJResp.IntOf("build.debugSession.sessionEnabled")
Local $sSessionTarget = $oJResp.StringOf("build.debugSession.sessionTarget")
Local $sEncryptionKey = $oJResp.StringOf("build.encryptionKey")
Local $iEndTime = $oJResp.IntOf("build.endTime")
Local $sCertificate = $oJResp.StringOf("build.environment.certificate")
Local $sComputeType = $oJResp.StringOf("build.environment.computeType")
Local $sImage = $oJResp.StringOf("build.environment.image")
Local $sImagePullCredentialsType = $oJResp.StringOf("build.environment.imagePullCredentialsType")
Local $iPrivilegedMode = $oJResp.IntOf("build.environment.privilegedMode")
Local $sCredential = $oJResp.StringOf("build.environment.registryCredential.credential")
Local $sCredentialProvider = $oJResp.StringOf("build.environment.registryCredential.credentialProvider")
Local $sEnvironmentType = $oJResp.StringOf("build.environment.type")
Local $sId = $oJResp.StringOf("build.id")
Local $sInitiator = $oJResp.StringOf("build.initiator")
Local $sGroupName = $oJResp.StringOf("build.logs.cloudWatchLogs.groupName")
Local $sStatus = $oJResp.StringOf("build.logs.cloudWatchLogs.status")
Local $sStreamName = $oJResp.StringOf("build.logs.cloudWatchLogs.streamName")
Local $sCloudWatchLogsArn = $oJResp.StringOf("build.logs.cloudWatchLogsArn")
Local $sDeepLink = $oJResp.StringOf("build.logs.deepLink")
Local $sLogsGroupName = $oJResp.StringOf("build.logs.groupName")
Local $sS3DeepLink = $oJResp.StringOf("build.logs.s3DeepLink")
Local $sS3LogsBucketOwnerAccess = $oJResp.StringOf("build.logs.s3Logs.bucketOwnerAccess")
Local $iS3LogsEncryptionDisabled = $oJResp.IntOf("build.logs.s3Logs.encryptionDisabled")
Local $sS3LogsLocation = $oJResp.StringOf("build.logs.s3Logs.location")
Local $sS3LogsStatus = $oJResp.StringOf("build.logs.s3Logs.status")
Local $sS3LogsArn = $oJResp.StringOf("build.logs.s3LogsArn")
Local $sLogsStreamName = $oJResp.StringOf("build.logs.streamName")
Local $sNetworkInterfaceId = $oJResp.StringOf("build.networkInterface.networkInterfaceId")
Local $sSubnetId = $oJResp.StringOf("build.networkInterface.subnetId")
Local $sProjectName = $oJResp.StringOf("build.projectName")
Local $iQueuedTimeoutInMinutes = $oJResp.IntOf("build.queuedTimeoutInMinutes")
Local $sResolvedSourceVersion = $oJResp.StringOf("build.resolvedSourceVersion")
Local $sServiceRole = $oJResp.StringOf("build.serviceRole")
Local $sResource = $oJResp.StringOf("build.source.auth.resource")
Local $sAuthType = $oJResp.StringOf("build.source.auth.type")
Local $sBuildspec = $oJResp.StringOf("build.source.buildspec")
Local $sContext = $oJResp.StringOf("build.source.buildStatusConfig.context")
Local $sTargetUrl = $oJResp.StringOf("build.source.buildStatusConfig.targetUrl")
Local $iGitCloneDepth = $oJResp.IntOf("build.source.gitCloneDepth")
Local $iFetchSubmodules = $oJResp.IntOf("build.source.gitSubmodulesConfig.fetchSubmodules")
Local $iInsecureSsl = $oJResp.IntOf("build.source.insecureSsl")
Local $sSourceLocation = $oJResp.StringOf("build.source.location")
Local $iReportBuildStatus = $oJResp.IntOf("build.source.reportBuildStatus")
Local $sSourceIdentifier = $oJResp.StringOf("build.source.sourceIdentifier")
Local $sSourceType = $oJResp.StringOf("build.source.type")
Local $sSourceVersion = $oJResp.StringOf("build.sourceVersion")
Local $iStartTime = $oJResp.IntOf("build.startTime")
Local $iTimeoutInMinutes = $oJResp.IntOf("build.timeoutInMinutes")
Local $sVpcId = $oJResp.StringOf("build.vpcConfig.vpcId")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("build.cache.modes")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("build.cache.modes[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("build.environment.environmentVariables")
While $i < $iCount_i
    $oJResp.I = $i
    $sName = $oJResp.StringOf("build.environment.environmentVariables[i].name")
    $sV_type = $oJResp.StringOf("build.environment.environmentVariables[i].type")
    $sValue = $oJResp.StringOf("build.environment.environmentVariables[i].value")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("build.exportedEnvironmentVariables")
While $i < $iCount_i
    $oJResp.I = $i
    $sName = $oJResp.StringOf("build.exportedEnvironmentVariables[i].name")
    $sValue = $oJResp.StringOf("build.exportedEnvironmentVariables[i].value")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("build.fileSystemLocations")
While $i < $iCount_i
    $oJResp.I = $i
    $sIdentifier = $oJResp.StringOf("build.fileSystemLocations[i].identifier")
    $sLocation = $oJResp.StringOf("build.fileSystemLocations[i].location")
    $sMountOptions = $oJResp.StringOf("build.fileSystemLocations[i].mountOptions")
    $sMountPoint = $oJResp.StringOf("build.fileSystemLocations[i].mountPoint")
    $sV_type = $oJResp.StringOf("build.fileSystemLocations[i].type")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("build.phases")
While $i < $iCount_i
    $oJResp.I = $i
    $iDurationInSeconds = $oJResp.IntOf("build.phases[i].durationInSeconds")
    $iEndTime = $oJResp.IntOf("build.phases[i].endTime")
    $sPhaseStatus = $oJResp.StringOf("build.phases[i].phaseStatus")
    $sPhaseType = $oJResp.StringOf("build.phases[i].phaseType")
    $iStartTime = $oJResp.IntOf("build.phases[i].startTime")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("build.phases[i].contexts")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sMessage = $oJResp.StringOf("build.phases[i].contexts[j].message")
        $statusCode = $oJResp.StringOf("build.phases[i].contexts[j].statusCode")
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("build.reportArns")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("build.reportArns[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("build.secondaryArtifacts")
While $i < $iCount_i
    $oJResp.I = $i
    $sArtifactIdentifier = $oJResp.StringOf("build.secondaryArtifacts[i].artifactIdentifier")
    $sBucketOwnerAccess = $oJResp.StringOf("build.secondaryArtifacts[i].bucketOwnerAccess")
    $iEncryptionDisabled = $oJResp.IntOf("build.secondaryArtifacts[i].encryptionDisabled")
    $sLocation = $oJResp.StringOf("build.secondaryArtifacts[i].location")
    $sMd5sum = $oJResp.StringOf("build.secondaryArtifacts[i].md5sum")
    $iOverrideArtifactName = $oJResp.IntOf("build.secondaryArtifacts[i].overrideArtifactName")
    $sha256sum = $oJResp.StringOf("build.secondaryArtifacts[i].sha256sum")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("build.secondarySources")
While $i < $iCount_i
    $oJResp.I = $i
    $sAuthResource = $oJResp.StringOf("build.secondarySources[i].auth.resource")
    $sAuthType = $oJResp.StringOf("build.secondarySources[i].auth.type")
    $sBuildspec = $oJResp.StringOf("build.secondarySources[i].buildspec")
    $sBuildStatusConfigContext = $oJResp.StringOf("build.secondarySources[i].buildStatusConfig.context")
    $sBuildStatusConfigTargetUrl = $oJResp.StringOf("build.secondarySources[i].buildStatusConfig.targetUrl")
    $iGitCloneDepth = $oJResp.IntOf("build.secondarySources[i].gitCloneDepth")
    $iGitSubmodulesConfigFetchSubmodules = $oJResp.IntOf("build.secondarySources[i].gitSubmodulesConfig.fetchSubmodules")
    $insecureSsl = $oJResp.IntOf("build.secondarySources[i].insecureSsl")
    $sLocation = $oJResp.StringOf("build.secondarySources[i].location")
    $iReportBuildStatus = $oJResp.IntOf("build.secondarySources[i].reportBuildStatus")
    $sourceIdentifier = $oJResp.StringOf("build.secondarySources[i].sourceIdentifier")
    $sV_type = $oJResp.StringOf("build.secondarySources[i].type")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("build.secondarySourceVersions")
While $i < $iCount_i
    $oJResp.I = $i
    $sourceIdentifier = $oJResp.StringOf("build.secondarySourceVersions[i].sourceIdentifier")
    $sourceVersion = $oJResp.StringOf("build.secondarySourceVersions[i].sourceVersion")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("build.vpcConfig.securityGroupIds")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("build.vpcConfig.securityGroupIds[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("build.vpcConfig.subnets")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("build.vpcConfig.subnets[i]")
    $i = $i + 1
Wend

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