Chilkat Online Tools

BatchGetBuilds PowerBuilder Example

AWS CodeBuild

integer li_rc
oleobject loo_Rest
integer li_Success
oleobject loo_AuthAws
oleobject loo_Json
oleobject loo_SbRequestBody
oleobject loo_SbResponseBody
integer li_RespStatusCode
oleobject loo_JResp
string ls_Arn
string ls_ArtifactIdentifier
string ls_BucketOwnerAccess
integer li_EncryptionDisabled
string ls_Location
string ls_Md5sum
integer li_OverrideArtifactName
string ls_Sha256sum
string ls_BuildBatchArn
integer li_BuildComplete
integer li_BuildNumber
string ls_BuildStatus
string ls_CacheLocation
string ls_V_Type
string ls_CurrentPhase
integer li_SessionEnabled
string ls_SessionTarget
string ls_EncryptionKey
integer li_EndTime
string ls_Certificate
string ls_ComputeType
string ls_Image
string ls_ImagePullCredentialsType
integer li_PrivilegedMode
string ls_Credential
string ls_CredentialProvider
string ls_EnvironmentType
string ls_Id
string ls_Initiator
string ls_GroupName
string ls_Status
string ls_StreamName
string ls_CloudWatchLogsArn
string ls_DeepLink
string ls_LogsGroupName
string ls_S3DeepLink
string ls_S3LogsBucketOwnerAccess
integer li_S3LogsEncryptionDisabled
string ls_S3LogsLocation
string ls_S3LogsStatus
string ls_S3LogsArn
string ls_LogsStreamName
string ls_NetworkInterfaceId
string ls_SubnetId
string ls_ProjectName
integer li_QueuedTimeoutInMinutes
string ls_ResolvedSourceVersion
string ls_ServiceRole
string ls_Resource
string ls_AuthType
string ls_Buildspec
string ls_Context
string ls_TargetUrl
integer li_GitCloneDepth
integer li_FetchSubmodules
integer li_InsecureSsl
string ls_SourceLocation
integer li_ReportBuildStatus
string ls_SourceIdentifier
string ls_SourceType
string ls_SourceVersion
integer li_StartTime
integer li_TimeoutInMinutes
string ls_VpcId
integer j
integer li_Count_j
string ls_StrVal
string ls_Name
string ls_V_type
string ls_Value
string ls_Identifier
string ls_Location
string ls_MountOptions
string ls_MountPoint
integer li_DurationInSeconds
string ls_PhaseStatus
string ls_PhaseType
integer k
integer li_Count_k
string ls_Message
string ls_StatusCode
string ls_ArtifactIdentifier
string ls_BucketOwnerAccess
integer li_EncryptionDisabled
string ls_Md5sum
integer li_OverrideArtifactName
string ls_Sha256sum
string ls_AuthResource
string ls_AuthType
string ls_Buildspec
string ls_BuildStatusConfigContext
string ls_BuildStatusConfigTargetUrl
integer li_GitCloneDepth
integer li_GitSubmodulesConfigFetchSubmodules
integer li_InsecureSsl
integer li_ReportBuildStatus
string ls_SourceIdentifier
integer i
integer li_Count_i

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

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")
if li_rc < 0 then
    destroy loo_Rest
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_AuthAws = create oleobject
li_rc = loo_AuthAws.ConnectToNewObject("Chilkat_9_5_0.AuthAws")

loo_AuthAws.AccessKey = "AWS_ACCESS_KEY"
loo_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.)
loo_AuthAws.Region = "us-west-2"
loo_AuthAws.ServiceName = "codebuild"
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loo_Rest.SetAuthAws(loo_AuthAws)

// URL: https://codebuild.us-west-2.amazonaws.com/
// Use the same region as specified above.
li_Success = loo_Rest.Connect("codebuild.us-west-2.amazonaws.com",443,1,1)
if li_Success <> 1 then
    Write-Debug "ConnectFailReason: " + string(loo_Rest.ConnectFailReason)
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_AuthAws
    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

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_Json.UpdateString("ids[0]","string")

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

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

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

loo_SbRequestBody = create oleobject
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Json.EmitSb(loo_SbRequestBody)
loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Rest.FullRequestSb("POST","/",loo_SbRequestBody,loo_SbResponseBody)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_AuthAws
    destroy loo_Json
    destroy loo_SbRequestBody
    destroy loo_SbResponseBody
    return
end if

li_RespStatusCode = loo_Rest.ResponseStatusCode
Write-Debug "response status code = " + string(li_RespStatusCode)
if li_RespStatusCode <> 200 then
    Write-Debug "Response Header:"
    Write-Debug loo_Rest.ResponseHeader
    Write-Debug "Response Body:"
    Write-Debug loo_SbResponseBody.GetAsString()
    destroy loo_Rest
    destroy loo_AuthAws
    destroy loo_Json
    destroy loo_SbRequestBody
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_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

i = 0
li_Count_i = loo_JResp.SizeOfArray("builds")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Arn = loo_JResp.StringOf("builds[i].arn")
    ls_ArtifactIdentifier = loo_JResp.StringOf("builds[i].artifacts.artifactIdentifier")
    ls_BucketOwnerAccess = loo_JResp.StringOf("builds[i].artifacts.bucketOwnerAccess")
    li_EncryptionDisabled = loo_JResp.IntOf("builds[i].artifacts.encryptionDisabled")
    ls_Location = loo_JResp.StringOf("builds[i].artifacts.location")
    ls_Md5sum = loo_JResp.StringOf("builds[i].artifacts.md5sum")
    li_OverrideArtifactName = loo_JResp.IntOf("builds[i].artifacts.overrideArtifactName")
    ls_Sha256sum = loo_JResp.StringOf("builds[i].artifacts.sha256sum")
    ls_BuildBatchArn = loo_JResp.StringOf("builds[i].buildBatchArn")
    li_BuildComplete = loo_JResp.IntOf("builds[i].buildComplete")
    li_BuildNumber = loo_JResp.IntOf("builds[i].buildNumber")
    ls_BuildStatus = loo_JResp.StringOf("builds[i].buildStatus")
    ls_CacheLocation = loo_JResp.StringOf("builds[i].cache.location")
    ls_V_Type = loo_JResp.StringOf("builds[i].cache.type")
    ls_CurrentPhase = loo_JResp.StringOf("builds[i].currentPhase")
    li_SessionEnabled = loo_JResp.IntOf("builds[i].debugSession.sessionEnabled")
    ls_SessionTarget = loo_JResp.StringOf("builds[i].debugSession.sessionTarget")
    ls_EncryptionKey = loo_JResp.StringOf("builds[i].encryptionKey")
    li_EndTime = loo_JResp.IntOf("builds[i].endTime")
    ls_Certificate = loo_JResp.StringOf("builds[i].environment.certificate")
    ls_ComputeType = loo_JResp.StringOf("builds[i].environment.computeType")
    ls_Image = loo_JResp.StringOf("builds[i].environment.image")
    ls_ImagePullCredentialsType = loo_JResp.StringOf("builds[i].environment.imagePullCredentialsType")
    li_PrivilegedMode = loo_JResp.IntOf("builds[i].environment.privilegedMode")
    ls_Credential = loo_JResp.StringOf("builds[i].environment.registryCredential.credential")
    ls_CredentialProvider = loo_JResp.StringOf("builds[i].environment.registryCredential.credentialProvider")
    ls_EnvironmentType = loo_JResp.StringOf("builds[i].environment.type")
    ls_Id = loo_JResp.StringOf("builds[i].id")
    ls_Initiator = loo_JResp.StringOf("builds[i].initiator")
    ls_GroupName = loo_JResp.StringOf("builds[i].logs.cloudWatchLogs.groupName")
    ls_Status = loo_JResp.StringOf("builds[i].logs.cloudWatchLogs.status")
    ls_StreamName = loo_JResp.StringOf("builds[i].logs.cloudWatchLogs.streamName")
    ls_CloudWatchLogsArn = loo_JResp.StringOf("builds[i].logs.cloudWatchLogsArn")
    ls_DeepLink = loo_JResp.StringOf("builds[i].logs.deepLink")
    ls_LogsGroupName = loo_JResp.StringOf("builds[i].logs.groupName")
    ls_S3DeepLink = loo_JResp.StringOf("builds[i].logs.s3DeepLink")
    ls_S3LogsBucketOwnerAccess = loo_JResp.StringOf("builds[i].logs.s3Logs.bucketOwnerAccess")
    li_S3LogsEncryptionDisabled = loo_JResp.IntOf("builds[i].logs.s3Logs.encryptionDisabled")
    ls_S3LogsLocation = loo_JResp.StringOf("builds[i].logs.s3Logs.location")
    ls_S3LogsStatus = loo_JResp.StringOf("builds[i].logs.s3Logs.status")
    ls_S3LogsArn = loo_JResp.StringOf("builds[i].logs.s3LogsArn")
    ls_LogsStreamName = loo_JResp.StringOf("builds[i].logs.streamName")
    ls_NetworkInterfaceId = loo_JResp.StringOf("builds[i].networkInterface.networkInterfaceId")
    ls_SubnetId = loo_JResp.StringOf("builds[i].networkInterface.subnetId")
    ls_ProjectName = loo_JResp.StringOf("builds[i].projectName")
    li_QueuedTimeoutInMinutes = loo_JResp.IntOf("builds[i].queuedTimeoutInMinutes")
    ls_ResolvedSourceVersion = loo_JResp.StringOf("builds[i].resolvedSourceVersion")
    ls_ServiceRole = loo_JResp.StringOf("builds[i].serviceRole")
    ls_Resource = loo_JResp.StringOf("builds[i].source.auth.resource")
    ls_AuthType = loo_JResp.StringOf("builds[i].source.auth.type")
    ls_Buildspec = loo_JResp.StringOf("builds[i].source.buildspec")
    ls_Context = loo_JResp.StringOf("builds[i].source.buildStatusConfig.context")
    ls_TargetUrl = loo_JResp.StringOf("builds[i].source.buildStatusConfig.targetUrl")
    li_GitCloneDepth = loo_JResp.IntOf("builds[i].source.gitCloneDepth")
    li_FetchSubmodules = loo_JResp.IntOf("builds[i].source.gitSubmodulesConfig.fetchSubmodules")
    li_InsecureSsl = loo_JResp.IntOf("builds[i].source.insecureSsl")
    ls_SourceLocation = loo_JResp.StringOf("builds[i].source.location")
    li_ReportBuildStatus = loo_JResp.IntOf("builds[i].source.reportBuildStatus")
    ls_SourceIdentifier = loo_JResp.StringOf("builds[i].source.sourceIdentifier")
    ls_SourceType = loo_JResp.StringOf("builds[i].source.type")
    ls_SourceVersion = loo_JResp.StringOf("builds[i].sourceVersion")
    li_StartTime = loo_JResp.IntOf("builds[i].startTime")
    li_TimeoutInMinutes = loo_JResp.IntOf("builds[i].timeoutInMinutes")
    ls_VpcId = loo_JResp.StringOf("builds[i].vpcConfig.vpcId")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("builds[i].cache.modes")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("builds[i].cache.modes[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("builds[i].environment.environmentVariables")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Name = loo_JResp.StringOf("builds[i].environment.environmentVariables[j].name")
        ls_V_type = loo_JResp.StringOf("builds[i].environment.environmentVariables[j].type")
        ls_Value = loo_JResp.StringOf("builds[i].environment.environmentVariables[j].value")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("builds[i].exportedEnvironmentVariables")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Name = loo_JResp.StringOf("builds[i].exportedEnvironmentVariables[j].name")
        ls_Value = loo_JResp.StringOf("builds[i].exportedEnvironmentVariables[j].value")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("builds[i].fileSystemLocations")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Identifier = loo_JResp.StringOf("builds[i].fileSystemLocations[j].identifier")
        ls_Location = loo_JResp.StringOf("builds[i].fileSystemLocations[j].location")
        ls_MountOptions = loo_JResp.StringOf("builds[i].fileSystemLocations[j].mountOptions")
        ls_MountPoint = loo_JResp.StringOf("builds[i].fileSystemLocations[j].mountPoint")
        ls_V_type = loo_JResp.StringOf("builds[i].fileSystemLocations[j].type")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("builds[i].phases")
    do while j < li_Count_j
        loo_JResp.J = j
        li_DurationInSeconds = loo_JResp.IntOf("builds[i].phases[j].durationInSeconds")
        li_EndTime = loo_JResp.IntOf("builds[i].phases[j].endTime")
        ls_PhaseStatus = loo_JResp.StringOf("builds[i].phases[j].phaseStatus")
        ls_PhaseType = loo_JResp.StringOf("builds[i].phases[j].phaseType")
        li_StartTime = loo_JResp.IntOf("builds[i].phases[j].startTime")
        k = 0
        li_Count_k = loo_JResp.SizeOfArray("builds[i].phases[j].contexts")
        do while k < li_Count_k
            loo_JResp.K = k
            ls_Message = loo_JResp.StringOf("builds[i].phases[j].contexts[k].message")
            ls_StatusCode = loo_JResp.StringOf("builds[i].phases[j].contexts[k].statusCode")
            k = k + 1
        loop
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("builds[i].reportArns")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("builds[i].reportArns[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("builds[i].secondaryArtifacts")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_ArtifactIdentifier = loo_JResp.StringOf("builds[i].secondaryArtifacts[j].artifactIdentifier")
        ls_BucketOwnerAccess = loo_JResp.StringOf("builds[i].secondaryArtifacts[j].bucketOwnerAccess")
        li_EncryptionDisabled = loo_JResp.IntOf("builds[i].secondaryArtifacts[j].encryptionDisabled")
        ls_Location = loo_JResp.StringOf("builds[i].secondaryArtifacts[j].location")
        ls_Md5sum = loo_JResp.StringOf("builds[i].secondaryArtifacts[j].md5sum")
        li_OverrideArtifactName = loo_JResp.IntOf("builds[i].secondaryArtifacts[j].overrideArtifactName")
        ls_Sha256sum = loo_JResp.StringOf("builds[i].secondaryArtifacts[j].sha256sum")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("builds[i].secondarySources")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_AuthResource = loo_JResp.StringOf("builds[i].secondarySources[j].auth.resource")
        ls_AuthType = loo_JResp.StringOf("builds[i].secondarySources[j].auth.type")
        ls_Buildspec = loo_JResp.StringOf("builds[i].secondarySources[j].buildspec")
        ls_BuildStatusConfigContext = loo_JResp.StringOf("builds[i].secondarySources[j].buildStatusConfig.context")
        ls_BuildStatusConfigTargetUrl = loo_JResp.StringOf("builds[i].secondarySources[j].buildStatusConfig.targetUrl")
        li_GitCloneDepth = loo_JResp.IntOf("builds[i].secondarySources[j].gitCloneDepth")
        li_GitSubmodulesConfigFetchSubmodules = loo_JResp.IntOf("builds[i].secondarySources[j].gitSubmodulesConfig.fetchSubmodules")
        li_InsecureSsl = loo_JResp.IntOf("builds[i].secondarySources[j].insecureSsl")
        ls_Location = loo_JResp.StringOf("builds[i].secondarySources[j].location")
        li_ReportBuildStatus = loo_JResp.IntOf("builds[i].secondarySources[j].reportBuildStatus")
        ls_SourceIdentifier = loo_JResp.StringOf("builds[i].secondarySources[j].sourceIdentifier")
        ls_V_type = loo_JResp.StringOf("builds[i].secondarySources[j].type")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("builds[i].secondarySourceVersions")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_SourceIdentifier = loo_JResp.StringOf("builds[i].secondarySourceVersions[j].sourceIdentifier")
        ls_SourceVersion = loo_JResp.StringOf("builds[i].secondarySourceVersions[j].sourceVersion")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("builds[i].vpcConfig.securityGroupIds")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("builds[i].vpcConfig.securityGroupIds[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("builds[i].vpcConfig.subnets")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("builds[i].vpcConfig.subnets[j]")
        j = j + 1
    loop
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("buildsNotFound")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("buildsNotFound[i]")
    i = i + 1
loop

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


destroy loo_Rest
destroy loo_AuthAws
destroy loo_Json
destroy loo_SbRequestBody
destroy loo_SbResponseBody
destroy loo_JResp