BatchGetDeployments PureBasic Example
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkRest.pb"
IncludeFile "CkAuthAws.pb"
Procedure ChilkatExample()
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
rest.i = CkRest::ckCreate()
If rest.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
authAws.i = CkAuthAws::ckCreate()
If authAws.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkAuthAws::setCkAccessKey(authAws, "AWS_ACCESS_KEY")
CkAuthAws::setCkSecretKey(authAws, "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.)
CkAuthAws::setCkRegion(authAws, "us-west-2")
CkAuthAws::setCkServiceName(authAws, "codedeploy")
; SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest::ckSetAuthAws(rest,authAws)
; URL: https://codedeploy.us-west-2.amazonaws.com/
; Use the same region as specified above.
success = CkRest::ckConnect(rest,"codedeploy.us-west-2.amazonaws.com",443,1,1)
If success <> 1
Debug "ConnectFailReason: " + Str(CkRest::ckConnectFailReason(rest))
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
CkAuthAws::ckDispose(authAws)
ProcedureReturn
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
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckUpdateString(json,"deploymentIds[0]","string")
; The JSON request body created by the above code:
; {
; "deploymentIds": [
; "string"
; ]
; }
CkRest::ckAddHeader(rest,"Content-Type","application/x-amz-json-1.1")
CkRest::ckAddHeader(rest,"X-Amz-Target","CodeDeploy_20141006.BatchGetDeployments")
sbRequestBody.i = CkStringBuilder::ckCreate()
If sbRequestBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckEmitSb(json,sbRequestBody)
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkRest::ckFullRequestSb(rest,"POST","/",sbRequestBody,sbResponseBody)
If success <> 1
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
CkAuthAws::ckDispose(authAws)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
CkStringBuilder::ckDispose(sbResponseBody)
ProcedureReturn
EndIf
respStatusCode.i = CkRest::ckResponseStatusCode(rest)
Debug "response status code = " + Str(respStatusCode)
If respStatusCode <> 200
Debug "Response Header:"
Debug CkRest::ckResponseHeader(rest)
Debug "Response Body:"
Debug CkStringBuilder::ckGetAsString(sbResponseBody)
CkRest::ckDispose(rest)
CkAuthAws::ckDispose(authAws)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
CkStringBuilder::ckDispose(sbResponseBody)
ProcedureReturn
EndIf
jResp.i = CkJsonObject::ckCreate()
If jResp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(jResp,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
additionalDeploymentStatusInfo.s
applicationName.s
Enabled.i
ActionOnTimeout.s
WaitTimeInMinutes.i
Action.s
TerminateBlueInstancesOnDeploymentSuccessAction.s
TerminationWaitTimeInMinutes.i
completeTime.i
computePlatform.s
createTime.i
creator.s
deploymentConfigName.s
deploymentGroupName.s
deploymentId.s
Failed.i
InProgress.i
Pending.i
Ready.i
Skipped.i
Succeeded.i
DeploymentOption.s
DeploymentType.s
description.s
Code.s
Message.s
externalId.s
fileExistsBehavior.s
ignoreApplicationStopFailures.i
instanceTerminationWaitTimeStarted.i
Content.s
Sha256.s
CommitId.s
Repository.s
RevisionType.s
Bucket.s
BundleType.s
ETag.s
Key.s
Version.s
StringContent.s
StringSha256.s
AutoUpdateOutdatedInstancesRootDeploymentId.s
AppSpecContentContent.s
AppSpecContentSha256.s
GitHubLocationCommitId.s
GitHubLocationRepository.s
revisionRevisionType.s
S3LocationBucket.s
S3LocationBundleType.s
S3LocationETag.s
S3LocationKey.s
S3LocationVersion.s
RollbackDeploymentId.s
RollbackMessage.s
RollbackTriggeringDeploymentId.s
startTime.i
status.s
updateOutdatedInstancesOnly.i
j.i
count_j.i
strVal.s
name.s
k.i
count_k.i
v_Type.s
Value.s
i.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(jResp,"deploymentsInfo")
While i < count_i
CkJsonObject::setCkI(jResp, i)
additionalDeploymentStatusInfo = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].additionalDeploymentStatusInfo")
applicationName = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].applicationName")
Enabled = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].autoRollbackConfiguration.enabled")
ActionOnTimeout = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout")
WaitTimeInMinutes = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes")
Action = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action")
TerminateBlueInstancesOnDeploymentSuccessAction = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action")
TerminationWaitTimeInMinutes = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes")
completeTime = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].completeTime")
computePlatform = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].computePlatform")
createTime = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].createTime")
creator = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].creator")
deploymentConfigName = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].deploymentConfigName")
deploymentGroupName = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].deploymentGroupName")
deploymentId = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].deploymentId")
Failed = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].deploymentOverview.Failed")
InProgress = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].deploymentOverview.InProgress")
Pending = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].deploymentOverview.Pending")
Ready = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].deploymentOverview.Ready")
Skipped = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].deploymentOverview.Skipped")
Succeeded = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].deploymentOverview.Succeeded")
DeploymentOption = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].deploymentStyle.deploymentOption")
DeploymentType = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].deploymentStyle.deploymentType")
description = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].description")
Code = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].errorInformation.code")
Message = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].errorInformation.message")
externalId = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].externalId")
fileExistsBehavior = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].fileExistsBehavior")
ignoreApplicationStopFailures = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].ignoreApplicationStopFailures")
instanceTerminationWaitTimeStarted = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].instanceTerminationWaitTimeStarted")
Content = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].previousRevision.appSpecContent.content")
Sha256 = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].previousRevision.appSpecContent.sha256")
CommitId = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].previousRevision.gitHubLocation.commitId")
Repository = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].previousRevision.gitHubLocation.repository")
RevisionType = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].previousRevision.revisionType")
Bucket = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].previousRevision.s3Location.bucket")
BundleType = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].previousRevision.s3Location.bundleType")
ETag = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].previousRevision.s3Location.eTag")
Key = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].previousRevision.s3Location.key")
Version = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].previousRevision.s3Location.version")
StringContent = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].previousRevision.string.content")
StringSha256 = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].previousRevision.string.sha256")
AutoUpdateOutdatedInstancesRootDeploymentId = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesRootDeploymentId")
AppSpecContentContent = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].revision.appSpecContent.content")
AppSpecContentSha256 = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].revision.appSpecContent.sha256")
GitHubLocationCommitId = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].revision.gitHubLocation.commitId")
GitHubLocationRepository = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].revision.gitHubLocation.repository")
revisionRevisionType = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].revision.revisionType")
S3LocationBucket = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].revision.s3Location.bucket")
S3LocationBundleType = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].revision.s3Location.bundleType")
S3LocationETag = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].revision.s3Location.eTag")
S3LocationKey = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].revision.s3Location.key")
S3LocationVersion = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].revision.s3Location.version")
StringContent = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].revision.string.content")
StringSha256 = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].revision.string.sha256")
RollbackDeploymentId = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].rollbackInfo.rollbackDeploymentId")
RollbackMessage = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].rollbackInfo.rollbackMessage")
RollbackTriggeringDeploymentId = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].rollbackInfo.rollbackTriggeringDeploymentId")
startTime = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].startTime")
status = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].status")
updateOutdatedInstancesOnly = CkJsonObject::ckIntOf(jResp,"deploymentsInfo[i].updateOutdatedInstancesOnly")
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"deploymentsInfo[i].autoRollbackConfiguration.events")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
strVal = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].autoRollbackConfiguration.events[j]")
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"deploymentsInfo[i].deploymentStatusMessages")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
strVal = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].deploymentStatusMessages[j]")
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"deploymentsInfo[i].loadBalancerInfo.elbInfoList")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
name = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].loadBalancerInfo.elbInfoList[j].name")
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
name = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList[j].name")
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
k = 0
count_k = CkJsonObject::ckSizeOfArray(jResp,"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns")
While k < count_k
CkJsonObject::setCkK(jResp, k)
strVal = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns[k]")
k = k + 1
Wend
k = 0
count_k = CkJsonObject::ckSizeOfArray(jResp,"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups")
While k < count_k
CkJsonObject::setCkK(jResp, k)
name = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups[k].name")
k = k + 1
Wend
k = 0
count_k = CkJsonObject::ckSizeOfArray(jResp,"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns")
While k < count_k
CkJsonObject::setCkK(jResp, k)
strVal = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns[k]")
k = k + 1
Wend
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
strVal = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds[j]")
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"deploymentsInfo[i].targetInstances.autoScalingGroups")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
strVal = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].targetInstances.autoScalingGroups[j]")
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
k = 0
count_k = CkJsonObject::ckSizeOfArray(jResp,"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j]")
While k < count_k
CkJsonObject::setCkK(jResp, k)
Key = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Key")
v_Type = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Type")
Value = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Value")
k = k + 1
Wend
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"deploymentsInfo[i].targetInstances.tagFilters")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
Key = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].targetInstances.tagFilters[j].Key")
v_Type = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].targetInstances.tagFilters[j].Type")
Value = CkJsonObject::ckStringOf(jResp,"deploymentsInfo[i].targetInstances.tagFilters[j].Value")
j = j + 1
Wend
i = i + 1
Wend
; 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
; }
; ]
; }
CkRest::ckDispose(rest)
CkAuthAws::ckDispose(authAws)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndProcedure