GetApplicationComponentDetails Swift3 Example
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.string(of: "applicationComponentDetail.analysisStatus")
var S3Bucket: String? = jResp.string(of: "applicationComponentDetail.antipatternReportS3Object.s3Bucket")
var S3key: String? = jResp.string(of: "applicationComponentDetail.antipatternReportS3Object.s3key")
var AntipatternReportStatus: String? = jResp.string(of: "applicationComponentDetail.antipatternReportStatus")
var AntipatternReportStatusMessage: String? = jResp.string(of: "applicationComponentDetail.antipatternReportStatusMessage")
var AppType: String? = jResp.string(of: "applicationComponentDetail.appType")
var AssociatedServerId: String? = jResp.string(of: "applicationComponentDetail.associatedServerId")
var SecretName: String? = jResp.string(of: "applicationComponentDetail.databaseConfigDetail.secretName")
var Id: String? = jResp.string(of: "applicationComponentDetail.id")
var InclusionStatus: String? = jResp.string(of: "applicationComponentDetail.inclusionStatus")
var LastAnalyzedTimestamp: Int = jResp.int(of: "applicationComponentDetail.lastAnalyzedTimestamp").intValue
var MoreServerAssociationExists: Int = jResp.int(of: "applicationComponentDetail.moreServerAssociationExists").intValue
var Name: String? = jResp.string(of: "applicationComponentDetail.name")
var OsDriver: String? = jResp.string(of: "applicationComponentDetail.osDriver")
var OsVersion: String? = jResp.string(of: "applicationComponentDetail.osVersion")
var Strategy: String? = jResp.string(of: "applicationComponentDetail.recommendationSet.strategy")
var TargetDestination: String? = jResp.string(of: "applicationComponentDetail.recommendationSet.targetDestination")
var Description: String? = jResp.string(of: "applicationComponentDetail.recommendationSet.transformationTool.description")
var TransformationToolName: String? = jResp.string(of: "applicationComponentDetail.recommendationSet.transformationTool.name")
var TranformationToolInstallationLink: String? = jResp.string(of: "applicationComponentDetail.recommendationSet.transformationTool.tranformationToolInstallationLink")
var ResourceSubType: String? = jResp.string(of: "applicationComponentDetail.resourceSubType")
var StatusMessage: String? = jResp.string(of: "applicationComponentDetail.statusMessage")
var moreApplicationResource: Int = jResp.int(of: "moreApplicationResource").intValue
var i: Int = 0
var count_i: Int = jResp.size(ofArray: "applicationComponentDetail.listAntipatternSeveritySummary").intValue
while i < count_i {
jResp.i = i
count = jResp.int(of: "applicationComponentDetail.listAntipatternSeveritySummary[i].count").intValue
severity = jResp.string(of: "applicationComponentDetail.listAntipatternSeveritySummary[i].severity")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "applicationComponentDetail.sourceCodeRepositories").intValue
while i < count_i {
jResp.i = i
branch = jResp.string(of: "applicationComponentDetail.sourceCodeRepositories[i].branch")
repository = jResp.string(of: "applicationComponentDetail.sourceCodeRepositories[i].repository")
versionControlType = jResp.string(of: "applicationComponentDetail.sourceCodeRepositories[i].versionControlType")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "associatedApplications").intValue
while i < count_i {
jResp.i = i
id = jResp.string(of: "associatedApplications[i].id")
name = jResp.string(of: "associatedApplications[i].name")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "associatedServerIds").intValue
while i < count_i {
jResp.i = i
strVal = jResp.string(of: "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
// }
}