BatchGetDeployments unicodeC Example
#include <C_CkRestW.h>
#include <C_CkAuthAwsW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
HCkRestW rest;
BOOL success;
HCkAuthAwsW authAws;
HCkJsonObjectW json;
HCkStringBuilderW sbRequestBody;
HCkStringBuilderW sbResponseBody;
int respStatusCode;
HCkJsonObjectW jResp;
const wchar_t *additionalDeploymentStatusInfo;
const wchar_t *applicationName;
int Enabled;
const wchar_t *ActionOnTimeout;
int WaitTimeInMinutes;
const wchar_t *Action;
const wchar_t *TerminateBlueInstancesOnDeploymentSuccessAction;
int TerminationWaitTimeInMinutes;
int completeTime;
const wchar_t *computePlatform;
int createTime;
const wchar_t *creator;
const wchar_t *deploymentConfigName;
const wchar_t *deploymentGroupName;
const wchar_t *deploymentId;
int Failed;
int InProgress;
int Pending;
int Ready;
int Skipped;
int Succeeded;
const wchar_t *DeploymentOption;
const wchar_t *DeploymentType;
const wchar_t *description;
const wchar_t *Code;
const wchar_t *Message;
const wchar_t *externalId;
const wchar_t *fileExistsBehavior;
int ignoreApplicationStopFailures;
int instanceTerminationWaitTimeStarted;
const wchar_t *Content;
const wchar_t *Sha256;
const wchar_t *CommitId;
const wchar_t *Repository;
const wchar_t *RevisionType;
const wchar_t *Bucket;
const wchar_t *BundleType;
const wchar_t *ETag;
const wchar_t *Key;
const wchar_t *Version;
const wchar_t *StringContent;
const wchar_t *StringSha256;
const wchar_t *AutoUpdateOutdatedInstancesRootDeploymentId;
const wchar_t *AppSpecContentContent;
const wchar_t *AppSpecContentSha256;
const wchar_t *GitHubLocationCommitId;
const wchar_t *GitHubLocationRepository;
const wchar_t *revisionRevisionType;
const wchar_t *S3LocationBucket;
const wchar_t *S3LocationBundleType;
const wchar_t *S3LocationETag;
const wchar_t *S3LocationKey;
const wchar_t *S3LocationVersion;
const wchar_t *RollbackDeploymentId;
const wchar_t *RollbackMessage;
const wchar_t *RollbackTriggeringDeploymentId;
int startTime;
const wchar_t *status;
int updateOutdatedInstancesOnly;
int j;
int count_j;
const wchar_t *strVal;
const wchar_t *name;
int k;
int count_k;
const wchar_t *v_Type;
const wchar_t *Value;
int i;
int count_i;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
rest = CkRestW_Create();
authAws = CkAuthAwsW_Create();
CkAuthAwsW_putAccessKey(authAws,L"AWS_ACCESS_KEY");
CkAuthAwsW_putSecretKey(authAws,L"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.)
CkAuthAwsW_putRegion(authAws,L"us-west-2");
CkAuthAwsW_putServiceName(authAws,L"codedeploy");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRestW_SetAuthAws(rest,authAws);
// URL: https://codedeploy.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = CkRestW_Connect(rest,L"codedeploy.us-west-2.amazonaws.com",443,TRUE,TRUE);
if (success != TRUE) {
wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
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
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"deploymentIds[0]",L"string");
// The JSON request body created by the above code:
// {
// "deploymentIds": [
// "string"
// ]
// }
CkRestW_AddHeader(rest,L"Content-Type",L"application/x-amz-json-1.1");
CkRestW_AddHeader(rest,L"X-Amz-Target",L"CodeDeploy_20141006.BatchGetDeployments");
sbRequestBody = CkStringBuilderW_Create();
CkJsonObjectW_EmitSb(json,sbRequestBody);
sbResponseBody = CkStringBuilderW_Create();
success = CkRestW_FullRequestSb(rest,L"POST",L"/",sbRequestBody,sbResponseBody);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
respStatusCode = CkRestW_getResponseStatusCode(rest);
wprintf(L"response status code = %d\n",respStatusCode);
if (respStatusCode != 200) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkRestW_responseHeader(rest));
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkStringBuilderW_getAsString(sbResponseBody));
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,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
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
// See this example explaining how this memory should be used: const char * functions.
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"deploymentsInfo");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
additionalDeploymentStatusInfo = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].additionalDeploymentStatusInfo");
applicationName = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].applicationName");
Enabled = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].autoRollbackConfiguration.enabled");
ActionOnTimeout = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout");
WaitTimeInMinutes = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes");
Action = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action");
TerminateBlueInstancesOnDeploymentSuccessAction = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action");
TerminationWaitTimeInMinutes = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes");
completeTime = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].completeTime");
computePlatform = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].computePlatform");
createTime = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].createTime");
creator = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].creator");
deploymentConfigName = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].deploymentConfigName");
deploymentGroupName = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].deploymentGroupName");
deploymentId = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].deploymentId");
Failed = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].deploymentOverview.Failed");
InProgress = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].deploymentOverview.InProgress");
Pending = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].deploymentOverview.Pending");
Ready = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].deploymentOverview.Ready");
Skipped = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].deploymentOverview.Skipped");
Succeeded = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].deploymentOverview.Succeeded");
DeploymentOption = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].deploymentStyle.deploymentOption");
DeploymentType = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].deploymentStyle.deploymentType");
description = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].description");
Code = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].errorInformation.code");
Message = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].errorInformation.message");
externalId = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].externalId");
fileExistsBehavior = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].fileExistsBehavior");
ignoreApplicationStopFailures = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].ignoreApplicationStopFailures");
instanceTerminationWaitTimeStarted = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].instanceTerminationWaitTimeStarted");
Content = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].previousRevision.appSpecContent.content");
Sha256 = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].previousRevision.appSpecContent.sha256");
CommitId = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].previousRevision.gitHubLocation.commitId");
Repository = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].previousRevision.gitHubLocation.repository");
RevisionType = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].previousRevision.revisionType");
Bucket = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].previousRevision.s3Location.bucket");
BundleType = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].previousRevision.s3Location.bundleType");
ETag = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].previousRevision.s3Location.eTag");
Key = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].previousRevision.s3Location.key");
Version = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].previousRevision.s3Location.version");
StringContent = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].previousRevision.string.content");
StringSha256 = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].previousRevision.string.sha256");
AutoUpdateOutdatedInstancesRootDeploymentId = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesRootDeploymentId");
AppSpecContentContent = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].revision.appSpecContent.content");
AppSpecContentSha256 = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].revision.appSpecContent.sha256");
GitHubLocationCommitId = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].revision.gitHubLocation.commitId");
GitHubLocationRepository = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].revision.gitHubLocation.repository");
revisionRevisionType = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].revision.revisionType");
S3LocationBucket = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].revision.s3Location.bucket");
S3LocationBundleType = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].revision.s3Location.bundleType");
S3LocationETag = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].revision.s3Location.eTag");
S3LocationKey = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].revision.s3Location.key");
S3LocationVersion = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].revision.s3Location.version");
StringContent = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].revision.string.content");
StringSha256 = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].revision.string.sha256");
RollbackDeploymentId = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].rollbackInfo.rollbackDeploymentId");
RollbackMessage = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].rollbackInfo.rollbackMessage");
RollbackTriggeringDeploymentId = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].rollbackInfo.rollbackTriggeringDeploymentId");
startTime = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].startTime");
status = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].status");
updateOutdatedInstancesOnly = CkJsonObjectW_IntOf(jResp,L"deploymentsInfo[i].updateOutdatedInstancesOnly");
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentsInfo[i].autoRollbackConfiguration.events");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].autoRollbackConfiguration.events[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentsInfo[i].deploymentStatusMessages");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].deploymentStatusMessages[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentsInfo[i].loadBalancerInfo.elbInfoList");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
name = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].loadBalancerInfo.elbInfoList[j].name");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
name = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].loadBalancerInfo.targetGroupInfoList[j].name");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
k = 0;
count_k = CkJsonObjectW_SizeOfArray(jResp,L"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns");
while (k < count_k) {
CkJsonObjectW_putK(jResp,k);
strVal = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns[k]");
k = k + 1;
}
k = 0;
count_k = CkJsonObjectW_SizeOfArray(jResp,L"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups");
while (k < count_k) {
CkJsonObjectW_putK(jResp,k);
name = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups[k].name");
k = k + 1;
}
k = 0;
count_k = CkJsonObjectW_SizeOfArray(jResp,L"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns");
while (k < count_k) {
CkJsonObjectW_putK(jResp,k);
strVal = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns[k]");
k = k + 1;
}
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].relatedDeployments.autoUpdateOutdatedInstancesDeploymentIds[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentsInfo[i].targetInstances.autoScalingGroups");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].targetInstances.autoScalingGroups[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
k = 0;
count_k = CkJsonObjectW_SizeOfArray(jResp,L"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j]");
while (k < count_k) {
CkJsonObjectW_putK(jResp,k);
Key = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Key");
v_Type = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Type");
Value = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].targetInstances.ec2TagSet.ec2TagSetList[j][k].Value");
k = k + 1;
}
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentsInfo[i].targetInstances.tagFilters");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
Key = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].targetInstances.tagFilters[j].Key");
v_Type = CkJsonObjectW_stringOf(jResp,L"deploymentsInfo[i].targetInstances.tagFilters[j].Type");
Value = CkJsonObjectW_stringOf(jResp,L"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
// }
// ]
// }
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}