Chilkat Online Tools

GetDeploymentGroup Java Example

AWS CodeDeploy

import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkRest rest = new CkRest();
    boolean success;

    CkAuthAws authAws = new CkAuthAws();
    authAws.put_AccessKey("AWS_ACCESS_KEY");
    authAws.put_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.put_Region("us-west-2");
    authAws.put_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",443,true,true);
    if (success != true) {
        System.out.println("ConnectFailReason: " + rest.get_ConnectFailReason());
        System.out.println(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

    CkJsonObject json = new CkJsonObject();
    json.UpdateString("applicationName","string");
    json.UpdateString("deploymentGroupName","string");

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

    // {
    //   "applicationName": "string",
    //   "deploymentGroupName": "string"
    // }

    rest.AddHeader("Content-Type","application/x-amz-json-1.1");
    rest.AddHeader("X-Amz-Target","CodeDeploy_20141006.GetDeploymentGroup");

    CkStringBuilder sbRequestBody = new CkStringBuilder();
    json.EmitSb(sbRequestBody);
    CkStringBuilder sbResponseBody = new CkStringBuilder();
    success = rest.FullRequestSb("POST","/",sbRequestBody,sbResponseBody);
    if (success != true) {
        System.out.println(rest.lastErrorText());
        return;
        }

    int respStatusCode = rest.get_ResponseStatusCode();
    System.out.println("response status code = " + respStatusCode);
    if (respStatusCode != 200) {
        System.out.println("Response Header:");
        System.out.println(rest.responseHeader());
        System.out.println("Response Body:");
        System.out.println(sbResponseBody.getAsString());
        return;
        }

    CkJsonObject jResp = new CkJsonObject();
    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

    String name;
    String strVal;
    String hook;
    String v_Type;
    String Value;
    int j;
    int count_j;
    String clusterName;
    String serviceName;
    String triggerName;
    String triggerTargetArn;

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

    i = 0;
    count_i = jResp.SizeOfArray("deploymentGroupInfo.autoRollbackConfiguration.events");
    while (i < count_i) {
        jResp.put_I(i);
        strVal = jResp.stringOf("deploymentGroupInfo.autoRollbackConfiguration.events[i]");
        i = i+1;
        }

    i = 0;
    count_i = jResp.SizeOfArray("deploymentGroupInfo.autoScalingGroups");
    while (i < count_i) {
        jResp.put_I(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");
    while (i < count_i) {
        jResp.put_I(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");
    while (i < count_i) {
        jResp.put_I(i);
        j = 0;
        count_j = jResp.SizeOfArray("deploymentGroupInfo.ec2TagSet.ec2TagSetList[i]");
        while (j < count_j) {
            jResp.put_J(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");
    while (i < count_i) {
        jResp.put_I(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");
    while (i < count_i) {
        jResp.put_I(i);
        name = jResp.stringOf("deploymentGroupInfo.loadBalancerInfo.elbInfoList[i].name");
        i = i+1;
        }

    i = 0;
    count_i = jResp.SizeOfArray("deploymentGroupInfo.loadBalancerInfo.targetGroupInfoList");
    while (i < count_i) {
        jResp.put_I(i);
        name = jResp.stringOf("deploymentGroupInfo.loadBalancerInfo.targetGroupInfoList[i].name");
        i = i+1;
        }

    i = 0;
    count_i = jResp.SizeOfArray("deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList");
    while (i < count_i) {
        jResp.put_I(i);
        j = 0;
        count_j = jResp.SizeOfArray("deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns");
        while (j < count_j) {
            jResp.put_J(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");
        while (j < count_j) {
            jResp.put_J(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");
        while (j < count_j) {
            jResp.put_J(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");
    while (i < count_i) {
        jResp.put_I(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");
    while (i < count_i) {
        jResp.put_I(i);
        j = 0;
        count_j = jResp.SizeOfArray("deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i]");
        while (j < count_j) {
            jResp.put_J(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");
    while (i < count_i) {
        jResp.put_I(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");
        while (j < count_j) {
            jResp.put_J(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"
    //       }
    //     ]
    //   }
    // }
  }
}