GetRouteAnalysis 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 = @"networkmanager";
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
[rest SetAuthAws: authAws];
// URL: https://networkmanager.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = [rest Connect: @"networkmanager.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: @"GetRouteAnalysis"];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"GET" uriPath: @"/global-networks/{globalNetworkId}/route-analyses/{routeAnalysisId}" 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 *DestinationCidrBlock = 0;
NSString *Definition = 0;
int IsMiddlebox;
NSString *NameTag = 0;
NSString *RegisteredGatewayArn = 0;
NSString *ResourceArn = 0;
NSString *ResourceType = 0;
int Sequence;
NSString *ResourceDefinition = 0;
int ResourceIsMiddlebox;
NSString *ResourceNameTag = 0;
NSString *ResourceRegisteredGatewayArn = 0;
NSString *ResourceResourceArn = 0;
NSString *ResourceResourceType = 0;
NSString *IpAddress = [jResp StringOf: @"RouteAnalysis.Destination.IpAddress"];
NSString *TransitGatewayArn = [jResp StringOf: @"RouteAnalysis.Destination.TransitGatewayArn"];
NSString *TransitGatewayAttachmentArn = [jResp StringOf: @"RouteAnalysis.Destination.TransitGatewayAttachmentArn"];
NSString *ReasonCode = [jResp StringOf: @"RouteAnalysis.ForwardPath.CompletionStatus.ReasonCode"];
NSString *v_String = [jResp StringOf: @"RouteAnalysis.ForwardPath.CompletionStatus.ReasonContext.string"];
NSString *ResultCode = [jResp StringOf: @"RouteAnalysis.ForwardPath.CompletionStatus.ResultCode"];
NSString *GlobalNetworkId = [jResp StringOf: @"RouteAnalysis.GlobalNetworkId"];
int IncludeReturnPath = [[jResp IntOf: @"RouteAnalysis.IncludeReturnPath"] intValue];
NSString *OwnerAccountId = [jResp StringOf: @"RouteAnalysis.OwnerAccountId"];
NSString *CompletionStatusReasonCode = [jResp StringOf: @"RouteAnalysis.ReturnPath.CompletionStatus.ReasonCode"];
NSString *ReasonContextString = [jResp StringOf: @"RouteAnalysis.ReturnPath.CompletionStatus.ReasonContext.string"];
NSString *CompletionStatusResultCode = [jResp StringOf: @"RouteAnalysis.ReturnPath.CompletionStatus.ResultCode"];
NSString *RouteAnalysisId = [jResp StringOf: @"RouteAnalysis.RouteAnalysisId"];
NSString *SourceIpAddress = [jResp StringOf: @"RouteAnalysis.Source.IpAddress"];
NSString *SourceTransitGatewayArn = [jResp StringOf: @"RouteAnalysis.Source.TransitGatewayArn"];
NSString *SourceTransitGatewayAttachmentArn = [jResp StringOf: @"RouteAnalysis.Source.TransitGatewayAttachmentArn"];
int StartTimestamp = [[jResp IntOf: @"RouteAnalysis.StartTimestamp"] intValue];
NSString *Status = [jResp StringOf: @"RouteAnalysis.Status"];
int UseMiddleboxes = [[jResp IntOf: @"RouteAnalysis.UseMiddleboxes"] intValue];
int i = 0;
int count_i = [[jResp SizeOfArray: @"RouteAnalysis.ForwardPath.Path"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
DestinationCidrBlock = [jResp StringOf: @"RouteAnalysis.ForwardPath.Path[i].DestinationCidrBlock"];
Definition = [jResp StringOf: @"RouteAnalysis.ForwardPath.Path[i].Resource.Definition"];
IsMiddlebox = [[jResp IntOf: @"RouteAnalysis.ForwardPath.Path[i].Resource.IsMiddlebox"] intValue];
NameTag = [jResp StringOf: @"RouteAnalysis.ForwardPath.Path[i].Resource.NameTag"];
RegisteredGatewayArn = [jResp StringOf: @"RouteAnalysis.ForwardPath.Path[i].Resource.RegisteredGatewayArn"];
ResourceArn = [jResp StringOf: @"RouteAnalysis.ForwardPath.Path[i].Resource.ResourceArn"];
ResourceType = [jResp StringOf: @"RouteAnalysis.ForwardPath.Path[i].Resource.ResourceType"];
Sequence = [[jResp IntOf: @"RouteAnalysis.ForwardPath.Path[i].Sequence"] intValue];
i = i + 1;
}
i = 0;
count_i = [[jResp SizeOfArray: @"RouteAnalysis.ReturnPath.Path"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
DestinationCidrBlock = [jResp StringOf: @"RouteAnalysis.ReturnPath.Path[i].DestinationCidrBlock"];
ResourceDefinition = [jResp StringOf: @"RouteAnalysis.ReturnPath.Path[i].Resource.Definition"];
ResourceIsMiddlebox = [[jResp IntOf: @"RouteAnalysis.ReturnPath.Path[i].Resource.IsMiddlebox"] intValue];
ResourceNameTag = [jResp StringOf: @"RouteAnalysis.ReturnPath.Path[i].Resource.NameTag"];
ResourceRegisteredGatewayArn = [jResp StringOf: @"RouteAnalysis.ReturnPath.Path[i].Resource.RegisteredGatewayArn"];
ResourceResourceArn = [jResp StringOf: @"RouteAnalysis.ReturnPath.Path[i].Resource.ResourceArn"];
ResourceResourceType = [jResp StringOf: @"RouteAnalysis.ReturnPath.Path[i].Resource.ResourceType"];
Sequence = [[jResp IntOf: @"RouteAnalysis.ReturnPath.Path[i].Sequence"] intValue];
i = i + 1;
}
// A sample JSON response body parsed by the above code:
// {
// "RouteAnalysis": {
// "Destination": {
// "IpAddress": "string",
// "TransitGatewayArn": "string",
// "TransitGatewayAttachmentArn": "string"
// },
// "ForwardPath": {
// "CompletionStatus": {
// "ReasonCode": "string",
// "ReasonContext": {
// "string": "string"
// },
// "ResultCode": "string"
// },
// "Path": [
// {
// "DestinationCidrBlock": "string",
// "Resource": {
// "Definition": "string",
// "IsMiddlebox": boolean,
// "NameTag": "string",
// "RegisteredGatewayArn": "string",
// "ResourceArn": "string",
// "ResourceType": "string"
// },
// "Sequence": number
// }
// ]
// },
// "GlobalNetworkId": "string",
// "IncludeReturnPath": boolean,
// "OwnerAccountId": "string",
// "ReturnPath": {
// "CompletionStatus": {
// "ReasonCode": "string",
// "ReasonContext": {
// "string": "string"
// },
// "ResultCode": "string"
// },
// "Path": [
// {
// "DestinationCidrBlock": "string",
// "Resource": {
// "Definition": "string",
// "IsMiddlebox": boolean,
// "NameTag": "string",
// "RegisteredGatewayArn": "string",
// "ResourceArn": "string",
// "ResourceType": "string"
// },
// "Sequence": number
// }
// ]
// },
// "RouteAnalysisId": "string",
// "Source": {
// "IpAddress": "string",
// "TransitGatewayArn": "string",
// "TransitGatewayAttachmentArn": "string"
// },
// "StartTimestamp": number,
// "Status": "string",
// "UseMiddleboxes": boolean
// }
// }