ListApplicationComponents 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"migrationhub-strategy");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.SetAuthAws(authAws);
// URL: https://migrationhub-strategy.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = rest.Connect(L"migrationhub-strategy.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"applicationComponentCriteria",L"string");
json.UpdateString(L"filterValue",L"string");
json.UpdateString(L"groupIdFilter[0].name",L"string");
json.UpdateString(L"groupIdFilter[0].value",L"string");
json.UpdateInt(L"maxResults",123);
json.UpdateString(L"nextToken",L"string");
json.UpdateString(L"sort",L"string");
// The JSON request body created by the above code:
// {
// "applicationComponentCriteria": "string",
// "filterValue": "string",
// "groupIdFilter": [
// {
// "name": "string",
// "value": "string"
// }
// ],
// "maxResults": number,
// "nextToken": "string",
// "sort": "string"
// }
rest.AddHeader(L"Content-Type",L"application/x-amz-json-1.1");
rest.AddHeader(L"X-Amz-Target",L"ListApplicationComponents");
CkStringBuilderW sbRequestBody;
json.EmitSb(sbRequestBody);
CkStringBuilderW sbResponseBody;
success = rest.FullRequestSb(L"POST",L"/list-applicationcomponents",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.
const wchar_t *analysisStatus = 0;
const wchar_t *S3Bucket = 0;
const wchar_t *S3key = 0;
const wchar_t *antipatternReportStatus = 0;
const wchar_t *antipatternReportStatusMessage = 0;
const wchar_t *appType = 0;
const wchar_t *associatedServerId = 0;
const wchar_t *SecretName = 0;
const wchar_t *id = 0;
const wchar_t *inclusionStatus = 0;
int lastAnalyzedTimestamp;
int moreServerAssociationExists;
const wchar_t *name = 0;
const wchar_t *osDriver = 0;
const wchar_t *osVersion = 0;
const wchar_t *Strategy = 0;
const wchar_t *TargetDestination = 0;
const wchar_t *Description = 0;
const wchar_t *Name = 0;
const wchar_t *TranformationToolInstallationLink = 0;
const wchar_t *resourceSubType = 0;
const wchar_t *statusMessage = 0;
int j;
int count_j;
int count;
const wchar_t *severity = 0;
const wchar_t *branch = 0;
const wchar_t *repository = 0;
const wchar_t *versionControlType = 0;
const wchar_t *nextToken = jResp.stringOf(L"nextToken");
int i = 0;
int count_i = jResp.SizeOfArray(L"applicationComponentInfos");
while (i < count_i) {
jResp.put_I(i);
analysisStatus = jResp.stringOf(L"applicationComponentInfos[i].analysisStatus");
S3Bucket = jResp.stringOf(L"applicationComponentInfos[i].antipatternReportS3Object.s3Bucket");
S3key = jResp.stringOf(L"applicationComponentInfos[i].antipatternReportS3Object.s3key");
antipatternReportStatus = jResp.stringOf(L"applicationComponentInfos[i].antipatternReportStatus");
antipatternReportStatusMessage = jResp.stringOf(L"applicationComponentInfos[i].antipatternReportStatusMessage");
appType = jResp.stringOf(L"applicationComponentInfos[i].appType");
associatedServerId = jResp.stringOf(L"applicationComponentInfos[i].associatedServerId");
SecretName = jResp.stringOf(L"applicationComponentInfos[i].databaseConfigDetail.secretName");
id = jResp.stringOf(L"applicationComponentInfos[i].id");
inclusionStatus = jResp.stringOf(L"applicationComponentInfos[i].inclusionStatus");
lastAnalyzedTimestamp = jResp.IntOf(L"applicationComponentInfos[i].lastAnalyzedTimestamp");
moreServerAssociationExists = jResp.IntOf(L"applicationComponentInfos[i].moreServerAssociationExists");
name = jResp.stringOf(L"applicationComponentInfos[i].name");
osDriver = jResp.stringOf(L"applicationComponentInfos[i].osDriver");
osVersion = jResp.stringOf(L"applicationComponentInfos[i].osVersion");
Strategy = jResp.stringOf(L"applicationComponentInfos[i].recommendationSet.strategy");
TargetDestination = jResp.stringOf(L"applicationComponentInfos[i].recommendationSet.targetDestination");
Description = jResp.stringOf(L"applicationComponentInfos[i].recommendationSet.transformationTool.description");
Name = jResp.stringOf(L"applicationComponentInfos[i].recommendationSet.transformationTool.name");
TranformationToolInstallationLink = jResp.stringOf(L"applicationComponentInfos[i].recommendationSet.transformationTool.tranformationToolInstallationLink");
resourceSubType = jResp.stringOf(L"applicationComponentInfos[i].resourceSubType");
statusMessage = jResp.stringOf(L"applicationComponentInfos[i].statusMessage");
j = 0;
count_j = jResp.SizeOfArray(L"applicationComponentInfos[i].listAntipatternSeveritySummary");
while (j < count_j) {
jResp.put_J(j);
count = jResp.IntOf(L"applicationComponentInfos[i].listAntipatternSeveritySummary[j].count");
severity = jResp.stringOf(L"applicationComponentInfos[i].listAntipatternSeveritySummary[j].severity");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray(L"applicationComponentInfos[i].sourceCodeRepositories");
while (j < count_j) {
jResp.put_J(j);
branch = jResp.stringOf(L"applicationComponentInfos[i].sourceCodeRepositories[j].branch");
repository = jResp.stringOf(L"applicationComponentInfos[i].sourceCodeRepositories[j].repository");
versionControlType = jResp.stringOf(L"applicationComponentInfos[i].sourceCodeRepositories[j].versionControlType");
j = j + 1;
}
i = i + 1;
}
// A sample JSON response body parsed by the above code:
// {
// "applicationComponentInfos": [
// {
// "analysisStatus": "string",
// "antipatternReportS3Object": {
// "s3Bucket": "string",
// "s3key": "string"
// },
// "antipatternReportStatus": "string",
// "antipatternReportStatusMessage": "string",
// "appType": "string",
// "associatedServerId": "string",
// "databaseConfigDetail": {
// "secretName": "string"
// },
// "id": "string",
// "inclusionStatus": "string",
// "lastAnalyzedTimestamp": number,
// "listAntipatternSeveritySummary": [
// {
// "count": number,
// "severity": "string"
// }
// ],
// "moreServerAssociationExists": boolean,
// "name": "string",
// "osDriver": "string",
// "osVersion": "string",
// "recommendationSet": {
// "strategy": "string",
// "targetDestination": "string",
// "transformationTool": {
// "description": "string",
// "name": "string",
// "tranformationToolInstallationLink": "string"
// }
// },
// "resourceSubType": "string",
// "sourceCodeRepositories": [
// {
// "branch": "string",
// "repository": "string",
// "versionControlType": "string"
// }
// ],
// "statusMessage": "string"
// }
// ],
// "nextToken": "string"
// }
}