BatchGetDeploymentGroups unicodeCpp Example
#include <CkRestW.h>
#include <CkAuthAwsW.h>
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>
void ChilkatSample(void)
{
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkRestW rest;
bool success;
CkAuthAwsW authAws;
authAws.put_AccessKey(L"AWS_ACCESS_KEY");
authAws.put_SecretKey(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.)
authAws.put_Region(L"us-west-2");
authAws.put_ServiceName(L"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(L"codedeploy.us-west-2.amazonaws.com",443,true,true);
if (success != true) {
wprintf(L"ConnectFailReason: %d\n",rest.get_ConnectFailReason());
wprintf(L"%s\n",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
CkJsonObjectW json;
json.UpdateString(L"applicationName",L"string");
json.UpdateString(L"deploymentGroupNames[0]",L"string");
// The JSON request body created by the above code:
// {
// "applicationName": "string",
// "deploymentGroupNames": [
// "string"
// ]
// }
rest.AddHeader(L"Content-Type",L"application/x-amz-json-1.1");
rest.AddHeader(L"X-Amz-Target",L"CodeDeploy_20141006.BatchGetDeploymentGroups");
CkStringBuilderW sbRequestBody;
json.EmitSb(sbRequestBody);
CkStringBuilderW sbResponseBody;
success = rest.FullRequestSb(L"POST",L"/",sbRequestBody,sbResponseBody);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
int respStatusCode = rest.get_ResponseStatusCode();
wprintf(L"response status code = %d\n",respStatusCode);
if (respStatusCode != 200) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",rest.responseHeader());
wprintf(L"Response Body:\n");
wprintf(L"%s\n",sbResponseBody.getAsString());
return;
}
CkJsonObjectW jResp;
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
// 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.
int Enabled;
int IgnorePollAlarmFailure;
const wchar_t *applicationName = 0;
int autoRollbackConfigurationEnabled;
const wchar_t *ActionOnTimeout = 0;
int WaitTimeInMinutes;
const wchar_t *Action = 0;
const wchar_t *TerminateBlueInstancesOnDeploymentSuccessAction = 0;
int TerminationWaitTimeInMinutes;
const wchar_t *computePlatform = 0;
const wchar_t *deploymentConfigName = 0;
const wchar_t *deploymentGroupId = 0;
const wchar_t *deploymentGroupName = 0;
const wchar_t *DeploymentOption = 0;
const wchar_t *DeploymentType = 0;
int CreateTime;
const wchar_t *DeploymentId = 0;
int EndTime;
const wchar_t *Status = 0;
int lastSuccessfulDeploymentCreateTime;
const wchar_t *lastSuccessfulDeploymentDeploymentId = 0;
int lastSuccessfulDeploymentEndTime;
const wchar_t *lastSuccessfulDeploymentStatus = 0;
const wchar_t *outdatedInstancesStrategy = 0;
const wchar_t *serviceRoleArn = 0;
const wchar_t *Content = 0;
const wchar_t *Sha256 = 0;
const wchar_t *CommitId = 0;
const wchar_t *Repository = 0;
const wchar_t *RevisionType = 0;
const wchar_t *Bucket = 0;
const wchar_t *BundleType = 0;
const wchar_t *ETag = 0;
const wchar_t *Key = 0;
const wchar_t *Version = 0;
const wchar_t *StringContent = 0;
const wchar_t *StringSha256 = 0;
int j;
int count_j;
const wchar_t *name = 0;
const wchar_t *strVal = 0;
const wchar_t *hook = 0;
const wchar_t *v_Type = 0;
const wchar_t *Value = 0;
int k;
int count_k;
const wchar_t *clusterName = 0;
const wchar_t *serviceName = 0;
const wchar_t *triggerName = 0;
const wchar_t *triggerTargetArn = 0;
const wchar_t *errorMessage = jResp.stringOf(L"errorMessage");
int i = 0;
int count_i = jResp.SizeOfArray(L"deploymentGroupsInfo");
while (i < count_i) {
jResp.put_I(i);
Enabled = jResp.IntOf(L"deploymentGroupsInfo[i].alarmConfiguration.enabled");
IgnorePollAlarmFailure = jResp.IntOf(L"deploymentGroupsInfo[i].alarmConfiguration.ignorePollAlarmFailure");
applicationName = jResp.stringOf(L"deploymentGroupsInfo[i].applicationName");
autoRollbackConfigurationEnabled = jResp.IntOf(L"deploymentGroupsInfo[i].autoRollbackConfiguration.enabled");
ActionOnTimeout = jResp.stringOf(L"deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.actionOnTimeout");
WaitTimeInMinutes = jResp.IntOf(L"deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes");
Action = jResp.stringOf(L"deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.greenFleetProvisioningOption.action");
TerminateBlueInstancesOnDeploymentSuccessAction = jResp.stringOf(L"deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.action");
TerminationWaitTimeInMinutes = jResp.IntOf(L"deploymentGroupsInfo[i].blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes");
computePlatform = jResp.stringOf(L"deploymentGroupsInfo[i].computePlatform");
deploymentConfigName = jResp.stringOf(L"deploymentGroupsInfo[i].deploymentConfigName");
deploymentGroupId = jResp.stringOf(L"deploymentGroupsInfo[i].deploymentGroupId");
deploymentGroupName = jResp.stringOf(L"deploymentGroupsInfo[i].deploymentGroupName");
DeploymentOption = jResp.stringOf(L"deploymentGroupsInfo[i].deploymentStyle.deploymentOption");
DeploymentType = jResp.stringOf(L"deploymentGroupsInfo[i].deploymentStyle.deploymentType");
CreateTime = jResp.IntOf(L"deploymentGroupsInfo[i].lastAttemptedDeployment.createTime");
DeploymentId = jResp.stringOf(L"deploymentGroupsInfo[i].lastAttemptedDeployment.deploymentId");
EndTime = jResp.IntOf(L"deploymentGroupsInfo[i].lastAttemptedDeployment.endTime");
Status = jResp.stringOf(L"deploymentGroupsInfo[i].lastAttemptedDeployment.status");
lastSuccessfulDeploymentCreateTime = jResp.IntOf(L"deploymentGroupsInfo[i].lastSuccessfulDeployment.createTime");
lastSuccessfulDeploymentDeploymentId = jResp.stringOf(L"deploymentGroupsInfo[i].lastSuccessfulDeployment.deploymentId");
lastSuccessfulDeploymentEndTime = jResp.IntOf(L"deploymentGroupsInfo[i].lastSuccessfulDeployment.endTime");
lastSuccessfulDeploymentStatus = jResp.stringOf(L"deploymentGroupsInfo[i].lastSuccessfulDeployment.status");
outdatedInstancesStrategy = jResp.stringOf(L"deploymentGroupsInfo[i].outdatedInstancesStrategy");
serviceRoleArn = jResp.stringOf(L"deploymentGroupsInfo[i].serviceRoleArn");
Content = jResp.stringOf(L"deploymentGroupsInfo[i].targetRevision.appSpecContent.content");
Sha256 = jResp.stringOf(L"deploymentGroupsInfo[i].targetRevision.appSpecContent.sha256");
CommitId = jResp.stringOf(L"deploymentGroupsInfo[i].targetRevision.gitHubLocation.commitId");
Repository = jResp.stringOf(L"deploymentGroupsInfo[i].targetRevision.gitHubLocation.repository");
RevisionType = jResp.stringOf(L"deploymentGroupsInfo[i].targetRevision.revisionType");
Bucket = jResp.stringOf(L"deploymentGroupsInfo[i].targetRevision.s3Location.bucket");
BundleType = jResp.stringOf(L"deploymentGroupsInfo[i].targetRevision.s3Location.bundleType");
ETag = jResp.stringOf(L"deploymentGroupsInfo[i].targetRevision.s3Location.eTag");
Key = jResp.stringOf(L"deploymentGroupsInfo[i].targetRevision.s3Location.key");
Version = jResp.stringOf(L"deploymentGroupsInfo[i].targetRevision.s3Location.version");
StringContent = jResp.stringOf(L"deploymentGroupsInfo[i].targetRevision.string.content");
StringSha256 = jResp.stringOf(L"deploymentGroupsInfo[i].targetRevision.string.sha256");
j = 0;
count_j = jResp.SizeOfArray(L"deploymentGroupsInfo[i].alarmConfiguration.alarms");
while (j < count_j) {
jResp.put_J(j);
name = jResp.stringOf(L"deploymentGroupsInfo[i].alarmConfiguration.alarms[j].name");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"deploymentGroupsInfo[i].autoRollbackConfiguration.events");
while (j < count_j) {
jResp.put_J(j);
strVal = jResp.stringOf(L"deploymentGroupsInfo[i].autoRollbackConfiguration.events[j]");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"deploymentGroupsInfo[i].autoScalingGroups");
while (j < count_j) {
jResp.put_J(j);
hook = jResp.stringOf(L"deploymentGroupsInfo[i].autoScalingGroups[j].hook");
name = jResp.stringOf(L"deploymentGroupsInfo[i].autoScalingGroups[j].name");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"deploymentGroupsInfo[i].ec2TagFilters");
while (j < count_j) {
jResp.put_J(j);
Key = jResp.stringOf(L"deploymentGroupsInfo[i].ec2TagFilters[j].Key");
v_Type = jResp.stringOf(L"deploymentGroupsInfo[i].ec2TagFilters[j].Type");
Value = jResp.stringOf(L"deploymentGroupsInfo[i].ec2TagFilters[j].Value");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList");
while (j < count_j) {
jResp.put_J(j);
k = 0;
count_k = jResp.SizeOfArray(L"deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j]");
while (k < count_k) {
jResp.put_K(k);
Key = jResp.stringOf(L"deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j][k].Key");
v_Type = jResp.stringOf(L"deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j][k].Type");
Value = jResp.stringOf(L"deploymentGroupsInfo[i].ec2TagSet.ec2TagSetList[j][k].Value");
k = k + 1;
}
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"deploymentGroupsInfo[i].ecsServices");
while (j < count_j) {
jResp.put_J(j);
clusterName = jResp.stringOf(L"deploymentGroupsInfo[i].ecsServices[j].clusterName");
serviceName = jResp.stringOf(L"deploymentGroupsInfo[i].ecsServices[j].serviceName");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"deploymentGroupsInfo[i].loadBalancerInfo.elbInfoList");
while (j < count_j) {
jResp.put_J(j);
name = jResp.stringOf(L"deploymentGroupsInfo[i].loadBalancerInfo.elbInfoList[j].name");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupInfoList");
while (j < count_j) {
jResp.put_J(j);
name = jResp.stringOf(L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupInfoList[j].name");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList");
while (j < count_j) {
jResp.put_J(j);
k = 0;
count_k = jResp.SizeOfArray(L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns");
while (k < count_k) {
jResp.put_K(k);
strVal = jResp.stringOf(L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].prodTrafficRoute.listenerArns[k]");
k = k + 1;
}
k = 0;
count_k = jResp.SizeOfArray(L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups");
while (k < count_k) {
jResp.put_K(k);
name = jResp.stringOf(L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].targetGroups[k].name");
k = k + 1;
}
k = 0;
count_k = jResp.SizeOfArray(L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns");
while (k < count_k) {
jResp.put_K(k);
strVal = jResp.stringOf(L"deploymentGroupsInfo[i].loadBalancerInfo.targetGroupPairInfoList[j].testTrafficRoute.listenerArns[k]");
k = k + 1;
}
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"deploymentGroupsInfo[i].onPremisesInstanceTagFilters");
while (j < count_j) {
jResp.put_J(j);
Key = jResp.stringOf(L"deploymentGroupsInfo[i].onPremisesInstanceTagFilters[j].Key");
v_Type = jResp.stringOf(L"deploymentGroupsInfo[i].onPremisesInstanceTagFilters[j].Type");
Value = jResp.stringOf(L"deploymentGroupsInfo[i].onPremisesInstanceTagFilters[j].Value");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList");
while (j < count_j) {
jResp.put_J(j);
k = 0;
count_k = jResp.SizeOfArray(L"deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j]");
while (k < count_k) {
jResp.put_K(k);
Key = jResp.stringOf(L"deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j][k].Key");
v_Type = jResp.stringOf(L"deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j][k].Type");
Value = jResp.stringOf(L"deploymentGroupsInfo[i].onPremisesTagSet.onPremisesTagSetList[j][k].Value");
k = k + 1;
}
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"deploymentGroupsInfo[i].triggerConfigurations");
while (j < count_j) {
jResp.put_J(j);
triggerName = jResp.stringOf(L"deploymentGroupsInfo[i].triggerConfigurations[j].triggerName");
triggerTargetArn = jResp.stringOf(L"deploymentGroupsInfo[i].triggerConfigurations[j].triggerTargetArn");
k = 0;
count_k = jResp.SizeOfArray(L"deploymentGroupsInfo[i].triggerConfigurations[j].triggerEvents");
while (k < count_k) {
jResp.put_K(k);
strVal = jResp.stringOf(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"
// }
}