Chilkat Online Tools

GetMilestone Objective-C Example

AWS Well-Architected Tool

#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 = @"wellarchitected";
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
[rest SetAuthAws: authAws];

// URL: https://wellarchitected.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = [rest Connect: @"wellarchitected.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: @"GetMilestone"];

CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"GET" uriPath: @"/workloads/{WorkloadId}/milestones/{MilestoneNumber}" 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

NSString *strVal = 0;

NSString *MilestoneName = [jResp StringOf: @"Milestone.MilestoneName"];
int MilestoneNumber = [[jResp IntOf: @"Milestone.MilestoneNumber"] intValue];
int RecordedAt = [[jResp IntOf: @"Milestone.RecordedAt"] intValue];
NSString *ArchitecturalDesign = [jResp StringOf: @"Milestone.Workload.ArchitecturalDesign"];
NSString *Description = [jResp StringOf: @"Milestone.Workload.Description"];
NSString *Environment = [jResp StringOf: @"Milestone.Workload.Environment"];
NSString *ImprovementStatus = [jResp StringOf: @"Milestone.Workload.ImprovementStatus"];
NSString *Industry = [jResp StringOf: @"Milestone.Workload.Industry"];
NSString *IndustryType = [jResp StringOf: @"Milestone.Workload.IndustryType"];
int IsReviewOwnerUpdateAcknowledged = [[jResp IntOf: @"Milestone.Workload.IsReviewOwnerUpdateAcknowledged"] intValue];
NSString *Notes = [jResp StringOf: @"Milestone.Workload.Notes"];
NSString *Owner = [jResp StringOf: @"Milestone.Workload.Owner"];
NSString *ReviewOwner = [jResp StringOf: @"Milestone.Workload.ReviewOwner"];
int ReviewRestrictionDate = [[jResp IntOf: @"Milestone.Workload.ReviewRestrictionDate"] intValue];
int v_String = [[jResp IntOf: @"Milestone.Workload.RiskCounts.string"] intValue];
NSString *ShareInvitationId = [jResp StringOf: @"Milestone.Workload.ShareInvitationId"];
NSString *TagsString = [jResp StringOf: @"Milestone.Workload.Tags.string"];
int UpdatedAt = [[jResp IntOf: @"Milestone.Workload.UpdatedAt"] intValue];
NSString *WorkloadArn = [jResp StringOf: @"Milestone.Workload.WorkloadArn"];
NSString *WorkloadId = [jResp StringOf: @"Milestone.Workload.WorkloadId"];
NSString *WorkloadName = [jResp StringOf: @"Milestone.Workload.WorkloadName"];
WorkloadId = [jResp StringOf: @"WorkloadId"];
int i = 0;
int count_i = [[jResp SizeOfArray: @"Milestone.Workload.AccountIds"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    strVal = [jResp StringOf: @"Milestone.Workload.AccountIds[i]"];
    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"Milestone.Workload.AwsRegions"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    strVal = [jResp StringOf: @"Milestone.Workload.AwsRegions[i]"];
    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"Milestone.Workload.Lenses"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    strVal = [jResp StringOf: @"Milestone.Workload.Lenses[i]"];
    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"Milestone.Workload.NonAwsRegions"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    strVal = [jResp StringOf: @"Milestone.Workload.NonAwsRegions[i]"];
    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"Milestone.Workload.PillarPriorities"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    strVal = [jResp StringOf: @"Milestone.Workload.PillarPriorities[i]"];
    i = i + 1;
}

// A sample JSON response body parsed by the above code:

// {
//   "Milestone": {
//     "MilestoneName": "string",
//     "MilestoneNumber": number,
//     "RecordedAt": number,
//     "Workload": {
//       "AccountIds": [
//         "string"
//       ],
//       "ArchitecturalDesign": "string",
//       "AwsRegions": [
//         "string"
//       ],
//       "Description": "string",
//       "Environment": "string",
//       "ImprovementStatus": "string",
//       "Industry": "string",
//       "IndustryType": "string",
//       "IsReviewOwnerUpdateAcknowledged": boolean,
//       "Lenses": [
//         "string"
//       ],
//       "NonAwsRegions": [
//         "string"
//       ],
//       "Notes": "string",
//       "Owner": "string",
//       "PillarPriorities": [
//         "string"
//       ],
//       "ReviewOwner": "string",
//       "ReviewRestrictionDate": number,
//       "RiskCounts": {
//         "string": number
//       },
//       "ShareInvitationId": "string",
//       "Tags": {
//         "string": "string"
//       },
//       "UpdatedAt": number,
//       "WorkloadArn": "string",
//       "WorkloadId": "string",
//       "WorkloadName": "string"
//     }
//   },
//   "WorkloadId": "string"
// }