Chilkat Online Tools

BatchGetDeployments PowerBuilder Example

AWS CodeDeploy

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_AdditionalDeploymentStatusInfo
string ls_ApplicationName
integer li_Enabled
string ls_ActionOnTimeout
integer li_WaitTimeInMinutes
string ls_Action
string ls_TerminateBlueInstancesOnDeploymentSuccessAction
integer li_TerminationWaitTimeInMinutes
integer li_CompleteTime
string ls_ComputePlatform
integer li_CreateTime
string ls_Creator
string ls_DeploymentConfigName
string ls_DeploymentGroupName
string ls_DeploymentId
integer li_Failed
integer li_InProgress
integer li_Pending
integer li_Ready
integer li_Skipped
integer li_Succeeded
string ls_DeploymentOption
string ls_DeploymentType
string ls_Description
string ls_Code
string ls_Message
string ls_ExternalId
string ls_FileExistsBehavior
integer li_IgnoreApplicationStopFailures
integer li_InstanceTerminationWaitTimeStarted
string ls_Content
string ls_Sha256
string ls_CommitId
string ls_Repository
string ls_RevisionType
string ls_Bucket
string ls_BundleType
string ls_ETag
string ls_Key
string ls_Version
string ls_StringContent
string ls_StringSha256
string ls_AutoUpdateOutdatedInstancesRootDeploymentId
string ls_AppSpecContentContent
string ls_AppSpecContentSha256
string ls_GitHubLocationCommitId
string ls_GitHubLocationRepository
string ls_RevisionRevisionType
string ls_S3LocationBucket
string ls_S3LocationBundleType
string ls_S3LocationETag
string ls_S3LocationKey
string ls_S3LocationVersion
string ls_RollbackDeploymentId
string ls_RollbackMessage
string ls_RollbackTriggeringDeploymentId
integer li_StartTime
string ls_Status
integer li_UpdateOutdatedInstancesOnly
integer j
integer li_Count_j
string ls_StrVal
string ls_Name
integer k
integer li_Count_k
string ls_V_Type
string ls_Value
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 = "codedeploy"
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loo_Rest.SetAuthAws(loo_AuthAws)

