GetDeployment Node.js Example
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("deploymentId","string");
// The JSON request body created by the above code:
// {
// "deploymentId": "string"
// }
rest.AddHeader("Content-Type","application/x-amz-json-1.1");
rest.AddHeader("X-Amz-Target","CodeDeploy_20141006.GetDeployment");
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 strVal;
var name;
var j;
var count_j;
var v_Type;
var Value;
var AdditionalDeploymentStatusInfo = jResp.StringOf("deploymentInfo.additionalDeploymentStatusInfo");
var ApplicationName = jResp.StringOf("deploymentInfo.applicationName");
var Enabled = jResp.IntOf("deploymentInfo.autoRollbackConfiguration.enabled");
var ActionOnTimeout = jResp.StringOf("deploymentInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout");
var WaitTimeInMinutes = jResp.IntOf("deploymentInfo.blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes");
var Action = jResp.StringOf("deploymentInfo.blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action");
var TerminateBlueInstancesOnDeploymentSuccessAction = jResp.StringOf("deploymentInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action");
var TerminationWaitTimeInMinutes = jResp.IntOf("deploymentInfo.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes");
var CompleteTime = jResp.IntOf("deploymentInfo.completeTime");
var ComputePlatform = jResp.StringOf("deploymentInfo.computePlatform");
var CreateTime = jResp.IntOf("deploymentInfo.createTime");
var Creator = jResp.StringOf("deploymentInfo.creator");
var DeploymentConfigName = jResp.StringOf("deploymentInfo.deploymentConfigName");
var DeploymentGroupName = jResp.StringOf("deploymentInfo.deploymentGroupName");
var DeploymentId = jResp.StringOf("deploymentInfo.deploymentId");
var Failed = jResp.IntOf("deploymentInfo.deploymentOverview.Failed");
var InProgress = jResp.IntOf("deploymentInfo.deploymentOverview.InProgress");
var Pending = jResp.IntOf("deploymentInfo.deploymentOverview.Pending");
var Ready = jResp.IntOf("deploymentInfo.deploymentOverview.Ready");
var Skipped = jResp.IntOf("deploymentInfo.deploymentOverview.Skipped");
var Succeeded = jResp.IntOf("deploymentInfo.deploymentOverview.Succeeded");
var DeploymentOption = jResp.StringOf("deploymentInfo.deploymentStyle.deploymentOption");
var DeploymentType = jResp.StringOf("deploymentInfo.deploymentStyle.deploymentType");
var Description = jResp.StringOf("deploymentInfo.description");
var Code = jResp.StringOf("deploymentInfo.errorInformation.code");
var Message = jResp.StringOf("deploymentInfo.errorInformation.message");
var ExternalId = jResp.StringOf("deploymentInfo.externalId");
var FileExistsBehavior = jResp.StringOf("deploymentInfo.fileExistsBehavior");
var IgnoreApplicationStopFailures = jResp.IntOf("deploymentInfo.ignoreApplicationStopFailures");
var InstanceTerminationWaitTimeStarted = jResp.IntOf("deploymentInfo.instanceTerminationWaitTimeStarted");
var Content = jResp.StringOf("deploymentInfo.previousRevision.appSpecContent.content");
var Sha256 = jResp.StringOf("deploymentInfo.previousRevision.appSpecContent.sha256");
var CommitId = jResp.StringOf("deploymentInfo.previousRevision.gitHubLocation.commitId");
var Repository = jResp.StringOf("deploymentInfo.previousRevision.gitHubLocation.repository");
var RevisionType = jResp.StringOf("deploymentInfo.previousRevision.revisionType");
var Bucket = jResp.StringOf("deploymentInfo.previousRevision.s3Location.bucket");
var BundleType = jResp.StringOf("deploymentInfo.previousRevision.s3Location.bundleType");
var ETag = jResp.StringOf("deploymentInfo.previousRevision.s3Location.eTag");
var Key = jResp.StringOf("deploymentInfo.previousRevision.s3Location.key");
var Version = jResp.StringOf("deploymentInfo.previousRevision.s3Location.version");
var StringContent = jResp.StringOf("deploymentInfo.previousRevision.string.content");
var StringSha256 = jResp.StringOf("deploymentInfo.previousRevision.string.sha256");
var AutoUpdateOutdatedInstancesRootDeploymentId = jResp.StringOf("deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesRootDeploymentId");
var AppSpecContentContent = jResp.StringOf("deploymentInfo.revision.appSpecContent.content");
var AppSpecContentSha256 = jResp.StringOf("deploymentInfo.revision.appSpecContent.sha256");
var GitHubLocationCommitId = jResp.StringOf("deploymentInfo.revision.gitHubLocation.commitId");
var GitHubLocationRepository = jResp.StringOf("deploymentInfo.revision.gitHubLocation.repository");
var RevisionRevisionType = jResp.StringOf("deploymentInfo.revision.revisionType");
var S3LocationBucket = jResp.StringOf("deploymentInfo.revision.s3Location.bucket");
var S3LocationBundleType = jResp.StringOf("deploymentInfo.revision.s3Location.bundleType");
var S3LocationETag = jResp.StringOf("deploymentInfo.revision.s3Location.eTag");
var S3LocationKey = jResp.StringOf("deploymentInfo.revision.s3Location.key");
var S3LocationVersion = jResp.StringOf("deploymentInfo.revision.s3Location.version");
StringContent = jResp.StringOf("deploymentInfo.revision.string.content");
StringSha256 = jResp.StringOf("deploymentInfo.revision.string.sha256");
var RollbackDeploymentId = jResp.StringOf("deploymentInfo.rollbackInfo.rollbackDeploymentId");
var RollbackMessage = jResp.StringOf("deploymentInfo.rollbackInfo.rollbackMessage");
var RollbackTriggeringDeploymentId = jResp.StringOf("deploymentInfo.rollbackInfo.rollbackTriggeringDeploymentId");
var StartTime = jResp.IntOf("deploymentInfo.startTime");
var Status = jResp.StringOf("deploymentInfo.status");
var UpdateOutdatedInstancesOnly = jResp.IntOf("deploymentInfo.updateOutdatedInstancesOnly");
var i = 0;
var count_i = jResp.SizeOfArray("deploymentInfo.autoRollbackConfiguration.events");
while (i < count_i) {
jResp.I = i;
strVal = jResp.StringOf("deploymentInfo.autoRollbackConfiguration.events[i]");
i = i+1;
}
i = 0;
count_i = jResp.SizeOfArray("deploymentInfo.deploymentStatusMessages");
while (i < count_i) {
jResp.I = i;
strVal = jResp.StringOf("deploymentInfo.deploymentStatusMessages[i]");
i = i+1;
}
i = 0;
count_i = jResp.SizeOfArray("deploymentInfo.loadBalancerInfo.elbInfoList");
while (i < count_i) {
jResp.I = i;
name = jResp.StringOf("deploymentInfo.loadBalancerInfo.elbInfoList[i].name");
i = i+1;
}
i = 0;
count_i = jResp.SizeOfArray("deploymentInfo.loadBalancerInfo.targetGroupInfoList");
while (i < count_i) {
jResp.I = i;
name = jResp.StringOf("deploymentInfo.loadBalancerInfo.targetGroupInfoList[i].name");
i = i+1;
}
i = 0;
count_i = jResp.SizeOfArray("deploymentInfo.loadBalancerInfo.targetGroupPairInfoList");
while (i < count_i) {
jResp.I = i;
j = 0;
count_j = jResp.SizeOfArray("deploymentInfo.loadBalancerInfo.targetGroupPairInfoList[i].prodTrafficRoute.listenerArns");
while (j < count_j) {
jResp.J = 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");
while (j < count_j) {
jResp.J = 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");
while (j < count_j) {
jResp.J = 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");
while (i < count_i) {
jResp.I = i;
strVal = jResp.StringOf("deploymentInfo.relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds[i]");
i = i+1;
}
i = 0;
count_i = jResp.SizeOfArray("deploymentInfo.targetInstances.autoScalingGroups");
while (i < count_i) {
jResp.I = i;
strVal = jResp.StringOf("deploymentInfo.targetInstances.autoScalingGroups[i]");
i = i+1;
}
i = 0;
count_i = jResp.SizeOfArray("deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList");
while (i < count_i) {
jResp.I = i;
j = 0;
count_j = jResp.SizeOfArray("deploymentInfo.targetInstances.ec2TagSet.ec2TagSetList[i]");
while (j < count_j) {
jResp.J = 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");
while (i < count_i) {
jResp.I = 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
// }
// }
}
chilkatExample();