Chilkat Online Tools

GetApplicationComponentDetails Swift Example

Migration Hub Strategy Recommendations

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

    let rest = CkoRest()
    var success: Bool

    let authAws = CkoAuthAws()
    authAws.AccessKey = "AWS_ACCESS_KEY"
    authAws.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.Region = "us-west-2"
    authAws.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", port: 443, tls: true, autoReconnect: true)
    if success != true {
        print("ConnectFailReason: \(rest.ConnectFailReason.intValue)")
        print("\(rest.LastErrorText)")
        return
    }

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

    let sbResponseBody = CkoStringBuilder()
    success = rest.FullRequestNoBodySb("GET", uriPath: "/get-applicationcomponent-details/{applicationComponentId}", sb: sbResponseBody)
    if success != true {
        print("\(rest.LastErrorText)")
        return
    }

    var respStatusCode: Int = rest.ResponseStatusCode.intValue
    print("response status code = \(respStatusCode)")
    if respStatusCode != 200 {
        print("Response Header:")
        print("\(rest.ResponseHeader)")
        print("Response Body:")
        print("\(sbResponseBody.GetAsString())")
        return
    }

    let jResp = CkoJsonObject()
    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

    var count: Int
    var severity: String?
    var branch: String?
    var repository: String?
    var versionControlType: String?
    var id: String?
    var name: String?
    var strVal: String?

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

    i = 0
    count_i = jResp.SizeOfArray("applicationComponentDetail.sourceCodeRepositories").intValue
    while i < count_i {
        jResp.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").intValue
    while i < count_i {
        jResp.I = i
        id = jResp.StringOf("associatedApplications[i].id")
        name = jResp.StringOf("associatedApplications[i].name")
        i = i + 1
    }

    i = 0
    count_i = jResp.SizeOfArray("associatedServerIds").intValue
    while i < count_i {
        jResp.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
    // }

}