// URL: https://codedeploy.us-west-2.amazonaws.com/
// Use the same region as specified above.
li_Success = loo_Rest.Connect("codedeploy.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("deploymentIds[0]","string")

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

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

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

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("deploymentsInfo")
do while i < li_Count_i
    loo_JResp.I = i
    ls_AdditionalDeploymentStatusInfo = loo_JResp.StringOf("deploymentsInfo[i].additionalDeploymentStatusInfo")
    ls_ApplicationName = loo_JResp.StringOf("deploymentsInfo[i].applicationName")
    li_Enabled = loo_JResp.IntOf("deploymentsInfo[i].autoRollbackConfiguration.enabled")
    ls_ActionOnTimeout = loo_JResp.StringOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout")
    li_WaitTimeInMinutes = loo_JResp.IntOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes")
    ls_Action = loo_JResp.StringOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action")
    ls_TerminateBlueInstancesOnDeploymentSuccessAction = loo_JResp.StringOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action")
    li_TerminationWaitTimeInMinutes = loo_JResp.IntOf("deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes")
    li_CompleteTime = loo_JResp.IntOf("deploymentsInfo[i].completeTime")
    ls_ComputePlatform = loo_JResp.StringOf("deploymentsInfo[i].computePlatform")
    li_CreateTime = loo_JResp.IntOf("deploymentsInfo[i].createTime")
    ls_Creator = loo_JResp.StringOf("deploymentsInfo[i].creator")
    ls_DeploymentConfigName = loo_JResp.StringOf("deploymentsInfo[i].deploymentConfigName")
    ls_DeploymentGroupName = loo_JResp.StringOf("deploymentsInfo[i].deploymentGroupName")
    ls_DeploymentId = loo_JResp.StringOf("deploymentsInfo[i].deploymentId")
    li_Failed = loo_JResp.IntOf("deploymentsInfo[i].deploymentOverview.Failed")
    li_InProgress = loo_JResp.IntOf("deploymentsInfo[i].deploymentOverview.InProgress")
    li_Pending = loo_JResp.IntOf("deploymentsInfo[i].deploymentOverview.Pending")
    li_Ready = loo_JResp.IntOf("deploymentsInfo[i].deploymentOverview.Ready")
    li_Skipped = loo_JResp.IntOf("deploymentsInfo[i].deploymentOverview.Skipped")
    li_Succeeded = loo_JResp.IntOf("deploymentsInfo[i].deploymentOverview.Succeeded")
    ls_DeploymentOption = loo_JResp.StringOf("deploymentsInfo[i].deploymentStyle.deploymentOption")
    ls_DeploymentType = loo_JResp.StringOf("deploymentsInfo[i].deploymentStyle.deploymentType")
    ls_Description = loo_JResp.StringOf("deploymentsInfo[i].description")
    ls_Code = loo_JResp.StringOf("deploymentsInfo[i].errorInformation.code")
    ls_Message = loo_JResp.StringOf("deploymentsInfo[i].errorInformation.message")
    ls_ExternalId = loo_JResp.StringOf("deploymentsInfo[i].externalId")
    ls_FileExistsBehavior = loo_JResp.StringOf("deploymentsInfo[i].fileExistsBehavior")
    li_IgnoreApplicationStopFailures = loo_JResp.IntOf("deploymentsInfo[i].ignoreApplicationStopFailures")
    li_InstanceTerminationWaitTimeStarted = loo_JResp.IntOf("deploymentsInfo[i].instanceTerminationWaitTimeStarted")
    ls_Content = loo_JResp.StringOf("deploymentsInfo[i].previousRevision.appSpecContent.content")
    ls_Sha256 = loo_JResp.StringOf("deploymentsInfo[i].previousRevision.appSpecContent.sha256")
    ls_CommitId = loo_JResp.StringOf("deploymentsInfo[i].previousRevision.gitHubLocation.commitId")
    ls_Repository = loo_JResp.StringOf("deploymentsInfo[i].previousRevision.gitHubLocation.repository")
    ls_RevisionType = loo_JResp.StringOf("deploymentsInfo[i].previousRevision.revisionType")
    ls_Bucket = loo_JResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.bucket")
    ls_BundleType = loo_JResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.bundleType")
    ls_ETag = loo_JResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.eTag")
    ls_Key = loo_JResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.key")
    ls_Version = loo_JResp.StringOf("deploymentsInfo[i].previousRevision.s3Location.version")
    ls_StringContent = loo_JResp.StringOf("deploymentsInfo[i].previousRevision.string.content")
    ls_StringSha256 = loo_JResp.StringOf("deploymentsInfo[i].previousRevision.string.sha256")
    ls_AutoUpdateOutdatedInstancesRootDeploymentId = loo_JResp.StringOf("deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesRootDeploymentId")
    ls_AppSpecContentContent = loo_JResp.StringOf("deploymentsInfo[i].revision.appSpecContent.content")
    ls_AppSpecContentSha256 = loo_JResp.StringOf("deploymentsInfo[i].revision.appSpecContent.sha256")
    ls_GitHubLocationCommitId = loo_JResp.StringOf("deploymentsInfo[i].revision.gitHubLocation.commitId")
    ls_GitHubLocationRepository = loo_JResp.StringOf("deploymentsInfo[i].revision.gitHubLocation.repository")
    ls_RevisionRevisionType = loo_JResp.StringOf("deploymentsInfo[i].revision.revisionType")
    ls_S3LocationBucket = loo_JResp.StringOf("deploymentsInfo[i].revision.s3Location.bucket")
    ls_S3LocationBundleType = loo_JResp.StringOf("deploymentsInfo[i].revision.s3Location.bundleType")
    ls_S3LocationETag = loo_JResp.StringOf("deploymentsInfo[i].revision.s3Location.eTag")
    ls_S3LocationKey = loo_JResp.StringOf("deploymentsInfo[i].revision.s3Location.key")
    ls_S3LocationVersion = loo_JResp.StringOf("deploymentsInfo[i].revision.s3Location.version")
    ls_StringContent = loo_JResp.StringOf("deploymentsInfo[i].revision.string.content")
    ls_StringSha256 = loo_JResp.StringOf("deploymentsInfo[i].revision.string.sha256")
    ls_RollbackDeploymentId = loo_JResp.StringOf("deploymentsInfo[i].rollbackInfo.rollbackDeploymentId")
    ls_RollbackMessage = loo_JResp.StringOf("deploymentsInfo[i].rollbackInfo.rollbackMessage")
    ls_RollbackTriggeringDeploymentId = loo_JResp.StringOf("deploymentsInfo[i].rollbackInfo.rollbackTriggeringDeploymentId")
    li_StartTime = loo_JResp.IntOf("deploymentsInfo[i].startTime")
    ls_Status = loo_JResp.StringOf("deploymentsInfo[i].status")
    li_UpdateOutdatedInstancesOnly = loo_JResp.IntOf("deploymentsInfo[i].updateOutdatedInstancesOnly")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("deploymentsInfo[i].autoRollbackConfiguration.events")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("deploymentsInfo[i].autoRollbackConfiguration.events[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("deploymentsInfo[i].deploymentStatusMessages")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("deploymentsInfo[i].deploymentStatusMessages[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.elbInfoList")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Name = loo_JResp.StringOf("deploymentsInfo[i].loadBalancerInfo.elbInfoList[j].name")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Name = loo_JResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList[j].name")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList")
    do while j < li_Count_j
        loo_JResp.J = j
        k = 0
        li_Count_k = loo_JResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns")
        do while k < li_Count_k
            loo_JResp.K = k
            ls_StrVal = loo_JResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns[k]")
            k = k + 1
        loop
        k = 0
        li_Count_k = loo_JResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups")
        do while k < li_Count_k
            loo_JResp.K = k
            ls_Name = loo_JResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups[k].name")
            k = k + 1
        loop
        k = 0
        li_Count_k = loo_JResp.SizeOfArray("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns")
        do while k < li_Count_k
            loo_JResp.K = k
            ls_StrVal = loo_JResp.StringOf("deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns[k]")
            k = k + 1
        loop
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("deploymentsInfo[i].targetInstances.autoScalingGroups")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("deploymentsInfo[i].targetInstances.autoScalingGroups[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList")
    do while j < li_Count_j
        loo_JResp.J = j
        k = 0
        li_Count_k = loo_JResp.SizeOfArray("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j]")
        do while k < li_Count_k
            loo_JResp.K = k
            ls_Key = loo_JResp.StringOf("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Key")
            ls_V_Type = loo_JResp.StringOf("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Type")
            ls_Value = loo_JResp.StringOf("deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Value")
            k = k + 1
        loop
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("deploymentsInfo[i].targetInstances.tagFilters")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Key = loo_JResp.StringOf("deploymentsInfo[i].targetInstances.tagFilters[j].Key")
        ls_V_Type = loo_JResp.StringOf("deploymentsInfo[i].targetInstances.tagFilters[j].Type")
        ls_Value = loo_JResp.StringOf("deploymentsInfo[i].targetInstances.tagFilters[j].Value")
        j = j + 1
    loop
    i = i + 1
loop

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

// {
//   "deploymentsInfo": [
//     {
//       "additionalDeploymentStatusInfo": "string",
//       "applicationName": "string",
//       "autoRollbackConfiguration": {
//         "enabled": boolean,
//         "events": [
//           "string"
//         ]
//       },
//       "blueGreenDeploymentConfiguration": {
//         "deploymentReadyOption": {
//           "actionOnTimeout": "string",
//           "waitTimeInMinutes": number
//         },
//         "greenFleetProvisioningOption": {
//           "action": "string"
//         },
//         "terminateBlueInstancesOnDeploymentSuccess": {
//           "action": "string",
//           "terminationWaitTimeInMinutes": number
//         }
//       },
//       "completeTime": number,
//       "computePlatform": "string",
//       "createTime": number,
//       "creator": "string",
//       "deploymentConfigName": "string",
//       "deploymentGroupName": "string",
//       "deploymentId": "string",
//       "deploymentOverview": {
//         "Failed": number,
//         "InProgress": number,
//         "Pending": number,
//         "Ready": number,
//         "Skipped": number,
//         "Succeeded": number
//       },
//       "deploymentStatusMessages": [
//         "string"
//       ],
//       "deploymentStyle": {
//         "deploymentOption": "string",
//         "deploymentType": "string"
//       },
//       "description": "string",
//       "errorInformation": {
//         "code": "string",
//         "message": "string"
//       },
//       "externalId": "string",
//       "fileExistsBehavior": "string",
//       "ignoreApplicationStopFailures": boolean,
//       "instanceTerminationWaitTimeStarted": boolean,
//       "loadBalancerInfo": {
//         "elbInfoList": [
//           {
//             "name": "string"
//           }
//         ],
//         "targetGroupInfoList": [
//           {
//             "name": "string"
//           }
//         ],
//         "targetGroupPairInfoList": [
//           {
//             "prodTrafficRoute": {
//               "listenerArns": [
//                 "string"
//               ]
//             },
//             "targetGroups": [
//               {
//                 "name": "string"
//               }
//             ],
//             "testTrafficRoute": {
//               "listenerArns": [
//                 "string"
//               ]
//             }
//           }
//         ]
//       },
//       "previousRevision": {
//         "appSpecContent": {
//           "content": "string",
//           "sha256": "string"
//         },
//         "gitHubLocation": {
//           "commitId": "string",
//           "repository": "string"
//         },
//         "revisionType": "string",
//         "s3Location": {
//           "bucket": "string",
//           "bundleType": "string",
//           "eTag": "string",
//           "key": "string",
//           "version": "string"
//         },
//         "string": {
//           "content": "string",
//           "sha256": "string"
//         }
//       },
//       "relatedDeployments": {
//         "autoUpdateOutdatedInstancesDeploymentIds": [
//           "string"
//         ],
//         "autoUpdateOutdatedInstancesRootDeploymentId": "string"
//       },
//       "revision": {
//         "appSpecContent": {
//           "content": "string",
//           "sha256": "string"
//         },
//         "gitHubLocation": {
//           "commitId": "string",
//           "repository": "string"
//         },
//         "revisionType": "string",
//         "s3Location": {
//           "bucket": "string",
//           "bundleType": "string",
//           "eTag": "string",
//           "key": "string",
//           "version": "string"
//         },
//         "string": {
//           "content": "string",
//           "sha256": "string"
//         }
//       },
//       "rollbackInfo": {
//         "rollbackDeploymentId": "string",
//         "rollbackMessage": "string",
//         "rollbackTriggeringDeploymentId": "string"
//       },
//       "startTime": number,
//       "status": "string",
//       "targetInstances": {
//         "autoScalingGroups": [
//           "string"
//         ],
//         "ec2TagSet": {
//           "ec2TagSetList": [
//             [
//               {
//                 "Key": "string",
//                 "Type": "string",
//                 "Value": "string"
//               }
//             ]
//           ]
//         },
//         "tagFilters": [
//           {
//             "Key": "string",
//             "Type": "string",
//             "Value": "string"
//           }
//         ]
//       },
//       "updateOutdatedInstancesOnly": boolean
//     }
//   ]
// }


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