Chilkat Online Tools

BatchGetDeployments Objective-C Example

AWS CodeDeploy

#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: @"deploymentIds[0]" value: @"string"];

// The JSON request body created by the above code:

// {
//   "deploymentIds": [
//     "string"
//   ]
// }

[rest AddHeader: @"Content-Type" value: @"application/x-amz-json-1.1"];
[rest AddHeader: @"X-Amz-Target" value: @"CodeDeploy_20141006.BatchGetDeployments"];

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 *additionalDeploymentStatusInfo = 0;
NSString *applicationName = 0;
int Enabled;
NSString *ActionOnTimeout = 0;
int WaitTimeInMinutes;
NSString *Action = 0;
NSString *TerminateBlueInstancesOnDeploymentSuccessAction = 0;
int TerminationWaitTimeInMinutes;
int completeTime;
NSString *computePlatform = 0;
int createTime;
NSString *creator = 0;
NSString *deploymentConfigName = 0;
NSString *deploymentGroupName = 0;
NSString *deploymentId = 0;
int Failed;
int InProgress;
int Pending;
int Ready;
int Skipped;
int Succeeded;
NSString *DeploymentOption = 0;
NSString *DeploymentType = 0;
NSString *description = 0;
NSString *Code = 0;
NSString *Message = 0;
NSString *externalId = 0;
NSString *fileExistsBehavior = 0;
int ignoreApplicationStopFailures;
int instanceTerminationWaitTimeStarted;
NSString *Content = 0;
NSString *Sha256 = 0;
NSString *CommitId = 0;
NSString *Repository = 0;
NSString *RevisionType = 0;
NSString *Bucket = 0;
NSString *BundleType = 0;
NSString *ETag = 0;
NSString *Key = 0;
NSString *Version = 0;
NSString *StringContent = 0;
NSString *StringSha256 = 0;
NSString *AutoUpdateOutdatedInstancesRootDeploymentId = 0;
NSString *AppSpecContentContent = 0;
NSString *AppSpecContentSha256 = 0;
NSString *GitHubLocationCommitId = 0;
NSString *GitHubLocationRepository = 0;
NSString *revisionRevisionType = 0;
NSString *S3LocationBucket = 0;
NSString *S3LocationBundleType = 0;
NSString *S3LocationETag = 0;
NSString *S3LocationKey = 0;
NSString *S3LocationVersion = 0;
NSString *RollbackDeploymentId = 0;
NSString *RollbackMessage = 0;
NSString *RollbackTriggeringDeploymentId = 0;
int startTime;
NSString *status = 0;
int updateOutdatedInstancesOnly;
int j;
int count_j;
NSString *strVal = 0;
NSString *name = 0;
int k;
int count_k;
NSString *v_Type = 0;
NSString *Value = 0;

