GetRouteAnalysis TCL Example
load ./chilkat.dll
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set rest [new_CkRest]
set authAws [new_CkAuthAws]
CkAuthAws_put_AccessKey $authAws "AWS_ACCESS_KEY"
CkAuthAws_put_SecretKey $authAws "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.)
CkAuthAws_put_Region $authAws "us-west-2"
CkAuthAws_put_ServiceName $authAws "networkmanager"
# SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest_SetAuthAws $rest $authAws
# URL: https://networkmanager.us-west-2.amazonaws.com/
# Use the same region as specified above.
set success [CkRest_Connect $rest "networkmanager.us-west-2.amazonaws.com" 443 1 1]
if {$success != 1} then {
puts "ConnectFailReason: [CkRest_get_ConnectFailReason $rest]"
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
delete_CkAuthAws $authAws
exit
}
CkRest_AddHeader $rest "Content-Type" "application/x-amz-json-1.1"
CkRest_AddHeader $rest "X-Amz-Target" "GetRouteAnalysis"
set sbResponseBody [new_CkStringBuilder]
set success [CkRest_FullRequestNoBodySb $rest "GET" "/global-networks/{globalNetworkId}/route-analyses/{routeAnalysisId}" $sbResponseBody]
if {$success != 1} then {
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkStringBuilder $sbResponseBody
exit
}
set respStatusCode [CkRest_get_ResponseStatusCode $rest]
puts "response status code = $respStatusCode"
if {$respStatusCode != 200} then {
puts "Response Header:"
puts [CkRest_responseHeader $rest]
puts "Response Body:"
puts [CkStringBuilder_getAsString $sbResponseBody]
delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkStringBuilder $sbResponseBody
exit
}
set jResp [new_CkJsonObject]
CkJsonObject_LoadSb $jResp $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
set IpAddress [CkJsonObject_stringOf $jResp "RouteAnalysis.Destination.IpAddress"]
set TransitGatewayArn [CkJsonObject_stringOf $jResp "RouteAnalysis.Destination.TransitGatewayArn"]
set TransitGatewayAttachmentArn [CkJsonObject_stringOf $jResp "RouteAnalysis.Destination.TransitGatewayAttachmentArn"]
set ReasonCode [CkJsonObject_stringOf $jResp "RouteAnalysis.ForwardPath.CompletionStatus.ReasonCode"]
set v_String [CkJsonObject_stringOf $jResp "RouteAnalysis.ForwardPath.CompletionStatus.ReasonContext.string"]
set ResultCode [CkJsonObject_stringOf $jResp "RouteAnalysis.ForwardPath.CompletionStatus.ResultCode"]
set GlobalNetworkId [CkJsonObject_stringOf $jResp "RouteAnalysis.GlobalNetworkId"]
set IncludeReturnPath [CkJsonObject_IntOf $jResp "RouteAnalysis.IncludeReturnPath"]
set OwnerAccountId [CkJsonObject_stringOf $jResp "RouteAnalysis.OwnerAccountId"]
set CompletionStatusReasonCode [CkJsonObject_stringOf $jResp "RouteAnalysis.ReturnPath.CompletionStatus.ReasonCode"]
set ReasonContextString [CkJsonObject_stringOf $jResp "RouteAnalysis.ReturnPath.CompletionStatus.ReasonContext.string"]
set CompletionStatusResultCode [CkJsonObject_stringOf $jResp "RouteAnalysis.ReturnPath.CompletionStatus.ResultCode"]
set RouteAnalysisId [CkJsonObject_stringOf $jResp "RouteAnalysis.RouteAnalysisId"]
set SourceIpAddress [CkJsonObject_stringOf $jResp "RouteAnalysis.Source.IpAddress"]
set SourceTransitGatewayArn [CkJsonObject_stringOf $jResp "RouteAnalysis.Source.TransitGatewayArn"]
set SourceTransitGatewayAttachmentArn [CkJsonObject_stringOf $jResp "RouteAnalysis.Source.TransitGatewayAttachmentArn"]
set StartTimestamp [CkJsonObject_IntOf $jResp "RouteAnalysis.StartTimestamp"]
set Status [CkJsonObject_stringOf $jResp "RouteAnalysis.Status"]
set UseMiddleboxes [CkJsonObject_IntOf $jResp "RouteAnalysis.UseMiddleboxes"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "RouteAnalysis.ForwardPath.Path"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set DestinationCidrBlock [CkJsonObject_stringOf $jResp "RouteAnalysis.ForwardPath.Path[i].DestinationCidrBlock"]
set Definition [CkJsonObject_stringOf $jResp "RouteAnalysis.ForwardPath.Path[i].Resource.Definition"]
set IsMiddlebox [CkJsonObject_IntOf $jResp "RouteAnalysis.ForwardPath.Path[i].Resource.IsMiddlebox"]
set NameTag [CkJsonObject_stringOf $jResp "RouteAnalysis.ForwardPath.Path[i].Resource.NameTag"]
set RegisteredGatewayArn [CkJsonObject_stringOf $jResp "RouteAnalysis.ForwardPath.Path[i].Resource.RegisteredGatewayArn"]
set ResourceArn [CkJsonObject_stringOf $jResp "RouteAnalysis.ForwardPath.Path[i].Resource.ResourceArn"]
set ResourceType [CkJsonObject_stringOf $jResp "RouteAnalysis.ForwardPath.Path[i].Resource.ResourceType"]
set Sequence [CkJsonObject_IntOf $jResp "RouteAnalysis.ForwardPath.Path[i].Sequence"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "RouteAnalysis.ReturnPath.Path"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set DestinationCidrBlock [CkJsonObject_stringOf $jResp "RouteAnalysis.ReturnPath.Path[i].DestinationCidrBlock"]
set ResourceDefinition [CkJsonObject_stringOf $jResp "RouteAnalysis.ReturnPath.Path[i].Resource.Definition"]
set ResourceIsMiddlebox [CkJsonObject_IntOf $jResp "RouteAnalysis.ReturnPath.Path[i].Resource.IsMiddlebox"]
set ResourceNameTag [CkJsonObject_stringOf $jResp "RouteAnalysis.ReturnPath.Path[i].Resource.NameTag"]
set ResourceRegisteredGatewayArn [CkJsonObject_stringOf $jResp "RouteAnalysis.ReturnPath.Path[i].Resource.RegisteredGatewayArn"]
set ResourceResourceArn [CkJsonObject_stringOf $jResp "RouteAnalysis.ReturnPath.Path[i].Resource.ResourceArn"]
set ResourceResourceType [CkJsonObject_stringOf $jResp "RouteAnalysis.ReturnPath.Path[i].Resource.ResourceType"]
set Sequence [CkJsonObject_IntOf $jResp "RouteAnalysis.ReturnPath.Path[i].Sequence"]
set i [expr $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
# }
# }
delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp