GetApplicationComponentDetails C++ Example
#include <CkRest.h>
#include <CkAuthAws.h>
#include <CkStringBuilder.h>
#include <CkJsonObject.h>
void ChilkatSample(void)
{
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkRest rest;
bool success;
CkAuthAws authAws;
authAws.put_AccessKey("AWS_ACCESS_KEY");
authAws.put_SecretKey("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("us-west-2");
authAws.put_ServiceName("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("migrationhub-strategy.us-west-2.amazonaws.com",443,true,true);
if (success != true) {
std::cout << "ConnectFailReason: " << rest.get_ConnectFailReason() << "\r\n";
std::cout << rest.lastErrorText() << "\r\n";
return;
}
rest.AddHeader("Content-Type","application/x-amz-json-1.1");
rest.AddHeader("X-Amz-Target","GetApplicationComponentDetails");
CkStringBuilder sbResponseBody;
success = rest.FullRequestNoBodySb("GET","/get-applicationcomponent-details/{applicationComponentId}",sbResponseBody);
if (success != true) {
std::cout << rest.lastErrorText() << "\r\n";
return;
}
int respStatusCode = rest.get_ResponseStatusCode();
std::cout << "response status code = " << respStatusCode << "\r\n";
if (respStatusCode != 200) {
std::cout << "Response Header:" << "\r\n";
std::cout << rest.responseHeader() << "\r\n";
std::cout << "Response Body:" << "\r\n";
std::cout << sbResponseBody.getAsString() << "\r\n";
return;
}
CkJsonObject 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 count;
const char *severity = 0;
const char *branch = 0;
const char *repository = 0;
const char *versionControlType = 0;
const char *id = 0;
const char *name = 0;
const char *strVal = 0;
const char *AnalysisStatus = jResp.stringOf("applicationComponentDetail.analysisStatus");
const char *S3Bucket = jResp.stringOf("applicationComponentDetail.antipatternReportS3Object.s3Bucket");
const char *S3key = jResp.stringOf("applicationComponentDetail.antipatternReportS3Object.s3key");
const char *AntipatternReportStatus = jResp.stringOf("applicationComponentDetail.antipatternReportStatus");
const char *AntipatternReportStatusMessage = jResp.stringOf("applicationComponentDetail.antipatternReportStatusMessage");
const char *AppType = jResp.stringOf("applicationComponentDetail.appType");
const char *AssociatedServerId = jResp.stringOf("applicationComponentDetail.associatedServerId");
const char *SecretName = jResp.stringOf("applicationComponentDetail.databaseConfigDetail.secretName");
const char *Id = jResp.stringOf("applicationComponentDetail.id");
const char *InclusionStatus = jResp.stringOf("applicationComponentDetail.inclusionStatus");
int LastAnalyzedTimestamp = jResp.IntOf("applicationComponentDetail.lastAnalyzedTimestamp");
int MoreServerAssociationExists = jResp.IntOf("applicationComponentDetail.moreServerAssociationExists");
const char *Name = jResp.stringOf("applicationComponentDetail.name");
const char *OsDriver = jResp.stringOf("applicationComponentDetail.osDriver");
const char *OsVersion = jResp.stringOf("applicationComponentDetail.osVersion");
const char *Strategy = jResp.stringOf("applicationComponentDetail.recommendationSet.strategy");
const char *TargetDestination = jResp.stringOf("applicationComponentDetail.recommendationSet.targetDestination");
const char *Description = jResp.stringOf("applicationComponentDetail.recommendationSet.transformationTool.description");
const char *TransformationToolName = jResp.stringOf("applicationComponentDetail.recommendationSet.transformationTool.name");
const char *TranformationToolInstallationLink = jResp.stringOf("applicationComponentDetail.recommendationSet.transformationTool.tranformationToolInstallationLink");
const char *ResourceSubType = jResp.stringOf("applicationComponentDetail.resourceSubType");
const char *StatusMessage = jResp.stringOf("applicationComponentDetail.statusMessage");
int moreApplicationResource = jResp.IntOf("moreApplicationResource");
int i = 0;
int count_i = jResp.SizeOfArray("applicationComponentDetail.listAntipatternSeveritySummary");
while (i < count_i) {
jResp.put_I(i);
count = jResp.IntOf("applicationComponentDetail.listAntipatternSeveritySummary[i].count");
severity = jResp.stringOf("applicationComponentDetail.listAntipatternSeveritySummary[i].severity");
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray("applicationComponentDetail.sourceCodeRepositories");
while (i < count_i) {
jResp.put_I(i);
branch = jResp.stringOf("applicationComponentDetail.sourceCodeRepositories[i].branch");
repository = jResp.stringOf("applicationComponentDetail.sourceCodeRepositories[i].repository");
versionControlType = jResp.stringOf("applicationComponentDetail.sourceCodeRepositories[i].versionControlType");
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray("associatedApplications");
while (i < count_i) {
jResp.put_I(i);
id = jResp.stringOf("associatedApplications[i].id");
name = jResp.stringOf("associatedApplications[i].name");
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray("associatedServerIds");
while (i < count_i) {
jResp.put_I(i);
strVal = jResp.stringOf("associatedServerIds[i]");
i = i + 1;
}
// A sample JSON response body parsed by the above code:
// {
// "applicationComponentDetail": {
// "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"
// },
// "associatedApplications": [
// {
// "id": "string",
// "name": "string"
// }
// ],
// "associatedServerIds": [
// "string"
// ],
// "moreApplicationResource": boolean
// }
}