BatchGetDeploymentGroups 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;
int Enabled;
int IgnorePollAlarmFailure;
const wchar_t *applicationName;
int autoRollbackConfigurationEnabled;
const wchar_t *ActionOnTimeout;
int WaitTimeInMinutes;
const wchar_t *Action;
const wchar_t *TerminateBlueInstancesOnDeploymentSuccessAction;
int TerminationWaitTimeInMinutes;
const wchar_t *computePlatform;
const wchar_t *deploymentConfigName;
const wchar_t *deploymentGroupId;
const wchar_t *deploymentGroupName;
const wchar_t *DeploymentOption;
const wchar_t *DeploymentType;
int CreateTime;
const wchar_t *DeploymentId;
int EndTime;
const wchar_t *Status;
int lastSuccessfulDeploymentCreateTime;
const wchar_t *lastSuccessfulDeploymentDeploymentId;
int lastSuccessfulDeploymentEndTime;
const wchar_t *lastSuccessfulDeploymentStatus;
const wchar_t *outdatedInstancesStrategy;
const wchar_t *serviceRoleArn;
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;
int j;
int count_j;
const wchar_t *name;
const wchar_t *strVal;
const wchar_t *hook;
const wchar_t *v_Type;
const wchar_t *Value;
int k;
int count_k;
const wchar_t *clusterName;
const wchar_t *serviceName;
const wchar_t *triggerName;
const wchar_t *triggerTargetArn;
const wchar_t *errorMessage;
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"applicationName",L"string");
CkJsonObjectW_UpdateString(json,L"deploymentGroupNames[0]",L"string");
// The JSON request body created by the above code:
// {
// "applicationName": "string",
// "deploymentGroupNames": [
// "string"
// ]
// }
CkRestW_AddHeader(rest,L"Content-Type",L"application/x-amz-json-1.1");
CkRestW_AddHeader(rest,L"X-Amz-Target",L"CodeDeploy_20141006.BatchGetDeploymentGroups");
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.
errorMessage = CkJsonObjectW_stringOf(jResp,L"errorMessage");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
Enabled = CkJsonObjectW_IntOf(jResp,L"deploymentGroupsInfo[i].alarmConfiguration.enabled");
IgnorePollAlarmFailure = CkJsonObjectW_IntOf(jResp,L"deploymentGroupsInfo[i].alarmConfiguration.ignorePollAlarmFailure");
applicationName = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].applicationName");
autoRollbackConfigurationEnabled = CkJsonObjectW_IntOf(jResp,L"deploymentGroupsInfo[i].autoRollbackConfiguration.enabled");
ActionOnTimeout = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout");
WaitTimeInMinutes = CkJsonObjectW_IntOf(jResp,L"deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes");
Action = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action");
TerminateBlueInstancesOnDeploymentSuccessAction = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action");
TerminationWaitTimeInMinutes = CkJsonObjectW_IntOf(jResp,L"deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes");
computePlatform = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].computePlatform");
deploymentConfigName = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].deploymentConfigName");
deploymentGroupId = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].deploymentGroupId");
deploymentGroupName = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].deploymentGroupName");
DeploymentOption = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].deploymentStyle.deploymentOption");
DeploymentType = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].deploymentStyle.deploymentType");
CreateTime = CkJsonObjectW_IntOf(jResp,L"deploymentGroupsInfo[i].lastAttemptedDeployment.createTime");
DeploymentId = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].lastAttemptedDeployment.deploymentId");
EndTime = CkJsonObjectW_IntOf(jResp,L"deploymentGroupsInfo[i].lastAttemptedDeployment.endTime");
Status = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].lastAttemptedDeployment.status");
lastSuccessfulDeploymentCreateTime = CkJsonObjectW_IntOf(jResp,L"deploymentGroupsInfo[i].lastSuccessfulDeployment.createTime");
lastSuccessfulDeploymentDeploymentId = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].lastSuccessfulDeployment.deploymentId");
lastSuccessfulDeploymentEndTime = CkJsonObjectW_IntOf(jResp,L"deploymentGroupsInfo[i].lastSuccessfulDeployment.endTime");
lastSuccessfulDeploymentStatus = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].lastSuccessfulDeployment.status");
outdatedInstancesStrategy = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].outdatedInstancesStrategy");
serviceRoleArn = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].serviceRoleArn");
Content = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].targetRevision.appSpecContent.content");
Sha256 = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].targetRevision.appSpecContent.sha256");
CommitId = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].targetRevision.gitHubLocation.commitId");
Repository = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].targetRevision.gitHubLocation.repository");
RevisionType = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].targetRevision.revisionType");
Bucket = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].targetRevision.s3Location.bucket");
BundleType = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].targetRevision.s3Location.bundleType");
ETag = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].targetRevision.s3Location.eTag");
Key = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].targetRevision.s3Location.key");
Version = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].targetRevision.s3Location.version");
StringContent = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].targetRevision.string.content");
StringSha256 = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].targetRevision.string.sha256");
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].alarmConfiguration.alarms");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
name = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].alarmConfiguration.alarms[j].name");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].autoRollbackConfiguration.events");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].autoRollbackConfiguration.events[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].autoScalingGroups");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
hook = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].autoScalingGroups[j].hook");
name = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].autoScalingGroups[j].name");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].ec2TagFilters");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
Key = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].ec2TagFilters[j].Key");
v_Type = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].ec2TagFilters[j].Type");
Value = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].ec2TagFilters[j].Value");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
k = 0;
count_k = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j]");
while (k < count_k) {
CkJsonObjectW_putK(jResp,k);
Key = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j][k].Key");
v_Type = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j][k].Type");
Value = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j][k].Value");
k = k + 1;
}
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].ecsServices");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
clusterName = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].ecsServices[j].clusterName");
serviceName = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].ecsServices[j].serviceName");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].loadBalancerInfo.elbInfoList");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
name = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].loadBalancerInfo.elbInfoList[j].name");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupInfoList");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
name = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupInfoList[j].name");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
k = 0;
count_k = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns");
while (k < count_k) {
CkJsonObjectW_putK(jResp,k);
strVal = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns[k]");
k = k + 1;
}
k = 0;
count_k = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups");
while (k < count_k) {
CkJsonObjectW_putK(jResp,k);
name = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups[k].name");
k = k + 1;
}
k = 0;
count_k = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns");
while (k < count_k) {
CkJsonObjectW_putK(jResp,k);
strVal = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns[k]");
k = k + 1;
}
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].onPremisesInstanceTagFilters");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
Key = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].onPremisesInstanceTagFilters[j].Key");
v_Type = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].onPremisesInstanceTagFilters[j].Type");
Value = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].onPremisesInstanceTagFilters[j].Value");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
k = 0;
count_k = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j]");
while (k < count_k) {
CkJsonObjectW_putK(jResp,k);
Key = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j][k].Key");
v_Type = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j][k].Type");
Value = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j][k].Value");
k = k + 1;
}
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].triggerConfigurations");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
triggerName = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].triggerConfigurations[j].triggerName");
triggerTargetArn = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].triggerConfigurations[j].triggerTargetArn");
k = 0;
count_k = CkJsonObjectW_SizeOfArray(jResp,L"deploymentGroupsInfo[i].triggerConfigurations[j].triggerEvents");
while (k < count_k) {
CkJsonObjectW_putK(jResp,k);
strVal = CkJsonObjectW_stringOf(jResp,L"deploymentGroupsInfo[i].triggerConfigurations[j].triggerEvents[k]");
k = k + 1;
}
j = j + 1;
}
i = i + 1;
}
// A sample JSON response body parsed by the above code:
// {
// "deploymentGroupsInfo": [
// {
// "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"
// }
// ]
// }
// ],
// "errorMessage": "string"
// }
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}