GetDeployment TCL Example
load ./chilkat.dll
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set rest [new_CkRest]
set authAws [new_CkAuthAws]
CkAuthAws_put_AccessKey $authAws "AWS_ACCESS_KEY"
CkAuthAws_put_SecretKey $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_put_Region $authAws "us-west-2"
CkAuthAws_put_ServiceName $authAws "codedeploy"
# SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest_SetAuthAws $rest $authAws
# URL: https://codedeploy.us-west-2.amazonaws.com/
# Use the same region as specified above.
set success [CkRest_Connect $rest "codedeploy.us-west-2.amazonaws.com" 443 1 1]
if {$success != 1} then {
puts "ConnectFailReason: [CkRest_get_ConnectFailReason $rest]"
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
delete_CkAuthAws $authAws
exit
}
# 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
set json [new_CkJsonObject]
CkJsonObject_UpdateString $json "deploymentId" "string"
# The JSON request body created by the above code:
# {
# "deploymentId": "string"
# }
CkRest_AddHeader $rest "Content-Type" "application/x-amz-json-1.1"
CkRest_AddHeader $rest "X-Amz-Target" "CodeDeploy_20141006.GetDeployment"
set sbRequestBody [new_CkStringBuilder]
CkJsonObject_EmitSb $json $sbRequestBody
set sbResponseBody [new_CkStringBuilder]
set success [CkRest_FullRequestSb $rest "POST" "/" $sbRequestBody $sbResponseBody]
if {$success != 1} then {
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody
exit
}
set respStatusCode [CkRest_get_ResponseStatusCode $rest]
puts "response status code = $respStatusCode"
if {$respStatusCode != 200} then {
puts "Response Header:"
puts [CkRest_responseHeader $rest]
puts "Response Body:"
puts [CkStringBuilder_getAsString $sbResponseBody]
delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody
exit
}
set jResp [new_CkJsonObject]
CkJsonObject_LoadSb $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
set AdditionalDeploymentStatusInfo [CkJsonObject_stringOf $jResp "deploymentInfo.additionalDeploymentStatusInfo"]
set ApplicationName [CkJsonObject_stringOf $jResp "deploymentInfo.applicationName"]
set Enabled [CkJsonObject_IntOf $jResp "deploymentInfo.autoRollbackConfiguration.enabled"]
set ActionOnTimeout [CkJsonObject_stringOf $jResp "deploymentInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout"]
set WaitTimeInMinutes [CkJsonObject_IntOf $jResp "deploymentInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes"]
set Action [CkJsonObject_stringOf $jResp "deploymentInfo.blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action"]
set TerminateBlueInstancesOnDeploymentSuccessAction [CkJsonObject_stringOf $jResp "deploymentInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action"]
set TerminationWaitTimeInMinutes [CkJsonObject_IntOf $jResp "deploymentInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes"]
set CompleteTime [CkJsonObject_IntOf $jResp "deploymentInfo.completeTime"]
set ComputePlatform [CkJsonObject_stringOf $jResp "deploymentInfo.computePlatform"]
set CreateTime [CkJsonObject_IntOf $jResp "deploymentInfo.createTime"]
set Creator [CkJsonObject_stringOf $jResp "deploymentInfo.creator"]
set DeploymentConfigName [CkJsonObject_stringOf $jResp "deploymentInfo.deploymentConfigName"]
set DeploymentGroupName [CkJsonObject_stringOf $jResp "deploymentInfo.deploymentGroupName"]
set DeploymentId [CkJsonObject_stringOf $jResp "deploymentInfo.deploymentId"]
set Failed [CkJsonObject_IntOf $jResp "deploymentInfo.deploymentOverview.Failed"]
set InProgress [CkJsonObject_IntOf $jResp "deploymentInfo.deploymentOverview.InProgress"]
set Pending [CkJsonObject_IntOf $jResp "deploymentInfo.deploymentOverview.Pending"]
set Ready [CkJsonObject_IntOf $jResp "deploymentInfo.deploymentOverview.Ready"]
set Skipped [CkJsonObject_IntOf $jResp "deploymentInfo.deploymentOverview.Skipped"]
set Succeeded [CkJsonObject_IntOf $jResp "deploymentInfo.deploymentOverview.Succeeded"]
set DeploymentOption [CkJsonObject_stringOf $jResp "deploymentInfo.deploymentStyle.deploymentOption"]
set DeploymentType [CkJsonObject_stringOf $jResp "deploymentInfo.deploymentStyle.deploymentType"]
set Description [CkJsonObject_stringOf $jResp "deploymentInfo.description"]
set Code [CkJsonObject_stringOf $jResp "deploymentInfo.errorInformation.code"]
set Message [CkJsonObject_stringOf $jResp "deploymentInfo.errorInformation.message"]
set ExternalId [CkJsonObject_stringOf $jResp "deploymentInfo.externalId"]
set FileExistsBehavior [CkJsonObject_stringOf $jResp "deploymentInfo.fileExistsBehavior"]
set IgnoreApplicationStopFailures [CkJsonObject_IntOf $jResp "deploymentInfo.ignoreApplicationStopFailures"]
set InstanceTerminationWaitTimeStarted [CkJsonObject_IntOf $jResp "deploymentInfo.instanceTerminationWaitTimeStarted"]
set Content [CkJsonObject_stringOf $jResp "deploymentInfo.previousRevision.appSpecContent.content"]
set Sha256 [CkJsonObject_stringOf $jResp "deploymentInfo.previousRevision.appSpecContent.sha256"]
set CommitId [CkJsonObject_stringOf $jResp "deploymentInfo.previousRevision.gitHubLocation.commitId"]
set Repository [CkJsonObject_stringOf $jResp "deploymentInfo.previousRevision.gitHubLocation.repository"]
set RevisionType [CkJsonObject_stringOf $jResp "deploymentInfo.previousRevision.revisionType"]
set Bucket [CkJsonObject_stringOf $jResp "deploymentInfo.previousRevision.s3Location.bucket"]
set BundleType [CkJsonObject_stringOf $jResp "deploymentInfo.previousRevision.s3Location.bundleType"]
set ETag [CkJsonObject_stringOf $jResp "deploymentInfo.previousRevision.s3Location.eTag"]
set Key [CkJsonObject_stringOf $jResp "deploymentInfo.previousRevision.s3Location.key"]
set Version [CkJsonObject_stringOf $jResp "deploymentInfo.previousRevision.s3Location.version"]
set StringContent [CkJsonObject_stringOf $jResp "deploymentInfo.previousRevision.string.content"]
set StringSha256 [CkJsonObject_stringOf $jResp "deploymentInfo.previousRevision.string.sha256"]
set AutoUpdateOutdatedInstancesRootDeploymentId [CkJsonObject_stringOf $jResp "deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesRootDeploymentId"]
set AppSpecContentContent [CkJsonObject_stringOf $jResp "deploymentInfo.revision.appSpecContent.content"]
set AppSpecContentSha256 [CkJsonObject_stringOf $jResp "deploymentInfo.revision.appSpecContent.sha256"]
set GitHubLocationCommitId [CkJsonObject_stringOf $jResp "deploymentInfo.revision.gitHubLocation.commitId"]
set GitHubLocationRepository [CkJsonObject_stringOf $jResp "deploymentInfo.revision.gitHubLocation.repository"]
set RevisionRevisionType [CkJsonObject_stringOf $jResp "deploymentInfo.revision.revisionType"]
set S3LocationBucket [CkJsonObject_stringOf $jResp "deploymentInfo.revision.s3Location.bucket"]
set S3LocationBundleType [CkJsonObject_stringOf $jResp "deploymentInfo.revision.s3Location.bundleType"]
set S3LocationETag [CkJsonObject_stringOf $jResp "deploymentInfo.revision.s3Location.eTag"]
set S3LocationKey [CkJsonObject_stringOf $jResp "deploymentInfo.revision.s3Location.key"]
set S3LocationVersion [CkJsonObject_stringOf $jResp "deploymentInfo.revision.s3Location.version"]
set StringContent [CkJsonObject_stringOf $jResp "deploymentInfo.revision.string.content"]
set StringSha256 [CkJsonObject_stringOf $jResp "deploymentInfo.revision.string.sha256"]
set RollbackDeploymentId [CkJsonObject_stringOf $jResp "deploymentInfo.rollbackInfo.rollbackDeploymentId"]
set RollbackMessage [CkJsonObject_stringOf $jResp "deploymentInfo.rollbackInfo.rollbackMessage"]
set RollbackTriggeringDeploymentId [CkJsonObject_stringOf $jResp "deploymentInfo.rollbackInfo.rollbackTriggeringDeploymentId"]
set StartTime [CkJsonObject_IntOf $jResp "deploymentInfo.startTime"]
set Status [CkJsonObject_stringOf $jResp "deploymentInfo.status"]
set UpdateOutdatedInstancesOnly [CkJsonObject_IntOf $jResp "deploymentInfo.updateOutdatedInstancesOnly"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentInfo.autoRollbackConfiguration.events"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set strVal [CkJsonObject_stringOf $jResp "deploymentInfo.autoRollbackConfiguration.events[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentInfo.deploymentStatusMessages"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set strVal [CkJsonObject_stringOf $jResp "deploymentInfo.deploymentStatusMessages[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentInfo.loadBalancerInfo.elbInfoList"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set name [CkJsonObject_stringOf $jResp "deploymentInfo.loadBalancerInfo.elbInfoList[i].name"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentInfo.loadBalancerInfo.targetGroupInfoList"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set name [CkJsonObject_stringOf $jResp "deploymentInfo.loadBalancerInfo.targetGroupInfoList[i].name"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentInfo.loadBalancerInfo.targetGroupPairInfoList"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns[j]"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set name [CkJsonObject_stringOf $jResp "deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups[j].name"]
set j [expr $j + 1]
}
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set strVal [CkJsonObject_stringOf $jResp "deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns[j]"]
set j [expr $j + 1]
}
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set strVal [CkJsonObject_stringOf $jResp "deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentInfo.targetInstances.autoScalingGroups"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set strVal [CkJsonObject_stringOf $jResp "deploymentInfo.targetInstances.autoScalingGroups[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set j 0
set count_j [CkJsonObject_SizeOfArray $jResp "deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i]"]
while {$j < $count_j} {
CkJsonObject_put_J $jResp $j
set Key [CkJsonObject_stringOf $jResp "deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Key"]
set v_Type [CkJsonObject_stringOf $jResp "deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Type"]
set Value [CkJsonObject_stringOf $jResp "deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Value"]
set j [expr $j + 1]
}
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentInfo.targetInstances.tagFilters"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set Key [CkJsonObject_stringOf $jResp "deploymentInfo.targetInstances.tagFilters[i].Key"]
set v_Type [CkJsonObject_stringOf $jResp "deploymentInfo.targetInstances.tagFilters[i].Type"]
set Value [CkJsonObject_stringOf $jResp "deploymentInfo.targetInstances.tagFilters[i].Value"]
set i [expr $i + 1]
}
# A sample JSON response body parsed by the above code:
# {
# "deploymentInfo": {
# "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
# }
# }
delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp