ListLicenseConfigurations 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"license-manager");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.SetAuthAws(authAws);
// URL: https://license-manager.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = rest.Connect(L"license-manager.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"Filters[0].Name",L"string");
json.UpdateString(L"Filters[0].Values[0]",L"string");
json.UpdateString(L"LicenseConfigurationArns[0]",L"string");
json.UpdateInt(L"MaxResults",123);
json.UpdateString(L"NextToken",L"string");
// The JSON request body created by the above code:
// {
// "Filters": [
// {
// "Name": "string",
// "Values": [
// "string"
// ]
// }
// ],
// "LicenseConfigurationArns": [
// "string"
// ],
// "MaxResults": number,
// "NextToken": "string"
// }
rest.AddHeader(L"Content-Type",L"application/x-amz-json-1.1");
rest.AddHeader(L"X-Amz-Target",L"AWSLicenseManager.ListLicenseConfigurations");
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 LastRunTime;
int ConsumedLicenses;
const wchar_t *Description = 0;
int DisassociateWhenNotFound;
const wchar_t *LicenseConfigurationArn = 0;
const wchar_t *LicenseConfigurationId = 0;
int LicenseCount;
int LicenseCountHardLimit;
const wchar_t *LicenseCountingType = 0;
const wchar_t *Name = 0;
const wchar_t *OwnerAccountId = 0;
const wchar_t *Status = 0;
int j;
int count_j;
const wchar_t *ResourceType = 0;
const wchar_t *strVal = 0;
int AssociationCount;
int k;
int count_k;
const wchar_t *ProductInformationFilterComparator = 0;
const wchar_t *ProductInformationFilterName = 0;
CkJsonObjectW *json1 = 0;
int i1;
int count_i1;
const wchar_t *NextToken = jResp.stringOf(L"NextToken");
int i = 0;
int count_i = jResp.SizeOfArray(L"LicenseConfigurations");
while (i < count_i) {
jResp.put_I(i);
LastRunTime = jResp.IntOf(L"LicenseConfigurations[i].AutomatedDiscoveryInformation.LastRunTime");
ConsumedLicenses = jResp.IntOf(L"LicenseConfigurations[i].ConsumedLicenses");
Description = jResp.stringOf(L"LicenseConfigurations[i].Description");
DisassociateWhenNotFound = jResp.IntOf(L"LicenseConfigurations[i].DisassociateWhenNotFound");
LicenseConfigurationArn = jResp.stringOf(L"LicenseConfigurations[i].LicenseConfigurationArn");
LicenseConfigurationId = jResp.stringOf(L"LicenseConfigurations[i].LicenseConfigurationId");
LicenseCount = jResp.IntOf(L"LicenseConfigurations[i].LicenseCount");
LicenseCountHardLimit = jResp.IntOf(L"LicenseConfigurations[i].LicenseCountHardLimit");
LicenseCountingType = jResp.stringOf(L"LicenseConfigurations[i].LicenseCountingType");
Name = jResp.stringOf(L"LicenseConfigurations[i].Name");
OwnerAccountId = jResp.stringOf(L"LicenseConfigurations[i].OwnerAccountId");
Status = jResp.stringOf(L"LicenseConfigurations[i].Status");
j = 0;
count_j = jResp.SizeOfArray(L"LicenseConfigurations[i].ConsumedLicenseSummaryList");
while (j < count_j) {
jResp.put_J(j);
ConsumedLicenses = jResp.IntOf(L"LicenseConfigurations[i].ConsumedLicenseSummaryList[j].ConsumedLicenses");
ResourceType = jResp.stringOf(L"LicenseConfigurations[i].ConsumedLicenseSummaryList[j].ResourceType");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"LicenseConfigurations[i].LicenseRules");
while (j < count_j) {
jResp.put_J(j);
strVal = jResp.stringOf(L"LicenseConfigurations[i].LicenseRules[j]");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"LicenseConfigurations[i].ManagedResourceSummaryList");
while (j < count_j) {
jResp.put_J(j);
AssociationCount = jResp.IntOf(L"LicenseConfigurations[i].ManagedResourceSummaryList[j].AssociationCount");
ResourceType = jResp.stringOf(L"LicenseConfigurations[i].ManagedResourceSummaryList[j].ResourceType");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"LicenseConfigurations[i].ProductInformationList");
while (j < count_j) {
jResp.put_J(j);
ResourceType = jResp.stringOf(L"LicenseConfigurations[i].ProductInformationList[j].ResourceType");
k = 0;
count_k = jResp.SizeOfArray(L"LicenseConfigurations[i].ProductInformationList[j].ProductInformationFilterList");
while (k < count_k) {
jResp.put_K(k);
ProductInformationFilterComparator = jResp.stringOf(L"LicenseConfigurations[i].ProductInformationList[j].ProductInformationFilterList[k].ProductInformationFilterComparator");
ProductInformationFilterName = jResp.stringOf(L"LicenseConfigurations[i].ProductInformationList[j].ProductInformationFilterList[k].ProductInformationFilterName");
json1 = jResp.ObjectOf(L"LicenseConfigurations[i].ProductInformationList[j].ProductInformationFilterList[k]");
i1 = 0;
count_i1 = json1->SizeOfArray(L"ProductInformationFilterValue");
while (i1 < count_i1) {
json1->put_I(i1);
strVal = json1->stringOf(L"ProductInformationFilterValue[i]");
i1 = i1 + 1;
}
delete json1;
k = k + 1;
}
j = j + 1;
}
i = i + 1;
}
// A sample JSON response body parsed by the above code:
// {
// "LicenseConfigurations": [
// {
// "AutomatedDiscoveryInformation": {
// "LastRunTime": number
// },
// "ConsumedLicenses": number,
// "ConsumedLicenseSummaryList": [
// {
// "ConsumedLicenses": number,
// "ResourceType": "string"
// }
// ],
// "Description": "string",
// "DisassociateWhenNotFound": boolean,
// "LicenseConfigurationArn": "string",
// "LicenseConfigurationId": "string",
// "LicenseCount": number,
// "LicenseCountHardLimit": boolean,
// "LicenseCountingType": "string",
// "LicenseRules": [
// "string"
// ],
// "ManagedResourceSummaryList": [
// {
// "AssociationCount": number,
// "ResourceType": "string"
// }
// ],
// "Name": "string",
// "OwnerAccountId": "string",
// "ProductInformationList": [
// {
// "ProductInformationFilterList": [
// {
// "ProductInformationFilterComparator": "string",
// "ProductInformationFilterName": "string",
// "ProductInformationFilterValue": [
// "string"
// ]
// }
// ],
// "ResourceType": "string"
// }
// ],
// "Status": "string"
// }
// ],
// "NextToken": "string"
// }
}