Chilkat Online Tools

GetDeploymentGroup TCL Example

AWS CodeDeploy

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 "applicationName" "string"
CkJsonObject_UpdateString $json "deploymentGroupName" "string"

# The JSON request body created by the above code:

# {
#   "applicationName": "string",
#   "deploymentGroupName": "string"
# }

CkRest_AddHeader $rest "Content-Type" "application/x-amz-json-1.1"
CkRest_AddHeader $rest "X-Amz-Target" "CodeDeploy_20141006.GetDeploymentGroup"

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 Enabled [CkJsonObject_IntOf $jResp "deploymentGroupInfo.alarmConfiguration.enabled"]
set IgnorePollAlarmFailure [CkJsonObject_IntOf $jResp "deploymentGroupInfo.alarmConfiguration.ignorePollAlarmFailure"]
set ApplicationName [CkJsonObject_stringOf $jResp "deploymentGroupInfo.applicationName"]
set AutoRollbackConfigurationEnabled [CkJsonObject_IntOf $jResp "deploymentGroupInfo.autoRollbackConfiguration.enabled"]
set ActionOnTimeout [CkJsonObject_stringOf $jResp "deploymentGroupInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout"]
set WaitTimeInMinutes [CkJsonObject_IntOf $jResp "deploymentGroupInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes"]
set Action [CkJsonObject_stringOf $jResp "deploymentGroupInfo.blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action"]
set TerminateBlueInstancesOnDeploymentSuccessAction [CkJsonObject_stringOf $jResp "deploymentGroupInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action"]
set TerminationWaitTimeInMinutes [CkJsonObject_IntOf $jResp "deploymentGroupInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes"]
set ComputePlatform [CkJsonObject_stringOf $jResp "deploymentGroupInfo.computePlatform"]
set DeploymentConfigName [CkJsonObject_stringOf $jResp "deploymentGroupInfo.deploymentConfigName"]
set DeploymentGroupId [CkJsonObject_stringOf $jResp "deploymentGroupInfo.deploymentGroupId"]
set DeploymentGroupName [CkJsonObject_stringOf $jResp "deploymentGroupInfo.deploymentGroupName"]
set DeploymentOption [CkJsonObject_stringOf $jResp "deploymentGroupInfo.deploymentStyle.deploymentOption"]
set DeploymentType [CkJsonObject_stringOf $jResp "deploymentGroupInfo.deploymentStyle.deploymentType"]
set CreateTime [CkJsonObject_IntOf $jResp "deploymentGroupInfo.lastAttemptedDeployment.createTime"]
set DeploymentId [CkJsonObject_stringOf $jResp "deploymentGroupInfo.lastAttemptedDeployment.deploymentId"]
set EndTime [CkJsonObject_IntOf $jResp "deploymentGroupInfo.lastAttemptedDeployment.endTime"]
set Status [CkJsonObject_stringOf $jResp "deploymentGroupInfo.lastAttemptedDeployment.status"]
set LastSuccessfulDeploymentCreateTime [CkJsonObject_IntOf $jResp "deploymentGroupInfo.lastSuccessfulDeployment.createTime"]
set LastSuccessfulDeploymentDeploymentId [CkJsonObject_stringOf $jResp "deploymentGroupInfo.lastSuccessfulDeployment.deploymentId"]
set LastSuccessfulDeploymentEndTime [CkJsonObject_IntOf $jResp "deploymentGroupInfo.lastSuccessfulDeployment.endTime"]
set LastSuccessfulDeploymentStatus [CkJsonObject_stringOf $jResp "deploymentGroupInfo.lastSuccessfulDeployment.status"]
set OutdatedInstancesStrategy [CkJsonObject_stringOf $jResp "deploymentGroupInfo.outdatedInstancesStrategy"]
set ServiceRoleArn [CkJsonObject_stringOf $jResp "deploymentGroupInfo.serviceRoleArn"]
set Content [CkJsonObject_stringOf $jResp "deploymentGroupInfo.targetRevision.appSpecContent.content"]
set Sha256 [CkJsonObject_stringOf $jResp "deploymentGroupInfo.targetRevision.appSpecContent.sha256"]
set CommitId [CkJsonObject_stringOf $jResp "deploymentGroupInfo.targetRevision.gitHubLocation.commitId"]
set Repository [CkJsonObject_stringOf $jResp "deploymentGroupInfo.targetRevision.gitHubLocation.repository"]
set RevisionType [CkJsonObject_stringOf $jResp "deploymentGroupInfo.targetRevision.revisionType"]
set Bucket [CkJsonObject_stringOf $jResp "deploymentGroupInfo.targetRevision.s3Location.bucket"]
set BundleType [CkJsonObject_stringOf $jResp "deploymentGroupInfo.targetRevision.s3Location.bundleType"]
set ETag [CkJsonObject_stringOf $jResp "deploymentGroupInfo.targetRevision.s3Location.eTag"]
set Key [CkJsonObject_stringOf $jResp "deploymentGroupInfo.targetRevision.s3Location.key"]
set Version [CkJsonObject_stringOf $jResp "deploymentGroupInfo.targetRevision.s3Location.version"]
set StringContent [CkJsonObject_stringOf $jResp "deploymentGroupInfo.targetRevision.string.content"]
set StringSha256 [CkJsonObject_stringOf $jResp "deploymentGroupInfo.targetRevision.string.sha256"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.alarmConfiguration.alarms"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set name [CkJsonObject_stringOf $jResp "deploymentGroupInfo.alarmConfiguration.alarms[i].name"]
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.autoRollbackConfiguration.events"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set strVal [CkJsonObject_stringOf $jResp "deploymentGroupInfo.autoRollbackConfiguration.events[i]"]
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.autoScalingGroups"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set hook [CkJsonObject_stringOf $jResp "deploymentGroupInfo.autoScalingGroups[i].hook"]
    set name [CkJsonObject_stringOf $jResp "deploymentGroupInfo.autoScalingGroups[i].name"]
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.ec2TagFilters"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set Key [CkJsonObject_stringOf $jResp "deploymentGroupInfo.ec2TagFilters[i].Key"]
    set v_Type [CkJsonObject_stringOf $jResp "deploymentGroupInfo.ec2TagFilters[i].Type"]
    set Value [CkJsonObject_stringOf $jResp "deploymentGroupInfo.ec2TagFilters[i].Value"]
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.ec2TagSet.ec2TagSetList"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.ec2TagSet.ec2TagSetList[i]"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set Key [CkJsonObject_stringOf $jResp "deploymentGroupInfo.ec2TagSet.ec2TagSetList[i][j].Key"]
        set v_Type [CkJsonObject_stringOf $jResp "deploymentGroupInfo.ec2TagSet.ec2TagSetList[i][j].Type"]
        set Value [CkJsonObject_stringOf $jResp "deploymentGroupInfo.ec2TagSet.ec2TagSetList[i][j].Value"]
        set j [expr $j + 1]
    }
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.ecsServices"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set clusterName [CkJsonObject_stringOf $jResp "deploymentGroupInfo.ecsServices[i].clusterName"]
    set serviceName [CkJsonObject_stringOf $jResp "deploymentGroupInfo.ecsServices[i].serviceName"]
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.loadBalancerInfo.elbInfoList"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set name [CkJsonObject_stringOf $jResp "deploymentGroupInfo.loadBalancerInfo.elbInfoList[i].name"]
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.loadBalancerInfo.targetGroupInfoList"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set name [CkJsonObject_stringOf $jResp "deploymentGroupInfo.loadBalancerInfo.targetGroupInfoList[i].name"]
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns[j]"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set name [CkJsonObject_stringOf $jResp "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups[j].name"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "deploymentGroupInfo.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 "deploymentGroupInfo.onPremisesInstanceTagFilters"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set Key [CkJsonObject_stringOf $jResp "deploymentGroupInfo.onPremisesInstanceTagFilters[i].Key"]
    set v_Type [CkJsonObject_stringOf $jResp "deploymentGroupInfo.onPremisesInstanceTagFilters[i].Type"]
    set Value [CkJsonObject_stringOf $jResp "deploymentGroupInfo.onPremisesInstanceTagFilters[i].Value"]
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i]"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set Key [CkJsonObject_stringOf $jResp "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Key"]
        set v_Type [CkJsonObject_stringOf $jResp "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Type"]
        set Value [CkJsonObject_stringOf $jResp "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Value"]
        set j [expr $j + 1]
    }
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.triggerConfigurations"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set triggerName [CkJsonObject_stringOf $jResp "deploymentGroupInfo.triggerConfigurations[i].triggerName"]
    set triggerTargetArn [CkJsonObject_stringOf $jResp "deploymentGroupInfo.triggerConfigurations[i].triggerTargetArn"]
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "deploymentGroupInfo.triggerConfigurations[i].triggerEvents"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "deploymentGroupInfo.triggerConfigurations[i].triggerEvents[j]"]
        set j [expr $j + 1]
    }
    set i [expr $i + 1]
}

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

