GetDeployment 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("deploymentId", value: "string")
// The JSON request body created by the above code:
// {
// "deploymentId": "string"
// }
rest.addHeader("Content-Type", value: "application/x-amz-json-1.1")
rest.addHeader("X-Amz-Target", value: "CodeDeploy_20141006.GetDeployment")
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 strVal: String?
var name: String?
var j: Int
var count_j: Int
var v_Type: String?
var Value: String?
var AdditionalDeploymentStatusInfo: String? = jResp.string(of: "deploymentInfo.additionalDeploymentStatusInfo")
var ApplicationName: String? = jResp.string(of: "deploymentInfo.applicationName")
var Enabled: Int = jResp.int(of: "deploymentInfo.autoRollbackConfiguration.enabled").intValue
var ActionOnTimeout: String? = jResp.string(of: "deploymentInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout")
var WaitTimeInMinutes: Int = jResp.int(of: "deploymentInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes").intValue
var Action: String? = jResp.string(of: "deploymentInfo.blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action")
var TerminateBlueInstancesOnDeploymentSuccessAction: String? = jResp.string(of: "deploymentInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action")
var TerminationWaitTimeInMinutes: Int = jResp.int(of: "deploymentInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes").intValue
var CompleteTime: Int = jResp.int(of: "deploymentInfo.completeTime").intValue
var ComputePlatform: String? = jResp.string(of: "deploymentInfo.computePlatform")
var CreateTime: Int = jResp.int(of: "deploymentInfo.createTime").intValue
var Creator: String? = jResp.string(of: "deploymentInfo.creator")
var DeploymentConfigName: String? = jResp.string(of: "deploymentInfo.deploymentConfigName")
var DeploymentGroupName: String? = jResp.string(of: "deploymentInfo.deploymentGroupName")
var DeploymentId: String? = jResp.string(of: "deploymentInfo.deploymentId")
var Failed: Int = jResp.int(of: "deploymentInfo.deploymentOverview.Failed").intValue
var InProgress: Int = jResp.int(of: "deploymentInfo.deploymentOverview.InProgress").intValue
var Pending: Int = jResp.int(of: "deploymentInfo.deploymentOverview.Pending").intValue
var Ready: Int = jResp.int(of: "deploymentInfo.deploymentOverview.Ready").intValue
var Skipped: Int = jResp.int(of: "deploymentInfo.deploymentOverview.Skipped").intValue
var Succeeded: Int = jResp.int(of: "deploymentInfo.deploymentOverview.Succeeded").intValue
var DeploymentOption: String? = jResp.string(of: "deploymentInfo.deploymentStyle.deploymentOption")
var DeploymentType: String? = jResp.string(of: "deploymentInfo.deploymentStyle.deploymentType")
var Description: String? = jResp.string(of: "deploymentInfo.description")
var Code: String? = jResp.string(of: "deploymentInfo.errorInformation.code")
var Message: String? = jResp.string(of: "deploymentInfo.errorInformation.message")
var ExternalId: String? = jResp.string(of: "deploymentInfo.externalId")
var FileExistsBehavior: String? = jResp.string(of: "deploymentInfo.fileExistsBehavior")
var IgnoreApplicationStopFailures: Int = jResp.int(of: "deploymentInfo.ignoreApplicationStopFailures").intValue
var InstanceTerminationWaitTimeStarted: Int = jResp.int(of: "deploymentInfo.instanceTerminationWaitTimeStarted").intValue
var Content: String? = jResp.string(of: "deploymentInfo.previousRevision.appSpecContent.content")
var Sha256: String? = jResp.string(of: "deploymentInfo.previousRevision.appSpecContent.sha256")
var CommitId: String? = jResp.string(of: "deploymentInfo.previousRevision.gitHubLocation.commitId")
var Repository: String? = jResp.string(of: "deploymentInfo.previousRevision.gitHubLocation.repository")
var RevisionType: String? = jResp.string(of: "deploymentInfo.previousRevision.revisionType")
var Bucket: String? = jResp.string(of: "deploymentInfo.previousRevision.s3Location.bucket")
var BundleType: String? = jResp.string(of: "deploymentInfo.previousRevision.s3Location.bundleType")
var ETag: String? = jResp.string(of: "deploymentInfo.previousRevision.s3Location.eTag")
var Key: String? = jResp.string(of: "deploymentInfo.previousRevision.s3Location.key")
var Version: String? = jResp.string(of: "deploymentInfo.previousRevision.s3Location.version")
var StringContent: String? = jResp.string(of: "deploymentInfo.previousRevision.string.content")
var StringSha256: String? = jResp.string(of: "deploymentInfo.previousRevision.string.sha256")
var AutoUpdateOutdatedInstancesRootDeploymentId: String? = jResp.string(of: "deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesRootDeploymentId")
var AppSpecContentContent: String? = jResp.string(of: "deploymentInfo.revision.appSpecContent.content")
var AppSpecContentSha256: String? = jResp.string(of: "deploymentInfo.revision.appSpecContent.sha256")
var GitHubLocationCommitId: String? = jResp.string(of: "deploymentInfo.revision.gitHubLocation.commitId")
var GitHubLocationRepository: String? = jResp.string(of: "deploymentInfo.revision.gitHubLocation.repository")
var RevisionRevisionType: String? = jResp.string(of: "deploymentInfo.revision.revisionType")
var S3LocationBucket: String? = jResp.string(of: "deploymentInfo.revision.s3Location.bucket")
var S3LocationBundleType: String? = jResp.string(of: "deploymentInfo.revision.s3Location.bundleType")
var S3LocationETag: String? = jResp.string(of: "deploymentInfo.revision.s3Location.eTag")
var S3LocationKey: String? = jResp.string(of: "deploymentInfo.revision.s3Location.key")
var S3LocationVersion: String? = jResp.string(of: "deploymentInfo.revision.s3Location.version")
StringContent = jResp.string(of: "deploymentInfo.revision.string.content")
StringSha256 = jResp.string(of: "deploymentInfo.revision.string.sha256")
var RollbackDeploymentId: String? = jResp.string(of: "deploymentInfo.rollbackInfo.rollbackDeploymentId")
var RollbackMessage: String? = jResp.string(of: "deploymentInfo.rollbackInfo.rollbackMessage")
var RollbackTriggeringDeploymentId: String? = jResp.string(of: "deploymentInfo.rollbackInfo.rollbackTriggeringDeploymentId")
var StartTime: Int = jResp.int(of: "deploymentInfo.startTime").intValue
var Status: String? = jResp.string(of: "deploymentInfo.status")
var UpdateOutdatedInstancesOnly: Int = jResp.int(of: "deploymentInfo.updateOutdatedInstancesOnly").intValue
var i: Int = 0
var count_i: Int = jResp.size(ofArray: "deploymentInfo.autoRollbackConfiguration.events").intValue
while i < count_i {
jResp.i = i
strVal = jResp.string(of: "deploymentInfo.autoRollbackConfiguration.events[i]")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentInfo.deploymentStatusMessages").intValue
while i < count_i {
jResp.i = i
strVal = jResp.string(of: "deploymentInfo.deploymentStatusMessages[i]")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentInfo.loadBalancerInfo.elbInfoList").intValue
while i < count_i {
jResp.i = i
name = jResp.string(of: "deploymentInfo.loadBalancerInfo.elbInfoList[i].name")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentInfo.loadBalancerInfo.targetGroupInfoList").intValue
while i < count_i {
jResp.i = i
name = jResp.string(of: "deploymentInfo.loadBalancerInfo.targetGroupInfoList[i].name")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentInfo.loadBalancerInfo.targetGroupPairInfoList").intValue
while i < count_i {
jResp.i = i
j = 0
count_j = jResp.size(ofArray: "deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns").intValue
while j < count_j {
jResp.j = j
strVal = jResp.string(of: "deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns[j]")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups").intValue
while j < count_j {
jResp.j = j
name = jResp.string(of: "deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups[j].name")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns").intValue
while j < count_j {
jResp.j = j
strVal = jResp.string(of: "deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns[j]")
j = j + 1
}
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds").intValue
while i < count_i {
jResp.i = i
strVal = jResp.string(of: "deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds[i]")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentInfo.targetInstances.autoScalingGroups").intValue
while i < count_i {
jResp.i = i
strVal = jResp.string(of: "deploymentInfo.targetInstances.autoScalingGroups[i]")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList").intValue
while i < count_i {
jResp.i = i
j = 0
count_j = jResp.size(ofArray: "deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i]").intValue
while j < count_j {
jResp.j = j
Key = jResp.string(of: "deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Key")
v_Type = jResp.string(of: "deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Type")
Value = jResp.string(of: "deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Value")
j = j + 1
}
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "deploymentInfo.targetInstances.tagFilters").intValue
while i < count_i {
jResp.i = i
Key = jResp.string(of: "deploymentInfo.targetInstances.tagFilters[i].Key")
v_Type = jResp.string(of: "deploymentInfo.targetInstances.tagFilters[i].Type")
Value = jResp.string(of: "deploymentInfo.targetInstances.tagFilters[i].Value")
i = 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
// }
// }
}