int i = 0;
int count_i = [[jResp SizeOfArray: @"deploymentsInfo"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    additionalDeploymentStatusInfo = [jResp StringOf: @"deploymentsInfo[i].additionalDeploymentStatusInfo"];
    applicationName = [jResp StringOf: @"deploymentsInfo[i].applicationName"];
    Enabled = [[jResp IntOf: @"deploymentsInfo[i].autoRollbackConfiguration.enabled"] intValue];
    ActionOnTimeout = [jResp StringOf: @"deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout"];
    WaitTimeInMinutes = [[jResp IntOf: @"deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes"] intValue];
    Action = [jResp StringOf: @"deploymentsInfo[i].blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action"];
    TerminateBlueInstancesOnDeploymentSuccessAction = [jResp StringOf: @"deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action"];
    TerminationWaitTimeInMinutes = [[jResp IntOf: @"deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes"] intValue];
    completeTime = [[jResp IntOf: @"deploymentsInfo[i].completeTime"] intValue];
    computePlatform = [jResp StringOf: @"deploymentsInfo[i].computePlatform"];
    createTime = [[jResp IntOf: @"deploymentsInfo[i].createTime"] intValue];
    creator = [jResp StringOf: @"deploymentsInfo[i].creator"];
    deploymentConfigName = [jResp StringOf: @"deploymentsInfo[i].deploymentConfigName"];
    deploymentGroupName = [jResp StringOf: @"deploymentsInfo[i].deploymentGroupName"];
    deploymentId = [jResp StringOf: @"deploymentsInfo[i].deploymentId"];
    Failed = [[jResp IntOf: @"deploymentsInfo[i].deploymentOverview.Failed"] intValue];
    InProgress = [[jResp IntOf: @"deploymentsInfo[i].deploymentOverview.InProgress"] intValue];
    Pending = [[jResp IntOf: @"deploymentsInfo[i].deploymentOverview.Pending"] intValue];
    Ready = [[jResp IntOf: @"deploymentsInfo[i].deploymentOverview.Ready"] intValue];
    Skipped = [[jResp IntOf: @"deploymentsInfo[i].deploymentOverview.Skipped"] intValue];
    Succeeded = [[jResp IntOf: @"deploymentsInfo[i].deploymentOverview.Succeeded"] intValue];
    DeploymentOption = [jResp StringOf: @"deploymentsInfo[i].deploymentStyle.deploymentOption"];
    DeploymentType = [jResp StringOf: @"deploymentsInfo[i].deploymentStyle.deploymentType"];
    description = [jResp StringOf: @"deploymentsInfo[i].description"];
    Code = [jResp StringOf: @"deploymentsInfo[i].errorInformation.code"];
    Message = [jResp StringOf: @"deploymentsInfo[i].errorInformation.message"];
    externalId = [jResp StringOf: @"deploymentsInfo[i].externalId"];
    fileExistsBehavior = [jResp StringOf: @"deploymentsInfo[i].fileExistsBehavior"];
    ignoreApplicationStopFailures = [[jResp IntOf: @"deploymentsInfo[i].ignoreApplicationStopFailures"] intValue];
    instanceTerminationWaitTimeStarted = [[jResp IntOf: @"deploymentsInfo[i].instanceTerminationWaitTimeStarted"] intValue];
    Content = [jResp StringOf: @"deploymentsInfo[i].previousRevision.appSpecContent.content"];
    Sha256 = [jResp StringOf: @"deploymentsInfo[i].previousRevision.appSpecContent.sha256"];
    CommitId = [jResp StringOf: @"deploymentsInfo[i].previousRevision.gitHubLocation.commitId"];
    Repository = [jResp StringOf: @"deploymentsInfo[i].previousRevision.gitHubLocation.repository"];
    RevisionType = [jResp StringOf: @"deploymentsInfo[i].previousRevision.revisionType"];
    Bucket = [jResp StringOf: @"deploymentsInfo[i].previousRevision.s3Location.bucket"];
    BundleType = [jResp StringOf: @"deploymentsInfo[i].previousRevision.s3Location.bundleType"];
    ETag = [jResp StringOf: @"deploymentsInfo[i].previousRevision.s3Location.eTag"];
    Key = [jResp StringOf: @"deploymentsInfo[i].previousRevision.s3Location.key"];
    Version = [jResp StringOf: @"deploymentsInfo[i].previousRevision.s3Location.version"];
    StringContent = [jResp StringOf: @"deploymentsInfo[i].previousRevision.string.content"];
    StringSha256 = [jResp StringOf: @"deploymentsInfo[i].previousRevision.string.sha256"];
    AutoUpdateOutdatedInstancesRootDeploymentId = [jResp StringOf: @"deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesRootDeploymentId"];
    AppSpecContentContent = [jResp StringOf: @"deploymentsInfo[i].revision.appSpecContent.content"];
    AppSpecContentSha256 = [jResp StringOf: @"deploymentsInfo[i].revision.appSpecContent.sha256"];
    GitHubLocationCommitId = [jResp StringOf: @"deploymentsInfo[i].revision.gitHubLocation.commitId"];
    GitHubLocationRepository = [jResp StringOf: @"deploymentsInfo[i].revision.gitHubLocation.repository"];
    revisionRevisionType = [jResp StringOf: @"deploymentsInfo[i].revision.revisionType"];
    S3LocationBucket = [jResp StringOf: @"deploymentsInfo[i].revision.s3Location.bucket"];
    S3LocationBundleType = [jResp StringOf: @"deploymentsInfo[i].revision.s3Location.bundleType"];
    S3LocationETag = [jResp StringOf: @"deploymentsInfo[i].revision.s3Location.eTag"];
    S3LocationKey = [jResp StringOf: @"deploymentsInfo[i].revision.s3Location.key"];
    S3LocationVersion = [jResp StringOf: @"deploymentsInfo[i].revision.s3Location.version"];
    StringContent = [jResp StringOf: @"deploymentsInfo[i].revision.string.content"];
    StringSha256 = [jResp StringOf: @"deploymentsInfo[i].revision.string.sha256"];
    RollbackDeploymentId = [jResp StringOf: @"deploymentsInfo[i].rollbackInfo.rollbackDeploymentId"];
    RollbackMessage = [jResp StringOf: @"deploymentsInfo[i].rollbackInfo.rollbackMessage"];
    RollbackTriggeringDeploymentId = [jResp StringOf: @"deploymentsInfo[i].rollbackInfo.rollbackTriggeringDeploymentId"];
    startTime = [[jResp IntOf: @"deploymentsInfo[i].startTime"] intValue];
    status = [jResp StringOf: @"deploymentsInfo[i].status"];
    updateOutdatedInstancesOnly = [[jResp IntOf: @"deploymentsInfo[i].updateOutdatedInstancesOnly"] intValue];
    j = 0;
    count_j = [[jResp SizeOfArray: @"deploymentsInfo[i].autoRollbackConfiguration.events"] intValue];
    while (j < count_j) {
        jResp.J = [NSNumber numberWithInt: j];
        strVal = [jResp StringOf: @"deploymentsInfo[i].autoRollbackConfiguration.events[j]"];
        j = j + 1;
    }

    j = 0;
    count_j = [[jResp SizeOfArray: @"deploymentsInfo[i].deploymentStatusMessages"] intValue];
    while (j < count_j) {
        jResp.J = [NSNumber numberWithInt: j];
        strVal = [jResp StringOf: @"deploymentsInfo[i].deploymentStatusMessages[j]"];
        j = j + 1;
    }

    j = 0;
    count_j = [[jResp SizeOfArray: @"deploymentsInfo[i].loadBalancerInfo.elbInfoList"] intValue];
    while (j < count_j) {
        jResp.J = [NSNumber numberWithInt: j];
        name = [jResp StringOf: @"deploymentsInfo[i].loadBalancerInfo.elbInfoList[j].name"];
        j = j + 1;
    }

    j = 0;
    count_j = [[jResp SizeOfArray: @"deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList"] intValue];
    while (j < count_j) {
        jResp.J = [NSNumber numberWithInt: j];
        name = [jResp StringOf: @"deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList[j].name"];
        j = j + 1;
    }

    j = 0;
    count_j = [[jResp SizeOfArray: @"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList"] intValue];
    while (j < count_j) {
        jResp.J = [NSNumber numberWithInt: j];
        k = 0;
        count_k = [[jResp SizeOfArray: @"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns"] intValue];
        while (k < count_k) {
            jResp.K = [NSNumber numberWithInt: k];
            strVal = [jResp StringOf: @"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns[k]"];
            k = k + 1;
        }

        k = 0;
        count_k = [[jResp SizeOfArray: @"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups"] intValue];
        while (k < count_k) {
            jResp.K = [NSNumber numberWithInt: k];
            name = [jResp StringOf: @"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups[k].name"];
            k = k + 1;
        }

        k = 0;
        count_k = [[jResp SizeOfArray: @"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns"] intValue];
        while (k < count_k) {
            jResp.K = [NSNumber numberWithInt: k];
            strVal = [jResp StringOf: @"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns[k]"];
            k = k + 1;
        }

        j = j + 1;
    }

    j = 0;
    count_j = [[jResp SizeOfArray: @"deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds"] intValue];
    while (j < count_j) {
        jResp.J = [NSNumber numberWithInt: j];
        strVal = [jResp StringOf: @"deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds[j]"];
        j = j + 1;
    }

    j = 0;
    count_j = [[jResp SizeOfArray: @"deploymentsInfo[i].targetInstances.autoScalingGroups"] intValue];
    while (j < count_j) {
        jResp.J = [NSNumber numberWithInt: j];
        strVal = [jResp StringOf: @"deploymentsInfo[i].targetInstances.autoScalingGroups[j]"];
        j = j + 1;
    }

    j = 0;
    count_j = [[jResp SizeOfArray: @"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList"] intValue];
    while (j < count_j) {
        jResp.J = [NSNumber numberWithInt: j];
        k = 0;
        count_k = [[jResp SizeOfArray: @"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j]"] intValue];
        while (k < count_k) {
            jResp.K = [NSNumber numberWithInt: k];
            Key = [jResp StringOf: @"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Key"];
            v_Type = [jResp StringOf: @"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Type"];
            Value = [jResp StringOf: @"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Value"];
            k = k + 1;
        }

        j = j + 1;
    }

    j = 0;
    count_j = [[jResp SizeOfArray: @"deploymentsInfo[i].targetInstances.tagFilters"] intValue];
    while (j < count_j) {
        jResp.J = [NSNumber numberWithInt: j];
        Key = [jResp StringOf: @"deploymentsInfo[i].targetInstances.tagFilters[j].Key"];
        v_Type = [jResp StringOf: @"deploymentsInfo[i].targetInstances.tagFilters[j].Type"];
        Value = [jResp StringOf: @"deploymentsInfo[i].targetInstances.tagFilters[j].Value"];
        j = j + 1;
    }

    i = i + 1;
}

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

// {
//   "deploymentsInfo": [
//     {
//       "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
//     }
//   ]
// }