Chilkat Online Tools

GetApplicationComponentDetails unicodeCpp Example

Migration Hub Strategy Recommendations

#include <CkRestW.h>
#include <CkAuthAwsW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.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;
    }

    rest.AddHeader(L"Content-Type",L"application/x-amz-json-1.1");
    rest.AddHeader(L"X-Amz-Target",L"GetApplicationComponentDetails");

    CkStringBuilderW sbResponseBody;
    success = rest.FullRequestNoBodySb(L"GET",L"/get-applicationcomponent-details/{applicationComponentId}",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 count;
    const wchar_t *severity = 0;
    const wchar_t *branch = 0;
    const wchar_t *repository = 0;
    const wchar_t *versionControlType = 0;
    const wchar_t *id = 0;
    const wchar_t *name = 0;
    const wchar_t *strVal = 0;

    const wchar_t *AnalysisStatus = jResp.stringOf(L"applicationComponentDetail.analysisStatus");
    const wchar_t *S3Bucket = jResp.stringOf(L"applicationComponentDetail.antipatternReportS3Object.s3Bucket");
    const wchar_t *S3key = jResp.stringOf(L"applicationComponentDetail.antipatternReportS3Object.s3key");
    const wchar_t *AntipatternReportStatus = jResp.stringOf(L"applicationComponentDetail.antipatternReportStatus");
    const wchar_t *AntipatternReportStatusMessage = jResp.stringOf(L"applicationComponentDetail.antipatternReportStatusMessage");
    const wchar_t *AppType = jResp.stringOf(L"applicationComponentDetail.appType");
    const wchar_t *AssociatedServerId = jResp.stringOf(L"applicationComponentDetail.associatedServerId");
    const wchar_t *SecretName = jResp.stringOf(L"applicationComponentDetail.databaseConfigDetail.secretName");
    const wchar_t *Id = jResp.stringOf(L"applicationComponentDetail.id");
    const wchar_t *InclusionStatus = jResp.stringOf(L"applicationComponentDetail.inclusionStatus");
    int LastAnalyzedTimestamp = jResp.IntOf(L"applicationComponentDetail.lastAnalyzedTimestamp");
    int MoreServerAssociationExists = jResp.IntOf(L"applicationComponentDetail.moreServerAssociationExists");
    const wchar_t *Name = jResp.stringOf(L"applicationComponentDetail.name");
    const wchar_t *OsDriver = jResp.stringOf(L"applicationComponentDetail.osDriver");
    const wchar_t *OsVersion = jResp.stringOf(L"applicationComponentDetail.osVersion");
    const wchar_t *Strategy = jResp.stringOf(L"applicationComponentDetail.recommendationSet.strategy");
    const wchar_t *TargetDestination = jResp.stringOf(L"applicationComponentDetail.recommendationSet.targetDestination");
    const wchar_t *Description = jResp.stringOf(L"applicationComponentDetail.recommendationSet.transformationTool.description");
    const wchar_t *TransformationToolName = jResp.stringOf(L"applicationComponentDetail.recommendationSet.transformationTool.name");
    const wchar_t *TranformationToolInstallationLink = jResp.stringOf(L"applicationComponentDetail.recommendationSet.transformationTool.tranformationToolInstallationLink");
    const wchar_t *ResourceSubType = jResp.stringOf(L"applicationComponentDetail.resourceSubType");
    const wchar_t *StatusMessage = jResp.stringOf(L"applicationComponentDetail.statusMessage");
    int moreApplicationResource = jResp.IntOf(L"moreApplicationResource");
    int i = 0;
    int count_i = jResp.SizeOfArray(L"applicationComponentDetail.listAntipatternSeveritySummary");
    while (i < count_i) {
        jResp.put_I(i);
        count = jResp.IntOf(L"applicationComponentDetail.listAntipatternSeveritySummary[i].count");
        severity = jResp.stringOf(L"applicationComponentDetail.listAntipatternSeveritySummary[i].severity");
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray(L"applicationComponentDetail.sourceCodeRepositories");
    while (i < count_i) {
        jResp.put_I(i);
        branch = jResp.stringOf(L"applicationComponentDetail.sourceCodeRepositories[i].branch");
        repository = jResp.stringOf(L"applicationComponentDetail.sourceCodeRepositories[i].repository");
        versionControlType = jResp.stringOf(L"applicationComponentDetail.sourceCodeRepositories[i].versionControlType");
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray(L"associatedApplications");
    while (i < count_i) {
        jResp.put_I(i);
        id = jResp.stringOf(L"associatedApplications[i].id");
        name = jResp.stringOf(L"associatedApplications[i].name");
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray(L"associatedServerIds");
    while (i < count_i) {
        jResp.put_I(i);
        strVal = jResp.stringOf(L"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
    // }
    }