GetDeploymentGroup 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("deploymentGroupName", value: "string")
// The JSON request body created by the above code:
// {
// "applicationName": "string",
// "deploymentGroupName": "string"
// }
rest.addHeader("Content-Type", value: "application/x-amz-json-1.1")
rest.addHeader("X-Amz-Target", value: "CodeDeploy_20141006.GetDeploymentGroup")
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 name: String?
var strVal: String?
var hook: String?
var v_Type: String?
var Value: String?
var j: Int
var count_j: Int
var clusterName: String?
var serviceName: String?
var triggerName: String?
var triggerTargetArn: String?
var Enabled: Int = jResp.int(of: "deploymentGroupInfo.alarmConfiguration.enabled").intValue
var IgnorePollAlarmFailure: Int = jResp.int(of: "deploymentGroupInfo.alarmConfiguration.ignorePollAlarmFailure").intValue
var ApplicationName: String? = jResp.string(of: "deploymentGroupInfo.applicationName")
var AutoRollbackConfigurationEnabled: Int = jResp.int(of: "deploymentGroupInfo.autoRollbackConfiguration.enabled").intValue
var ActionOnTimeout: String? = jResp.string(of: "deploymentGroupInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout")
var WaitTimeInMinutes: Int = jResp.int(of: "deploymentGroupInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes").intValue
var Action: String? = jResp.string(of: "deploymentGroupInfo.blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action")
var TerminateBlueInstancesOnDeploymentSuccessAction: String? = jResp.string(of: "deploymentGroupInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action")
var TerminationWaitTimeInMinutes: Int = jResp.int(of: "deploymentGroupInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes").intValue
var ComputePlatform: String? = jResp.string(of: "deploymentGroupInfo.computePlatform")
var DeploymentConfigName: String? = jResp.string(of: "deploymentGroupInfo.deploymentConfigName")
var DeploymentGroupId: String? = jResp.string(of: "deploymentGroupInfo.deploymentGroupId")
var DeploymentGroupName: String? = jResp.string(of: "deploymentGroupInfo.deploymentGroupName")
var DeploymentOption: String? = jResp.string(of: "deploymentGroupInfo.deploymentStyle.deploymentOption")
var DeploymentType: String? = jResp.string(of: "deploymentGroupInfo.deploymentStyle.deploymentType")
var CreateTime: Int = jResp.int(of: "deploymentGroupInfo.lastAttemptedDeployment.createTime").intValue
var DeploymentId: String? = jResp.string(of: "deploymentGroupInfo.lastAttemptedDeployment.deploymentId")
var EndTime: Int = jResp.int(of: "deploymentGroupInfo.lastAttemptedDeployment.endTime").intValue
var Status: String? = jResp.string(of: "deploymentGroupInfo.lastAttemptedDeployment.status")
var LastSuccessfulDeploymentCreateTime: Int = jResp.int(of: "deploymentGroupInfo.lastSuccessfulDeployment.createTime").intValue
var LastSuccessfulDeploymentDeploymentId: String? = jResp.string(of: "deploymentGroupInfo.lastSuccessfulDeployment.deploymentId")
var LastSuccessfulDeploymentEndTime: Int = jResp.int(of: "deploymentGroupInfo.lastSuccessfulDeployment.endTime").intValue
var LastSuccessfulDeploymentStatus: String? = jResp.string(of: "deploymentGroupInfo.lastSuccessfulDeployment.status")
var OutdatedInstancesStrategy: String? = jResp.string(of: "deploymentGroupInfo.outdatedInstancesStrategy")
var ServiceRoleArn: String? = jResp.string(of: "deploymentGroupInfo.serviceRoleArn")
var Content: String? = jResp.string(of: "deploymentGroupInfo.targetRevision.appSpecContent.content")
var Sha256: String? = jResp.string(of: "deploymentGroupInfo.targetRevision.appSpecContent.sha256")
var CommitId: String? = jResp.string(of: "deploymentGroupInfo.targetRevision.gitHubLocation.commitId")
var Repository: String? = jResp.string(of: "deploymentGroupInfo.targetRevision.gitHubLocation.repository")
var RevisionType: String? = jResp.string(of: "deploymentGroupInfo.targetRevision.revisionType")
var Bucket: String? = jResp.string(of: "deploymentGroupInfo.targetRevision.s3Location.bucket")
var BundleType: String? = jResp.string(of: "deploymentGroupInfo.targetRevision.s3Location.bundleType")
var ETag: String? = jResp.string(of: "deploymentGroupInfo.targetRevision.s3Location.eTag")
var Key: String? = jResp.string(of: "deploymentGroupInfo.targetRevision.s3Location.key")
var Version: String? = jResp.string(of: "deploymentGroupInfo.targetRevision.s3Location.version")
var StringContent: String? = jResp.string(of: "deploymentGroupInfo.targetRevision.string.content")
var StringSha256: String? = jResp.string(of: "deploymentGroupInfo.targetRevision.string.sha256")
var i: Int = 0
var count_i: Int = jResp.size(ofArray: "deploymentGroupInfo.alarmConfiguration.alarms").intValue
while i < count_i {
jResp.i = i
name = jResp.string(of: "deploymentGroupInfo.alarmConfiguration.alarms[i].name")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentGroupInfo.autoRollbackConfiguration.events").intValue
while i < count_i {
jResp.i = i
strVal = jResp.string(of: "deploymentGroupInfo.autoRollbackConfiguration.events[i]")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentGroupInfo.autoScalingGroups").intValue
while i < count_i {
jResp.i = i
hook = jResp.string(of: "deploymentGroupInfo.autoScalingGroups[i].hook")
name = jResp.string(of: "deploymentGroupInfo.autoScalingGroups[i].name")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentGroupInfo.ec2TagFilters").intValue
while i < count_i {
jResp.i = i
Key = jResp.string(of: "deploymentGroupInfo.ec2TagFilters[i].Key")
v_Type = jResp.string(of: "deploymentGroupInfo.ec2TagFilters[i].Type")
Value = jResp.string(of: "deploymentGroupInfo.ec2TagFilters[i].Value")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentGroupInfo.ec2TagSet.ec2TagSetList").intValue
while i < count_i {
jResp.i = i
j = 0
count_j = jResp.size(ofArray: "deploymentGroupInfo.ec2TagSet.ec2TagSetList[i]").intValue
while j < count_j {
jResp.j = j
Key = jResp.string(of: "deploymentGroupInfo.ec2TagSet.ec2TagSetList[i][j].Key")
v_Type = jResp.string(of: "deploymentGroupInfo.ec2TagSet.ec2TagSetList[i][j].Type")
Value = jResp.string(of: "deploymentGroupInfo.ec2TagSet.ec2TagSetList[i][j].Value")
j = j + 1
}
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentGroupInfo.ecsServices").intValue
while i < count_i {
jResp.i = i
clusterName = jResp.string(of: "deploymentGroupInfo.ecsServices[i].clusterName")
serviceName = jResp.string(of: "deploymentGroupInfo.ecsServices[i].serviceName")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentGroupInfo.loadBalancerInfo.elbInfoList").intValue
while i < count_i {
jResp.i = i
name = jResp.string(of: "deploymentGroupInfo.loadBalancerInfo.elbInfoList[i].name")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentGroupInfo.loadBalancerInfo.targetGroupInfoList").intValue
while i < count_i {
jResp.i = i
name = jResp.string(of: "deploymentGroupInfo.loadBalancerInfo.targetGroupInfoList[i].name")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList").intValue
while i < count_i {
jResp.i = i
j = 0
count_j = jResp.size(ofArray: "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns").intValue
while j < count_j {
jResp.j = j
strVal = jResp.string(of: "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns[j]")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups").intValue
while j < count_j {
jResp.j = j
name = jResp.string(of: "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups[j].name")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns").intValue
while j < count_j {
jResp.j = j
strVal = jResp.string(of: "deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns[j]")
j = j + 1
}
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentGroupInfo.onPremisesInstanceTagFilters").intValue
while i < count_i {
jResp.i = i
Key = jResp.string(of: "deploymentGroupInfo.onPremisesInstanceTagFilters[i].Key")
v_Type = jResp.string(of: "deploymentGroupInfo.onPremisesInstanceTagFilters[i].Type")
Value = jResp.string(of: "deploymentGroupInfo.onPremisesInstanceTagFilters[i].Value")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList").intValue
while i < count_i {
jResp.i = i
j = 0
count_j = jResp.size(ofArray: "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i]").intValue
while j < count_j {
jResp.j = j
Key = jResp.string(of: "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Key")
v_Type = jResp.string(of: "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Type")
Value = jResp.string(of: "deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Value")
j = j + 1
}
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentGroupInfo.triggerConfigurations").intValue
while i < count_i {
jResp.i = i
triggerName = jResp.string(of: "deploymentGroupInfo.triggerConfigurations[i].triggerName")
triggerTargetArn = jResp.string(of: "deploymentGroupInfo.triggerConfigurations[i].triggerTargetArn")
j = 0
count_j = jResp.size(ofArray: "deploymentGroupInfo.triggerConfigurations[i].triggerEvents").intValue
while j < count_j {
jResp.j = j
strVal = jResp.string(of: "deploymentGroupInfo.triggerConfigurations[i].triggerEvents[j]")
j = j + 1
}
i = 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"
// }
// ]
// }
// }
}