GetDeployment Objective-C Example
#import <CkoRest.h>
#import <CkoAuthAws.h>
#import <CkoJsonObject.h>
#import <CkoStringBuilder.h>
#import <NSString.h>
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoRest *rest = [[CkoRest alloc] init];
BOOL success;
CkoAuthAws *authAws = [[CkoAuthAws alloc] init];
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: [NSNumber numberWithInt: 443] tls: YES autoReconnect: YES];
if (success != YES) {
NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
NSLog(@"%@",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
CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"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"];
CkoStringBuilder *sbRequestBody = [[CkoStringBuilder alloc] init];
[json EmitSb: sbRequestBody];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestSb: @"POST" uriPath: @"/" requestBody: sbRequestBody responseBody: sbResponseBody];
if (success != YES) {
NSLog(@"%@",rest.LastErrorText);
return;
}
int respStatusCode = [rest.ResponseStatusCode intValue];
NSLog(@"%@%d",@"response status code = ",respStatusCode);
if (respStatusCode != 200) {
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",rest.ResponseHeader);
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[sbResponseBody GetAsString]);
return;
}
CkoJsonObject *jResp = [[CkoJsonObject alloc] init];
[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
NSString *strVal = 0;
NSString *name = 0;
int j;
int count_j;
NSString *v_Type = 0;
NSString *Value = 0;
NSString *AdditionalDeploymentStatusInfo = [jResp StringOf: @"deploymentInfo.additionalDeploymentStatusInfo"];
NSString *ApplicationName = [jResp StringOf: @"deploymentInfo.applicationName"];
int Enabled = [[jResp IntOf: @"deploymentInfo.autoRollbackConfiguration.enabled"] intValue];
NSString *ActionOnTimeout = [jResp StringOf: @"deploymentInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout"];
int WaitTimeInMinutes = [[jResp IntOf: @"deploymentInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes"] intValue];
NSString *Action = [jResp StringOf: @"deploymentInfo.blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action"];
NSString *TerminateBlueInstancesOnDeploymentSuccessAction = [jResp StringOf: @"deploymentInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action"];
int TerminationWaitTimeInMinutes = [[jResp IntOf: @"deploymentInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes"] intValue];
int CompleteTime = [[jResp IntOf: @"deploymentInfo.completeTime"] intValue];
NSString *ComputePlatform = [jResp StringOf: @"deploymentInfo.computePlatform"];
int CreateTime = [[jResp IntOf: @"deploymentInfo.createTime"] intValue];
NSString *Creator = [jResp StringOf: @"deploymentInfo.creator"];
NSString *DeploymentConfigName = [jResp StringOf: @"deploymentInfo.deploymentConfigName"];
NSString *DeploymentGroupName = [jResp StringOf: @"deploymentInfo.deploymentGroupName"];
NSString *DeploymentId = [jResp StringOf: @"deploymentInfo.deploymentId"];
int Failed = [[jResp IntOf: @"deploymentInfo.deploymentOverview.Failed"] intValue];
int InProgress = [[jResp IntOf: @"deploymentInfo.deploymentOverview.InProgress"] intValue];
int Pending = [[jResp IntOf: @"deploymentInfo.deploymentOverview.Pending"] intValue];
int Ready = [[jResp IntOf: @"deploymentInfo.deploymentOverview.Ready"] intValue];
int Skipped = [[jResp IntOf: @"deploymentInfo.deploymentOverview.Skipped"] intValue];
int Succeeded = [[jResp IntOf: @"deploymentInfo.deploymentOverview.Succeeded"] intValue];
NSString *DeploymentOption = [jResp StringOf: @"deploymentInfo.deploymentStyle.deploymentOption"];
NSString *DeploymentType = [jResp StringOf: @"deploymentInfo.deploymentStyle.deploymentType"];
NSString *Description = [jResp StringOf: @"deploymentInfo.description"];
NSString *Code = [jResp StringOf: @"deploymentInfo.errorInformation.code"];
NSString *Message = [jResp StringOf: @"deploymentInfo.errorInformation.message"];
NSString *ExternalId = [jResp StringOf: @"deploymentInfo.externalId"];
NSString *FileExistsBehavior = [jResp StringOf: @"deploymentInfo.fileExistsBehavior"];
int IgnoreApplicationStopFailures = [[jResp IntOf: @"deploymentInfo.ignoreApplicationStopFailures"] intValue];
int InstanceTerminationWaitTimeStarted = [[jResp IntOf: @"deploymentInfo.instanceTerminationWaitTimeStarted"] intValue];
NSString *Content = [jResp StringOf: @"deploymentInfo.previousRevision.appSpecContent.content"];
NSString *Sha256 = [jResp StringOf: @"deploymentInfo.previousRevision.appSpecContent.sha256"];
NSString *CommitId = [jResp StringOf: @"deploymentInfo.previousRevision.gitHubLocation.commitId"];
NSString *Repository = [jResp StringOf: @"deploymentInfo.previousRevision.gitHubLocation.repository"];
NSString *RevisionType = [jResp StringOf: @"deploymentInfo.previousRevision.revisionType"];
NSString *Bucket = [jResp StringOf: @"deploymentInfo.previousRevision.s3Location.bucket"];
NSString *BundleType = [jResp StringOf: @"deploymentInfo.previousRevision.s3Location.bundleType"];
NSString *ETag = [jResp StringOf: @"deploymentInfo.previousRevision.s3Location.eTag"];
NSString *Key = [jResp StringOf: @"deploymentInfo.previousRevision.s3Location.key"];
NSString *Version = [jResp StringOf: @"deploymentInfo.previousRevision.s3Location.version"];
NSString *StringContent = [jResp StringOf: @"deploymentInfo.previousRevision.string.content"];
NSString *StringSha256 = [jResp StringOf: @"deploymentInfo.previousRevision.string.sha256"];
NSString *AutoUpdateOutdatedInstancesRootDeploymentId = [jResp StringOf: @"deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesRootDeploymentId"];
NSString *AppSpecContentContent = [jResp StringOf: @"deploymentInfo.revision.appSpecContent.content"];
NSString *AppSpecContentSha256 = [jResp StringOf: @"deploymentInfo.revision.appSpecContent.sha256"];
NSString *GitHubLocationCommitId = [jResp StringOf: @"deploymentInfo.revision.gitHubLocation.commitId"];
NSString *GitHubLocationRepository = [jResp StringOf: @"deploymentInfo.revision.gitHubLocation.repository"];
NSString *RevisionRevisionType = [jResp StringOf: @"deploymentInfo.revision.revisionType"];
NSString *S3LocationBucket = [jResp StringOf: @"deploymentInfo.revision.s3Location.bucket"];
NSString *S3LocationBundleType = [jResp StringOf: @"deploymentInfo.revision.s3Location.bundleType"];
NSString *S3LocationETag = [jResp StringOf: @"deploymentInfo.revision.s3Location.eTag"];
NSString *S3LocationKey = [jResp StringOf: @"deploymentInfo.revision.s3Location.key"];
NSString *S3LocationVersion = [jResp StringOf: @"deploymentInfo.revision.s3Location.version"];
StringContent = [jResp StringOf: @"deploymentInfo.revision.string.content"];
StringSha256 = [jResp StringOf: @"deploymentInfo.revision.string.sha256"];
NSString *RollbackDeploymentId = [jResp StringOf: @"deploymentInfo.rollbackInfo.rollbackDeploymentId"];
NSString *RollbackMessage = [jResp StringOf: @"deploymentInfo.rollbackInfo.rollbackMessage"];
NSString *RollbackTriggeringDeploymentId = [jResp StringOf: @"deploymentInfo.rollbackInfo.rollbackTriggeringDeploymentId"];
int StartTime = [[jResp IntOf: @"deploymentInfo.startTime"] intValue];
NSString *Status = [jResp StringOf: @"deploymentInfo.status"];
int UpdateOutdatedInstancesOnly = [[jResp IntOf: @"deploymentInfo.updateOutdatedInstancesOnly"] intValue];
int i = 0;
int count_i = [[jResp SizeOfArray: @"deploymentInfo.autoRollbackConfiguration.events"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
strVal = [jResp StringOf: @"deploymentInfo.autoRollbackConfiguration.events[i]"];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"deploymentInfo.deploymentStatusMessages"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
strVal = [jResp StringOf: @"deploymentInfo.deploymentStatusMessages[i]"];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"deploymentInfo.loadBalancerInfo.elbInfoList"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
name = [jResp StringOf: @"deploymentInfo.loadBalancerInfo.elbInfoList[i].name"];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"deploymentInfo.loadBalancerInfo.targetGroupInfoList"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
name = [jResp StringOf: @"deploymentInfo.loadBalancerInfo.targetGroupInfoList[i].name"];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"deploymentInfo.loadBalancerInfo.targetGroupPairInfoList"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
j = 0;
count_j = [[jResp SizeOfArray: @"deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns"] intValue];
while (j < count_j) {
jResp.J = [NSNumber numberWithInt: j];
strVal = [jResp StringOf: @"deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns[j]"];
j = j + 1;
}
j = 0;
count_j = [[jResp SizeOfArray: @"deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups"] intValue];
while (j < count_j) {
jResp.J = [NSNumber numberWithInt: j];
name = [jResp StringOf: @"deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].targetGroups[j].name"];
j = j + 1;
}
j = 0;
count_j = [[jResp SizeOfArray: @"deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns"] intValue];
while (j < count_j) {
jResp.J = [NSNumber numberWithInt: j];
strVal = [jResp StringOf: @"deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].testTrafficRoute.listenerArns[j]"];
j = j + 1;
}
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
strVal = [jResp StringOf: @"deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds[i]"];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"deploymentInfo.targetInstances.autoScalingGroups"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
strVal = [jResp StringOf: @"deploymentInfo.targetInstances.autoScalingGroups[i]"];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
j = 0;
count_j = [[jResp SizeOfArray: @"deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i]"] intValue];
while (j < count_j) {
jResp.J = [NSNumber numberWithInt: j];
Key = [jResp StringOf: @"deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Key"];
v_Type = [jResp StringOf: @"deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Type"];
Value = [jResp StringOf: @"deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i][j].Value"];
j = j + 1;
}
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"deploymentInfo.targetInstances.tagFilters"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
Key = [jResp StringOf: @"deploymentInfo.targetInstances.tagFilters[i].Key"];
v_Type = [jResp StringOf: @"deploymentInfo.targetInstances.tagFilters[i].Type"];
Value = [jResp StringOf: @"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
// }
// }