Chilkat Online Tools

GetDeploymentGroup Node.js Example

AWS CodeDeploy

var os = require('os');
if (os.platform() == 'win32') {  
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node17-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node17-win64'); 
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node17-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node17-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node17-linux64');
    }
} else if (os.platform() == 'darwin') {
    var chilkat = require('@chilkat/ck-node17-macosx');
}

function chilkatExample() {

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    var rest = new chilkat.Rest();
    var success;

    var authAws = new chilkat.AuthAws();
    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",443,true,true);
    if (success !== true) {
        console.log("ConnectFailReason: " + rest.ConnectFailReason);
        console.log(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

    var json = new chilkat.JsonObject();
    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");

    var sbRequestBody = new chilkat.StringBuilder();
    json.EmitSb(sbRequestBody);
    var sbResponseBody = new chilkat.StringBuilder();
    success = rest.FullRequestSb("POST","/",sbRequestBody,sbResponseBody);
    if (success !== true) {
        console.log(rest.LastErrorText);
        return;
    }

    var respStatusCode = rest.ResponseStatusCode;
    console.log("response status code = " + respStatusCode);
    if (respStatusCode !== 200) {
        console.log("Response Header:");
        console.log(rest.ResponseHeader);
        console.log("Response Body:");
        console.log(sbResponseBody.GetAsString());
        return;
    }

    var jResp = new chilkat.JsonObject();
    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 name;
    var strVal;
    var hook;
    var v_Type;
    var Value;
    var j;
    var count_j;
    var clusterName;
    var serviceName;
    var triggerName;
    var triggerTargetArn;

    var Enabled = jResp.IntOf("deploymentGroupInfo.alarmConfiguration.enabled");
    var IgnorePollAlarmFailure = jResp.IntOf("deploymentGroupInfo.alarmConfiguration.ignorePollAlarmFailure");
    var ApplicationName = jResp.StringOf("deploymentGroupInfo.applicationName");
    var AutoRollbackConfigurationEnabled = jResp.IntOf("deploymentGroupInfo.autoRollbackConfiguration.enabled");
    var ActionOnTimeout = jResp.StringOf("deploymentGroupInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout");
    var WaitTimeInMinutes = jResp.IntOf("deploymentGroupInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes");
    var Action = jResp.StringOf("deploymentGroupInfo.blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action");
    var TerminateBlueInstancesOnDeploymentSuccessAction = jResp.StringOf("deploymentGroupInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action");
    var TerminationWaitTimeInMinutes = jResp.IntOf("deploymentGroupInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes");
    var ComputePlatform = jResp.StringOf("deploymentGroupInfo.computePlatform");
    var DeploymentConfigName = jResp.StringOf("deploymentGroupInfo.deploymentConfigName");
    var DeploymentGroupId = jResp.StringOf("deploymentGroupInfo.deploymentGroupId");
    var DeploymentGroupName = jResp.StringOf("deploymentGroupInfo.deploymentGroupName");
    var DeploymentOption = jResp.StringOf("deploymentGroupInfo.deploymentStyle.deploymentOption");
    var DeploymentType = jResp.StringOf("deploymentGroupInfo.deploymentStyle.deploymentType");
    var CreateTime = jResp.IntOf("deploymentGroupInfo.lastAttemptedDeployment.createTime");
    var DeploymentId = jResp.StringOf("deploymentGroupInfo.lastAttemptedDeployment.deploymentId");
    var EndTime = jResp.IntOf("deploymentGroupInfo.lastAttemptedDeployment.endTime");
    var Status = jResp.StringOf("deploymentGroupInfo.lastAttemptedDeployment.status");
    var LastSuccessfulDeploymentCreateTime = jResp.IntOf("deploymentGroupInfo.lastSuccessfulDeployment.createTime");
    var LastSuccessfulDeploymentDeploymentId = jResp.StringOf("deploymentGroupInfo.lastSuccessfulDeployment.deploymentId");
    var LastSuccessfulDeploymentEndTime = jResp.IntOf("deploymentGroupInfo.lastSuccessfulDeployment.endTime");
    var LastSuccessfulDeploymentStatus = jResp.StringOf("deploymentGroupInfo.lastSuccessfulDeployment.status");
    var OutdatedInstancesStrategy = jResp.StringOf("deploymentGroupInfo.outdatedInstancesStrategy");
    var ServiceRoleArn = jResp.StringOf("deploymentGroupInfo.serviceRoleArn");
    var Content = jResp.StringOf("deploymentGroupInfo.targetRevision.appSpecContent.content");
    var Sha256 = jResp.StringOf("deploymentGroupInfo.targetRevision.appSpecContent.sha256");
    var CommitId = jResp.StringOf("deploymentGroupInfo.targetRevision.gitHubLocation.commitId");
    var Repository = jResp.StringOf("deploymentGroupInfo.targetRevision.gitHubLocation.repository");
    var RevisionType = jResp.StringOf("deploymentGroupInfo.targetRevision.revisionType");
    var Bucket = jResp.StringOf("deploymentGroupInfo.targetRevision.s3Location.bucket");
    var BundleType = jResp.StringOf("deploymentGroupInfo.targetRevision.s3Location.bundleType");
    var ETag = jResp.StringOf("deploymentGroupInfo.targetRevision.s3Location.eTag");
    var Key = jResp.StringOf("deploymentGroupInfo.targetRevision.s3Location.key");
    var Version = jResp.StringOf("deploymentGroupInfo.targetRevision.s3Location.version");
    var StringContent = jResp.StringOf("deploymentGroupInfo.targetRevision.string.content");
    var StringSha256 = jResp.StringOf("deploymentGroupInfo.targetRevision.string.sha256");
    var i = 0;
    var count_i = jResp.SizeOfArray("deploymentGroupInfo.alarmConfiguration.alarms");
    while (i < count_i) {
        jResp.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.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.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.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.I = i;
        j = 0;
        count_j = jResp.SizeOfArray("deploymentGroupInfo.ec2TagSet.ec2TagSetList[i]");
        while (j < count_j) {
            jResp.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.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.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.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.I = i;
        j = 0;
        count_j = jResp.SizeOfArray("deploymentGroupInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns");
        while (j < count_j) {
            jResp.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.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.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.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.I = i;
        j = 0;
        count_j = jResp.SizeOfArray("deploymentGroupInfo.onPremisesTagSet.onPremisesTagSetList[i]");
        while (j < count_j) {
            jResp.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.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.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"
    //       }
    //     ]
    //   }
    // }

}

chilkatExample();