BatchGetDeploymentGroups Swift3 Example
func chilkatTest() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let rest = CkoRest()!
var success: Bool
let authAws = CkoAuthAws()!
authAws.accessKey = "AWS_ACCESS_KEY"
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.)
authAws.region = "us-west-2"
authAws.serviceName = "codedeploy"
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.setAuthAws(authAws)
// URL: https://codedeploy.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = rest.connect("codedeploy.us-west-2.amazonaws.com", port: 443, tls: true, autoReconnect: true)
if success != true {
print("ConnectFailReason: \(rest.connectFailReason.intValue)")
print("\(rest.lastErrorText!)")
return
}
// 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
let json = CkoJsonObject()!
json.update("applicationName", value: "string")
json.update("deploymentGroupNames[0]", value: "string")
// The JSON request body created by the above code:
// {
// "applicationName": "string",
// "deploymentGroupNames": [
// "string"
// ]
// }
rest.addHeader("Content-Type", value: "application/x-amz-json-1.1")
rest.addHeader("X-Amz-Target", value: "CodeDeploy_20141006.BatchGetDeploymentGroups")
let sbRequestBody = CkoStringBuilder()!
json.emitSb(sbRequestBody)
let sbResponseBody = CkoStringBuilder()!
success = rest.fullRequestSb("POST", uriPath: "/", requestBody: sbRequestBody, responseBody: sbResponseBody)
if success != true {
print("\(rest.lastErrorText!)")
return
}
var respStatusCode: Int = rest.responseStatusCode.intValue
print("response status code = \(respStatusCode)")
if respStatusCode != 200 {
print("Response Header:")
print("\(rest.responseHeader!)")
print("Response Body:")
print("\(sbResponseBody.getAsString()!)")
return
}
let jResp = CkoJsonObject()!
jResp.loadSb(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
var Enabled: Int
var IgnorePollAlarmFailure: Int
var applicationName: String?
var autoRollbackConfigurationEnabled: Int
var ActionOnTimeout: String?
var WaitTimeInMinutes: Int
var Action: String?
var TerminateBlueInstancesOnDeploymentSuccessAction: String?
var TerminationWaitTimeInMinutes: Int
var computePlatform: String?
var deploymentConfigName: String?
var deploymentGroupId: String?
var deploymentGroupName: String?
var DeploymentOption: String?
var DeploymentType: String?
var CreateTime: Int
var DeploymentId: String?
var EndTime: Int
var Status: String?
var lastSuccessfulDeploymentCreateTime: Int
var lastSuccessfulDeploymentDeploymentId: String?
var lastSuccessfulDeploymentEndTime: Int
var lastSuccessfulDeploymentStatus: String?
var outdatedInstancesStrategy: String?
var serviceRoleArn: String?
var Content: String?
var Sha256: String?
var CommitId: String?
var Repository: String?
var RevisionType: String?
var Bucket: String?
var BundleType: String?
var ETag: String?
var Key: String?
var Version: String?
var StringContent: String?
var StringSha256: String?
var j: Int
var count_j: Int
var name: String?
var strVal: String?
var hook: String?
var v_Type: String?
var Value: String?
var k: Int
var count_k: Int
var clusterName: String?
var serviceName: String?
var triggerName: String?
var triggerTargetArn: String?
var errorMessage: String? = jResp.string(of: "errorMessage")
var i: Int = 0
var count_i: Int = jResp.size(ofArray: "deploymentGroupsInfo").intValue
while i < count_i {
jResp.i = i
Enabled = jResp.int(of: "deploymentGroupsInfo[i].alarmConfiguration.enabled").intValue
IgnorePollAlarmFailure = jResp.int(of: "deploymentGroupsInfo[i].alarmConfiguration.ignorePollAlarmFailure").intValue
applicationName = jResp.string(of: "deploymentGroupsInfo[i].applicationName")
autoRollbackConfigurationEnabled = jResp.int(of: "deploymentGroupsInfo[i].autoRollbackConfiguration.enabled").intValue
ActionOnTimeout = jResp.string(of: "deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout")
WaitTimeInMinutes = jResp.int(of: "deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes").intValue
Action = jResp.string(of: "deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action")
TerminateBlueInstancesOnDeploymentSuccessAction = jResp.string(of: "deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action")
TerminationWaitTimeInMinutes = jResp.int(of: "deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes").intValue
computePlatform = jResp.string(of: "deploymentGroupsInfo[i].computePlatform")
deploymentConfigName = jResp.string(of: "deploymentGroupsInfo[i].deploymentConfigName")
deploymentGroupId = jResp.string(of: "deploymentGroupsInfo[i].deploymentGroupId")
deploymentGroupName = jResp.string(of: "deploymentGroupsInfo[i].deploymentGroupName")
DeploymentOption = jResp.string(of: "deploymentGroupsInfo[i].deploymentStyle.deploymentOption")
DeploymentType = jResp.string(of: "deploymentGroupsInfo[i].deploymentStyle.deploymentType")
CreateTime = jResp.int(of: "deploymentGroupsInfo[i].lastAttemptedDeployment.createTime").intValue
DeploymentId = jResp.string(of: "deploymentGroupsInfo[i].lastAttemptedDeployment.deploymentId")
EndTime = jResp.int(of: "deploymentGroupsInfo[i].lastAttemptedDeployment.endTime").intValue
Status = jResp.string(of: "deploymentGroupsInfo[i].lastAttemptedDeployment.status")
lastSuccessfulDeploymentCreateTime = jResp.int(of: "deploymentGroupsInfo[i].lastSuccessfulDeployment.createTime").intValue
lastSuccessfulDeploymentDeploymentId = jResp.string(of: "deploymentGroupsInfo[i].lastSuccessfulDeployment.deploymentId")
lastSuccessfulDeploymentEndTime = jResp.int(of: "deploymentGroupsInfo[i].lastSuccessfulDeployment.endTime").intValue
lastSuccessfulDeploymentStatus = jResp.string(of: "deploymentGroupsInfo[i].lastSuccessfulDeployment.status")
outdatedInstancesStrategy = jResp.string(of: "deploymentGroupsInfo[i].outdatedInstancesStrategy")
serviceRoleArn = jResp.string(of: "deploymentGroupsInfo[i].serviceRoleArn")
Content = jResp.string(of: "deploymentGroupsInfo[i].targetRevision.appSpecContent.content")
Sha256 = jResp.string(of: "deploymentGroupsInfo[i].targetRevision.appSpecContent.sha256")
CommitId = jResp.string(of: "deploymentGroupsInfo[i].targetRevision.gitHubLocation.commitId")
Repository = jResp.string(of: "deploymentGroupsInfo[i].targetRevision.gitHubLocation.repository")
RevisionType = jResp.string(of: "deploymentGroupsInfo[i].targetRevision.revisionType")
Bucket = jResp.string(of: "deploymentGroupsInfo[i].targetRevision.s3Location.bucket")
BundleType = jResp.string(of: "deploymentGroupsInfo[i].targetRevision.s3Location.bundleType")
ETag = jResp.string(of: "deploymentGroupsInfo[i].targetRevision.s3Location.eTag")
Key = jResp.string(of: "deploymentGroupsInfo[i].targetRevision.s3Location.key")
Version = jResp.string(of: "deploymentGroupsInfo[i].targetRevision.s3Location.version")
StringContent = jResp.string(of: "deploymentGroupsInfo[i].targetRevision.string.content")
StringSha256 = jResp.string(of: "deploymentGroupsInfo[i].targetRevision.string.sha256")
j = 0
count_j = jResp.size(ofArray: "deploymentGroupsInfo[i].alarmConfiguration.alarms").intValue
while j < count_j {
jResp.j = j
name = jResp.string(of: "deploymentGroupsInfo[i].alarmConfiguration.alarms[j].name")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentGroupsInfo[i].autoRollbackConfiguration.events").intValue
while j < count_j {
jResp.j = j
strVal = jResp.string(of: "deploymentGroupsInfo[i].autoRollbackConfiguration.events[j]")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentGroupsInfo[i].autoScalingGroups").intValue
while j < count_j {
jResp.j = j
hook = jResp.string(of: "deploymentGroupsInfo[i].autoScalingGroups[j].hook")
name = jResp.string(of: "deploymentGroupsInfo[i].autoScalingGroups[j].name")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentGroupsInfo[i].ec2TagFilters").intValue
while j < count_j {
jResp.j = j
Key = jResp.string(of: "deploymentGroupsInfo[i].ec2TagFilters[j].Key")
v_Type = jResp.string(of: "deploymentGroupsInfo[i].ec2TagFilters[j].Type")
Value = jResp.string(of: "deploymentGroupsInfo[i].ec2TagFilters[j].Value")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList").intValue
while j < count_j {
jResp.j = j
k = 0
count_k = jResp.size(ofArray: "deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j]").intValue
while k < count_k {
jResp.k = k
Key = jResp.string(of: "deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j][k].Key")
v_Type = jResp.string(of: "deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j][k].Type")
Value = jResp.string(of: "deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j][k].Value")
k = k + 1
}
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentGroupsInfo[i].ecsServices").intValue
while j < count_j {
jResp.j = j
clusterName = jResp.string(of: "deploymentGroupsInfo[i].ecsServices[j].clusterName")
serviceName = jResp.string(of: "deploymentGroupsInfo[i].ecsServices[j].serviceName")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentGroupsInfo[i].loadBalancerInfo.elbInfoList").intValue
while j < count_j {
jResp.j = j
name = jResp.string(of: "deploymentGroupsInfo[i].loadBalancerInfo.elbInfoList[j].name")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentGroupsInfo[i].loadBalancerInfo.targetGroupInfoList").intValue
while j < count_j {
jResp.j = j
name = jResp.string(of: "deploymentGroupsInfo[i].loadBalancerInfo.targetGroupInfoList[j].name")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList").intValue
while j < count_j {
jResp.j = j
k = 0
count_k = jResp.size(ofArray: "deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns").intValue
while k < count_k {
jResp.k = k
strVal = jResp.string(of: "deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns[k]")
k = k + 1
}
k = 0
count_k = jResp.size(ofArray: "deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups").intValue
while k < count_k {
jResp.k = k
name = jResp.string(of: "deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups[k].name")
k = k + 1
}
k = 0
count_k = jResp.size(ofArray: "deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns").intValue
while k < count_k {
jResp.k = k
strVal = jResp.string(of: "deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns[k]")
k = k + 1
}
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentGroupsInfo[i].onPremisesInstanceTagFilters").intValue
while j < count_j {
jResp.j = j
Key = jResp.string(of: "deploymentGroupsInfo[i].onPremisesInstanceTagFilters[j].Key")
v_Type = jResp.string(of: "deploymentGroupsInfo[i].onPremisesInstanceTagFilters[j].Type")
Value = jResp.string(of: "deploymentGroupsInfo[i].onPremisesInstanceTagFilters[j].Value")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList").intValue
while j < count_j {
jResp.j = j
k = 0
count_k = jResp.size(ofArray: "deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j]").intValue
while k < count_k {
jResp.k = k
Key = jResp.string(of: "deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j][k].Key")
v_Type = jResp.string(of: "deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j][k].Type")
Value = jResp.string(of: "deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j][k].Value")
k = k + 1
}
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentGroupsInfo[i].triggerConfigurations").intValue
while j < count_j {
jResp.j = j
triggerName = jResp.string(of: "deploymentGroupsInfo[i].triggerConfigurations[j].triggerName")
triggerTargetArn = jResp.string(of: "deploymentGroupsInfo[i].triggerConfigurations[j].triggerTargetArn")
k = 0
count_k = jResp.size(ofArray: "deploymentGroupsInfo[i].triggerConfigurations[j].triggerEvents").intValue
while k < count_k {
jResp.k = k
strVal = jResp.string(of: "deploymentGroupsInfo[i].triggerConfigurations[j].triggerEvents[k]")
k = k + 1
}
j = j + 1
}
i = i + 1
}
// A sample JSON response body parsed by the above code:
// {
// "deploymentGroupsInfo": [
// {
// "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"
// }
// ]
// }
// ],
// "errorMessage": "string"
// }
}