DescribeLayers 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 *Arn;
const wchar_t *v_String;
int AutoAssignElasticIps;
int AutoAssignPublicIps;
int Enabled;
const wchar_t *CreatedAt;
const wchar_t *CustomInstanceProfileArn;
const wchar_t *CustomJson;
int EnableAutoHealing;
int InstallUpdatesOnBoot;
const wchar_t *LayerId;
int DelayUntilElbConnectionsDrained;
int ExecutionTimeout;
const wchar_t *Name;
const wchar_t *Shortname;
const wchar_t *StackId;
const wchar_t *v_Type;
int UseEbsOptimizedInstances;
int j;
int count_j;
int BatchCount;
int BatchSize;
int BufferDuration;
const wchar_t *DatetimeFormat;
const wchar_t *Encoding;
const wchar_t *File;
const wchar_t *FileFingerprintLines;
const wchar_t *InitialPosition;
const wchar_t *LogGroupName;
const wchar_t *MultiLineStartPattern;
const wchar_t *TimeZone;
const wchar_t *strVal;
int Encrypted;
int Iops;
const wchar_t *MountPoint;
int NumberOfDisks;
int RaidLevel;
int Size;
const wchar_t *VolumeType;
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"opsworks");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRestW_SetAuthAws(rest,authAws);
// URL: https://opsworks.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = CkRestW_Connect(rest,L"opsworks.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"LayerIds[0]",L"string");
CkJsonObjectW_UpdateString(json,L"StackId",L"string");
// The JSON request body created by the above code:
// {
// "LayerIds": [
// "string"
// ],
// "StackId": "string"
// }
CkRestW_AddHeader(rest,L"Content-Type",L"application/x-amz-json-1.1");
CkRestW_AddHeader(rest,L"X-Amz-Target",L"OpsWorks_20130218.DescribeLayers");
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"Layers");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
Arn = CkJsonObjectW_stringOf(jResp,L"Layers[i].Arn");
v_String = CkJsonObjectW_stringOf(jResp,L"Layers[i].Attributes.string");
AutoAssignElasticIps = CkJsonObjectW_IntOf(jResp,L"Layers[i].AutoAssignElasticIps");
AutoAssignPublicIps = CkJsonObjectW_IntOf(jResp,L"Layers[i].AutoAssignPublicIps");
Enabled = CkJsonObjectW_IntOf(jResp,L"Layers[i].CloudWatchLogsConfiguration.Enabled");
CreatedAt = CkJsonObjectW_stringOf(jResp,L"Layers[i].CreatedAt");
CustomInstanceProfileArn = CkJsonObjectW_stringOf(jResp,L"Layers[i].CustomInstanceProfileArn");
CustomJson = CkJsonObjectW_stringOf(jResp,L"Layers[i].CustomJson");
EnableAutoHealing = CkJsonObjectW_IntOf(jResp,L"Layers[i].EnableAutoHealing");
InstallUpdatesOnBoot = CkJsonObjectW_IntOf(jResp,L"Layers[i].InstallUpdatesOnBoot");
LayerId = CkJsonObjectW_stringOf(jResp,L"Layers[i].LayerId");
DelayUntilElbConnectionsDrained = CkJsonObjectW_IntOf(jResp,L"Layers[i].LifecycleEventConfiguration.Shutdown.DelayUntilElbConnectionsDrained");
ExecutionTimeout = CkJsonObjectW_IntOf(jResp,L"Layers[i].LifecycleEventConfiguration.Shutdown.ExecutionTimeout");
Name = CkJsonObjectW_stringOf(jResp,L"Layers[i].Name");
Shortname = CkJsonObjectW_stringOf(jResp,L"Layers[i].Shortname");
StackId = CkJsonObjectW_stringOf(jResp,L"Layers[i].StackId");
v_Type = CkJsonObjectW_stringOf(jResp,L"Layers[i].Type");
UseEbsOptimizedInstances = CkJsonObjectW_IntOf(jResp,L"Layers[i].UseEbsOptimizedInstances");
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].CloudWatchLogsConfiguration.LogStreams");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
BatchCount = CkJsonObjectW_IntOf(jResp,L"Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BatchCount");
BatchSize = CkJsonObjectW_IntOf(jResp,L"Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BatchSize");
BufferDuration = CkJsonObjectW_IntOf(jResp,L"Layers[i].CloudWatchLogsConfiguration.LogStreams[j].BufferDuration");
DatetimeFormat = CkJsonObjectW_stringOf(jResp,L"Layers[i].CloudWatchLogsConfiguration.LogStreams[j].DatetimeFormat");
Encoding = CkJsonObjectW_stringOf(jResp,L"Layers[i].CloudWatchLogsConfiguration.LogStreams[j].Encoding");
File = CkJsonObjectW_stringOf(jResp,L"Layers[i].CloudWatchLogsConfiguration.LogStreams[j].File");
FileFingerprintLines = CkJsonObjectW_stringOf(jResp,L"Layers[i].CloudWatchLogsConfiguration.LogStreams[j].FileFingerprintLines");
InitialPosition = CkJsonObjectW_stringOf(jResp,L"Layers[i].CloudWatchLogsConfiguration.LogStreams[j].InitialPosition");
LogGroupName = CkJsonObjectW_stringOf(jResp,L"Layers[i].CloudWatchLogsConfiguration.LogStreams[j].LogGroupName");
MultiLineStartPattern = CkJsonObjectW_stringOf(jResp,L"Layers[i].CloudWatchLogsConfiguration.LogStreams[j].MultiLineStartPattern");
TimeZone = CkJsonObjectW_stringOf(jResp,L"Layers[i].CloudWatchLogsConfiguration.LogStreams[j].TimeZone");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].CustomRecipes.Configure");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"Layers[i].CustomRecipes.Configure[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].CustomRecipes.Deploy");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"Layers[i].CustomRecipes.Deploy[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].CustomRecipes.Setup");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"Layers[i].CustomRecipes.Setup[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].CustomRecipes.Shutdown");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"Layers[i].CustomRecipes.Shutdown[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].CustomRecipes.Undeploy");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"Layers[i].CustomRecipes.Undeploy[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].CustomSecurityGroupIds");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"Layers[i].CustomSecurityGroupIds[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].DefaultRecipes.Configure");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"Layers[i].DefaultRecipes.Configure[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].DefaultRecipes.Deploy");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"Layers[i].DefaultRecipes.Deploy[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].DefaultRecipes.Setup");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"Layers[i].DefaultRecipes.Setup[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].DefaultRecipes.Shutdown");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"Layers[i].DefaultRecipes.Shutdown[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].DefaultRecipes.Undeploy");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"Layers[i].DefaultRecipes.Undeploy[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].DefaultSecurityGroupNames");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"Layers[i].DefaultSecurityGroupNames[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].Packages");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"Layers[i].Packages[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"Layers[i].VolumeConfigurations");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
Encrypted = CkJsonObjectW_IntOf(jResp,L"Layers[i].VolumeConfigurations[j].Encrypted");
Iops = CkJsonObjectW_IntOf(jResp,L"Layers[i].VolumeConfigurations[j].Iops");
MountPoint = CkJsonObjectW_stringOf(jResp,L"Layers[i].VolumeConfigurations[j].MountPoint");
NumberOfDisks = CkJsonObjectW_IntOf(jResp,L"Layers[i].VolumeConfigurations[j].NumberOfDisks");
RaidLevel = CkJsonObjectW_IntOf(jResp,L"Layers[i].VolumeConfigurations[j].RaidLevel");
Size = CkJsonObjectW_IntOf(jResp,L"Layers[i].VolumeConfigurations[j].Size");
VolumeType = CkJsonObjectW_stringOf(jResp,L"Layers[i].VolumeConfigurations[j].VolumeType");
j = j + 1;
}
i = i + 1;
}
// A sample JSON response body parsed by the above code:
// {
// "Layers": [
// {
// "Arn": "string",
// "Attributes": {
// "string": "string"
// },
// "AutoAssignElasticIps": boolean,
// "AutoAssignPublicIps": boolean,
// "CloudWatchLogsConfiguration": {
// "Enabled": boolean,
// "LogStreams": [
// {
// "BatchCount": number,
// "BatchSize": number,
// "BufferDuration": number,
// "DatetimeFormat": "string",
// "Encoding": "string",
// "File": "string",
// "FileFingerprintLines": "string",
// "InitialPosition": "string",
// "LogGroupName": "string",
// "MultiLineStartPattern": "string",
// "TimeZone": "string"
// }
// ]
// },
// "CreatedAt": "string",
// "CustomInstanceProfileArn": "string",
// "CustomJson": "string",
// "CustomRecipes": {
// "Configure": [
// "string"
// ],
// "Deploy": [
// "string"
// ],
// "Setup": [
// "string"
// ],
// "Shutdown": [
// "string"
// ],
// "Undeploy": [
// "string"
// ]
// },
// "CustomSecurityGroupIds": [
// "string"
// ],
// "DefaultRecipes": {
// "Configure": [
// "string"
// ],
// "Deploy": [
// "string"
// ],
// "Setup": [
// "string"
// ],
// "Shutdown": [
// "string"
// ],
// "Undeploy": [
// "string"
// ]
// },
// "DefaultSecurityGroupNames": [
// "string"
// ],
// "EnableAutoHealing": boolean,
// "InstallUpdatesOnBoot": boolean,
// "LayerId": "string",
// "LifecycleEventConfiguration": {
// "Shutdown": {
// "DelayUntilElbConnectionsDrained": boolean,
// "ExecutionTimeout": number
// }
// },
// "Name": "string",
// "Packages": [
// "string"
// ],
// "Shortname": "string",
// "StackId": "string",
// "Type": "string",
// "UseEbsOptimizedInstances": boolean,
// "VolumeConfigurations": [
// {
// "Encrypted": boolean,
// "Iops": number,
// "MountPoint": "string",
// "NumberOfDisks": number,
// "RaidLevel": number,
// "Size": number,
// "VolumeType": "string"
// }
// ]
// }
// ]
// }
CkRestW_Dispose(rest);
CkAuthAwsW_Dispose(authAws);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}