GetApplicationComponentDetails Objective-C Example
#import <CkoRest.h>
#import <CkoAuthAws.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoRest *rest = [[CkoRest alloc] init];
BOOL success;
CkoAuthAws *authAws = [[CkoAuthAws alloc] init];
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: [NSNumber numberWithInt: 443] tls: YES autoReconnect: YES];
if (success != YES) {
NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
NSLog(@"%@",rest.LastErrorText);
return;
}
[rest AddHeader: @"Content-Type" value: @"application/x-amz-json-1.1"];
[rest AddHeader: @"X-Amz-Target" value: @"GetApplicationComponentDetails"];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"GET" uriPath: @"/get-applicationcomponent-details/{applicationComponentId}" sb: sbResponseBody];
if (success != YES) {
NSLog(@"%@",rest.LastErrorText);
return;
}
int respStatusCode = [rest.ResponseStatusCode intValue];
NSLog(@"%@%d",@"response status code = ",respStatusCode);
if (respStatusCode != 200) {
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",rest.ResponseHeader);
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[sbResponseBody GetAsString]);
return;
}
CkoJsonObject *jResp = [[CkoJsonObject alloc] init];
[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
int count;
NSString *severity = 0;
NSString *branch = 0;
NSString *repository = 0;
NSString *versionControlType = 0;
NSString *id = 0;
NSString *name = 0;
NSString *strVal = 0;
NSString *AnalysisStatus = [jResp StringOf: @"applicationComponentDetail.analysisStatus"];
NSString *S3Bucket = [jResp StringOf: @"applicationComponentDetail.antipatternReportS3Object.s3Bucket"];
NSString *S3key = [jResp StringOf: @"applicationComponentDetail.antipatternReportS3Object.s3key"];
NSString *AntipatternReportStatus = [jResp StringOf: @"applicationComponentDetail.antipatternReportStatus"];
NSString *AntipatternReportStatusMessage = [jResp StringOf: @"applicationComponentDetail.antipatternReportStatusMessage"];
NSString *AppType = [jResp StringOf: @"applicationComponentDetail.appType"];
NSString *AssociatedServerId = [jResp StringOf: @"applicationComponentDetail.associatedServerId"];
NSString *SecretName = [jResp StringOf: @"applicationComponentDetail.databaseConfigDetail.secretName"];
NSString *Id = [jResp StringOf: @"applicationComponentDetail.id"];
NSString *InclusionStatus = [jResp StringOf: @"applicationComponentDetail.inclusionStatus"];
int LastAnalyzedTimestamp = [[jResp IntOf: @"applicationComponentDetail.lastAnalyzedTimestamp"] intValue];
int MoreServerAssociationExists = [[jResp IntOf: @"applicationComponentDetail.moreServerAssociationExists"] intValue];
NSString *Name = [jResp StringOf: @"applicationComponentDetail.name"];
NSString *OsDriver = [jResp StringOf: @"applicationComponentDetail.osDriver"];
NSString *OsVersion = [jResp StringOf: @"applicationComponentDetail.osVersion"];
NSString *Strategy = [jResp StringOf: @"applicationComponentDetail.recommendationSet.strategy"];
NSString *TargetDestination = [jResp StringOf: @"applicationComponentDetail.recommendationSet.targetDestination"];
NSString *Description = [jResp StringOf: @"applicationComponentDetail.recommendationSet.transformationTool.description"];
NSString *TransformationToolName = [jResp StringOf: @"applicationComponentDetail.recommendationSet.transformationTool.name"];
NSString *TranformationToolInstallationLink = [jResp StringOf: @"applicationComponentDetail.recommendationSet.transformationTool.tranformationToolInstallationLink"];
NSString *ResourceSubType = [jResp StringOf: @"applicationComponentDetail.resourceSubType"];
NSString *StatusMessage = [jResp StringOf: @"applicationComponentDetail.statusMessage"];
int moreApplicationResource = [[jResp IntOf: @"moreApplicationResource"] intValue];
int i = 0;
int count_i = [[jResp SizeOfArray: @"applicationComponentDetail.listAntipatternSeveritySummary"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: 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 = [NSNumber numberWithInt: 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 = [NSNumber numberWithInt: 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 = [NSNumber numberWithInt: 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
// }