# {
#   "deploymentGroupInfo": {
#     "alarmConfiguration": {
#       "alarms": [
#         {
#           "name": "string"
#         }
#       ],
#       "enabled": boolean,
#       "ignorePollAlarmFailure": boolean
#     },
#     "applicationName": "string",
#     "autoRollbackConfiguration": {
#       "enabled": boolean,
#       "events": [
#         "string"
#       ]
#     },
#     "autoScalingGroups": [
#       {
#         "hook": "string",
#         "name": "string"
#       }
#     ],
#     "blueGreenDeploymentConfiguration": {
#       "deploymentReadyOption": {
#         "actionOnTimeout": "string",
#         "waitTimeInMinutes": number
#       },
#       "greenFleetProvisioningOption": {
#         "action": "string"
#       },
#       "terminateBlueInstancesOnDeploymentSuccess": {
#         "action": "string",
#         "terminationWaitTimeInMinutes": number
#       }
#     },
#     "computePlatform": "string",
#     "deploymentConfigName": "string",
#     "deploymentGroupId": "string",
#     "deploymentGroupName": "string",
#     "deploymentStyle": {
#       "deploymentOption": "string",
#       "deploymentType": "string"
#     },
#     "ec2TagFilters": [
#       {
#         "Key": "string",
#         "Type": "string",
#         "Value": "string"
#       }
#     ],
#     "ec2TagSet": {
#       "ec2TagSetList": [
#         [
#           {
#             "Key": "string",
#             "Type": "string",
#             "Value": "string"
#           }
#         ]
#       ]
#     },
#     "ecsServices": [
#       {
#         "clusterName": "string",
#         "serviceName": "string"
#       }
#     ],
#     "lastAttemptedDeployment": {
#       "createTime": number,
#       "deploymentId": "string",
#       "endTime": number,
#       "status": "string"
#     },
#     "lastSuccessfulDeployment": {
#       "createTime": number,
#       "deploymentId": "string",
#       "endTime": number,
#       "status": "string"
#     },
#     "loadBalancerInfo": {
#       "elbInfoList": [
#         {
#           "name": "string"
#         }
#       ],
#       "targetGroupInfoList": [
#         {
#           "name": "string"
#         }
#       ],
#       "targetGroupPairInfoList": [
#         {
#           "prodTrafficRoute": {
#             "listenerArns": [
#               "string"
#             ]
#           },
#           "targetGroups": [
#             {
#               "name": "string"
#             }
#           ],
#           "testTrafficRoute": {
#             "listenerArns": [
#               "string"
#             ]
#           }
#         }
#       ]
#     },
#     "onPremisesInstanceTagFilters": [
#       {
#         "Key": "string",
#         "Type": "string",
#         "Value": "string"
#       }
#     ],
#     "onPremisesTagSet": {
#       "onPremisesTagSetList": [
#         [
#           {
#             "Key": "string",
#             "Type": "string",
#             "Value": "string"
#           }
#         ]
#       ]
#     },
#     "outdatedInstancesStrategy": "string",
#     "serviceRoleArn": "string",
#     "targetRevision": {
#       "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"
#       }
#     },
#     "triggerConfigurations": [
#       {
#         "triggerEvents": [
#           "string"
#         ],
#         "triggerName": "string",
#         "triggerTargetArn": "string"
#       }
#     ]
#   }
# }

delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp