Chilkat Online Tools

GetApplicationComponentDetails DataFlex Example

Migration Hub Strategy Recommendations

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
    Variant vAuthAws
    Handle hoAuthAws
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Integer iRespStatusCode
    Handle hoJResp
    Integer iCount
    String sSeverity
    String sBranch
    String sRepository
    String sVersionControlType
    String sId
    String sName
    String sStrVal
    String sAnalysisStatus
    String sS3Bucket
    String sS3key
    String sAntipatternReportStatus
    String sAntipatternReportStatusMessage
    String sAppType
    String sAssociatedServerId
    String sSecretName
    String sId
    String sInclusionStatus
    Integer iLastAnalyzedTimestamp
    Integer iMoreServerAssociationExists
    String sName
    String sOsDriver
    String sOsVersion
    String sStrategy
    String sTargetDestination
    String sDescription
    String sTransformationToolName
    String sTranformationToolInstallationLink
    String sResourceSubType
    String sStatusMessage
    Integer iMoreApplicationResource
    Integer i
    Integer iCount_i
    String sTemp1
    Integer iTemp1

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    Get Create (RefClass(cComChilkatAuthAws)) To hoAuthAws
    If (Not(IsComObjectCreated(hoAuthAws))) Begin
        Send CreateComObject of hoAuthAws
    End
    Set ComAccessKey Of hoAuthAws To "AWS_ACCESS_KEY"
    Set ComSecretKey Of hoAuthAws To "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.)
    Set ComRegion Of hoAuthAws To "us-west-2"
    Set ComServiceName Of hoAuthAws To "migrationhub-strategy"
    // SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
    Get pvComObject of hoAuthAws to vAuthAws
    Get ComSetAuthAws Of hoRest vAuthAws To iSuccess

    // URL: https://migrationhub-strategy.us-west-2.amazonaws.com/
    // Use the same region as specified above.
    Get ComConnect Of hoRest "migrationhub-strategy.us-west-2.amazonaws.com" 443 True True To iSuccess
    If (iSuccess <> True) Begin
        Get ComConnectFailReason Of hoRest To iTemp1
        Showln "ConnectFailReason: " iTemp1
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComAddHeader Of hoRest "Content-Type" "application/x-amz-json-1.1" To iSuccess
    Get ComAddHeader Of hoRest "X-Amz-Target" "GetApplicationComponentDetails" To iSuccess

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComFullRequestNoBodySb Of hoRest "GET" "/get-applicationcomponent-details/{applicationComponentId}" vSbResponseBody To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iRespStatusCode
    Showln "response status code = " iRespStatusCode
    If (iRespStatusCode <> 200) Begin
        Showln "Response Header:"
        Get ComResponseHeader Of hoRest To sTemp1
        Showln sTemp1
        Showln "Response Body:"
        Get ComGetAsString Of hoSbResponseBody To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess

    // 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

    Get ComStringOf Of hoJResp "applicationComponentDetail.analysisStatus" To sAnalysisStatus
    Get ComStringOf Of hoJResp "applicationComponentDetail.antipatternReportS3Object.s3Bucket" To sS3Bucket
    Get ComStringOf Of hoJResp "applicationComponentDetail.antipatternReportS3Object.s3key" To sS3key
    Get ComStringOf Of hoJResp "applicationComponentDetail.antipatternReportStatus" To sAntipatternReportStatus
    Get ComStringOf Of hoJResp "applicationComponentDetail.antipatternReportStatusMessage" To sAntipatternReportStatusMessage
    Get ComStringOf Of hoJResp "applicationComponentDetail.appType" To sAppType
    Get ComStringOf Of hoJResp "applicationComponentDetail.associatedServerId" To sAssociatedServerId
    Get ComStringOf Of hoJResp "applicationComponentDetail.databaseConfigDetail.secretName" To sSecretName
    Get ComStringOf Of hoJResp "applicationComponentDetail.id" To sId
    Get ComStringOf Of hoJResp "applicationComponentDetail.inclusionStatus" To sInclusionStatus
    Get ComIntOf Of hoJResp "applicationComponentDetail.lastAnalyzedTimestamp" To iLastAnalyzedTimestamp
    Get ComIntOf Of hoJResp "applicationComponentDetail.moreServerAssociationExists" To iMoreServerAssociationExists
    Get ComStringOf Of hoJResp "applicationComponentDetail.name" To sName
    Get ComStringOf Of hoJResp "applicationComponentDetail.osDriver" To sOsDriver
    Get ComStringOf Of hoJResp "applicationComponentDetail.osVersion" To sOsVersion
    Get ComStringOf Of hoJResp "applicationComponentDetail.recommendationSet.strategy" To sStrategy
    Get ComStringOf Of hoJResp "applicationComponentDetail.recommendationSet.targetDestination" To sTargetDestination
    Get ComStringOf Of hoJResp "applicationComponentDetail.recommendationSet.transformationTool.description" To sDescription
    Get ComStringOf Of hoJResp "applicationComponentDetail.recommendationSet.transformationTool.name" To sTransformationToolName
    Get ComStringOf Of hoJResp "applicationComponentDetail.recommendationSet.transformationTool.tranformationToolInstallationLink" To sTranformationToolInstallationLink
    Get ComStringOf Of hoJResp "applicationComponentDetail.resourceSubType" To sResourceSubType
    Get ComStringOf Of hoJResp "applicationComponentDetail.statusMessage" To sStatusMessage
    Get ComIntOf Of hoJResp "moreApplicationResource" To iMoreApplicationResource
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "applicationComponentDetail.listAntipatternSeveritySummary" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComIntOf Of hoJResp "applicationComponentDetail.listAntipatternSeveritySummary[i].count" To iCount
        Get ComStringOf Of hoJResp "applicationComponentDetail.listAntipatternSeveritySummary[i].severity" To sSeverity
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "applicationComponentDetail.sourceCodeRepositories" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "applicationComponentDetail.sourceCodeRepositories[i].branch" To sBranch
        Get ComStringOf Of hoJResp "applicationComponentDetail.sourceCodeRepositories[i].repository" To sRepository
        Get ComStringOf Of hoJResp "applicationComponentDetail.sourceCodeRepositories[i].versionControlType" To sVersionControlType
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "associatedApplications" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "associatedApplications[i].id" To sId
        Get ComStringOf Of hoJResp "associatedApplications[i].name" To sName
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "associatedServerIds" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "associatedServerIds[i]" To sStrVal
        Move (i + 1) To i
    Loop

    // 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
    // }


End_Procedure