Chilkat Online Tools

GetDeploymentGroup 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: @"applicationName" value: @"string"];
[json UpdateString: @"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"];

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 *name = 0;
NSString *strVal = 0;
NSString *hook = 0;
NSString *v_Type = 0;
NSString *Value = 0;
int j;
int count_j;
NSString *clusterName = 0;
NSString *serviceName = 0;
NSString *triggerName = 0;
NSString *triggerTargetArn = 0;

int Enabled = [[jResp IntOf: @"deploymentGroupInfo.alarmConfiguration.enabled"] intValue];
int IgnorePollAlarmFailure = [[jResp IntOf: @"deploymentGroupInfo.alarmConfiguration.ignorePollAlarmFailure"] intValue];
NSString *ApplicationName = [jResp StringOf: @"deploymentGroupInfo.applicationName"];
int AutoRollbackConfigurationEnabled = [[jResp IntOf: @"deploymentGroupInfo.autoRollbackConfiguration.enabled"] intValue];
NSString *ActionOnTimeout = [jResp StringOf: @"deploymentGroupInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout"];
int WaitTimeInMinutes = [[jResp IntOf: @"deploymentGroupInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes"] intValue];
NSString *Action = [jResp StringOf: @"deploymentGroupInfo.blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action"];
NSString *TerminateBlueInstancesOnDeploymentSuccessAction = [jResp StringOf: @"deploymentGroupInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action"];
int TerminationWaitTimeInMinutes = [[jResp IntOf: @"deploymentGroupInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes"] intValue];
NSString *ComputePlatform = [jResp StringOf: @"deploymentGroupInfo.computePlatform"];
NSString *DeploymentConfigName = [jResp StringOf: @"deploymentGroupInfo.deploymentConfigName"];
NSString *DeploymentGroupId = [jResp StringOf: @"deploymentGroupInfo.deploymentGroupId"];
NSString *DeploymentGroupName = [jResp StringOf: @"deploymentGroupInfo.deploymentGroupName"];
NSString *DeploymentOption = [jResp StringOf: @"deploymentGroupInfo.deploymentStyle.deploymentOption"];
NSString *DeploymentType = [jResp StringOf: @"deploymentGroupInfo.deploymentStyle.deploymentType"];
int CreateTime = [[jResp IntOf: @"deploymentGroupInfo.lastAttemptedDeployment.createTime"] intValue];
NSString *DeploymentId = [jResp StringOf: @"deploymentGroupInfo.lastAttemptedDeployment.deploymentId"];
int EndTime = [[jResp IntOf: @"deploymentGroupInfo.lastAttemptedDeployment.endTime"] intValue];
NSString *Status = [jResp StringOf: @"deploymentGroupInfo.lastAttemptedDeployment.status"];
int LastSuccessfulDeploymentCreateTime = [[jResp IntOf: @"deploymentGroupInfo.lastSuccessfulDeployment.createTime"] intValue];
NSString *LastSuccessfulDeploymentDeploymentId = [jResp StringOf: @"deploymentGroupInfo.lastSuccessfulDeployment.deploymentId"];
int LastSuccessfulDeploymentEndTime = [[jResp IntOf: @"deploymentGroupInfo.lastSuccessfulDeployment.endTime"] intValue];
NSString *LastSuccessfulDeploymentStatus = [jResp StringOf: @"deploymentGroupInfo.lastSuccessfulDeployment.status"];
NSString *OutdatedInstancesStrategy = [jResp StringOf: @"deploymentGroupInfo.outdatedInstancesStrategy"];
NSString *ServiceRoleArn = [jResp StringOf: @"deploymentGroupInfo.serviceRoleArn"];
NSString *Content = [jResp StringOf: @"deploymentGroupInfo.targetRevision.appSpecContent.content"];
NSString *Sha256 = [jResp StringOf: @"deploymentGroupInfo.targetRevision.appSpecContent.sha256"];
NSString *CommitId = [jResp StringOf: @"deploymentGroupInfo.targetRevision.gitHubLocation.commitId"];
NSString *Repository = [jResp StringOf: @"deploymentGroupInfo.targetRevision.gitHubLocation.repository"];
NSString *RevisionType = [jResp StringOf: @"deploymentGroupInfo.targetRevision.revisionType"];
NSString *Bucket = [jResp StringOf: @"deploymentGroupInfo.targetRevision.s3Location.bucket"];
NSString *BundleType = [jResp StringOf: @"deploymentGroupInfo.targetRevision.s3Location.bundleType"];
NSString *ETag = [jResp StringOf: @"deploymentGroupInfo.targetRevision.s3Location.eTag"];
NSString *Key = [jResp StringOf: @"deploymentGroupInfo.targetRevision.s3Location.key"];
NSString *Version = [jResp StringOf: @"deploymentGroupInfo.targetRevision.s3Location.version"];
NSString *StringContent = [jResp StringOf: @"deploymentGroupInfo.targetRevision.string.content"];
NSString *StringSha256 = [jResp StringOf: @"deploymentGroupInfo.targetRevision.string.sha256"];
int i = 0;
int count_i = [[jResp SizeOfArray: @"deploymentGroupInfo.alarmConfiguration.alarms"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    name = [jResp StringOf: @"deploymentGroupInfo.alarmConfiguration.alarms[i].name"];
    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"deploymentGroupInfo.autoRollbackConfiguration.events"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    strVal = [jResp StringOf: @"deploymentGroupInfo.autoRollbackConfiguration.events[i]"];
    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"deploymentGroupInfo.autoScalingGroups"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    hook = [jResp StringOf: @"deploymentGroupInfo.autoScalingGroups[i].hook"];
    name = [jResp StringOf: @"deploymentGroupInfo.autoScalingGroups[i].name"];
    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"deploymentGroupInfo.ec2TagFilters"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    Key = [jResp StringOf: @"deploymentGroupInfo.ec2TagFilters[i].Key"];
    v_Type = [jResp StringOf: @"deploymentGroupInfo.ec2TagFilters[i].Type"];
    Value = [jResp StringOf: @"deploymentGroupInfo.ec2TagFilters[i].Value"];
    i = i + 1;
}

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

    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"deploymentGroupInfo.ecsServices"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    clusterName = [jResp StringOf: @"deploymentGroupInfo.ecsServices[i].clusterName"];
    serviceName = [jResp StringOf: @"deploymentGroupInfo.ecsServices[i].serviceName"];
    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"deploymentGroupInfo.loadBalancerInfo.elbInfoList"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    name = [jResp StringOf: @"deploymentGroupInfo.loadBalancerInfo.elbInfoList[i].name"];
    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"deploymentGroupInfo.loadBalancerInfo.targetGroupInfoList"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    name = [jResp StringOf: @"deploymentGroupInfo.loadBalancerInfo.targetGroupInfoList[i].name"];
    i = i + 1;
}

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

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

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

    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"deploymentGroupInfo.onPremisesInstanceTagFilters"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    Key = [jResp StringOf: @"deploymentGroupInfo.onPremisesInstanceTagFilters[i].Key"];
    v_Type = [jResp StringOf: @"deploymentGroupInfo.onPremisesInstanceTagFilters[i].Type"];
    Value = [jResp StringOf: @"deploymentGroupInfo.onPremisesInstanceTagFilters[i].Value"];
    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    j = 0;
    count_j = [[jResp SizeOfArray: @"deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i]"] intValue];
    while (j < count_j) {
        jResp.J = [NSNumber numberWithInt: j];
        Key = [jResp StringOf: @"deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Key"];
        v_Type = [jResp StringOf: @"deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Type"];
        Value = [jResp StringOf: @"deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i][j].Value"];
        j = j + 1;
    }

    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"deploymentGroupInfo.triggerConfigurations"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    triggerName = [jResp StringOf: @"deploymentGroupInfo.triggerConfigurations[i].triggerName"];
    triggerTargetArn = [jResp StringOf: @"deploymentGroupInfo.triggerConfigurations[i].triggerTargetArn"];
    j = 0;
    count_j = [[jResp SizeOfArray: @"deploymentGroupInfo.triggerConfigurations[i].triggerEvents"] intValue];
    while (j < count_j) {
        jResp.J = [NSNumber numberWithInt: j];
        strVal = [jResp StringOf: @"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"
//       }
//     ]
//   }
// }