Chilkat Online Tools

GetRouteAnalysis DataFlex Example

AWS Network Manager

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
    Variant vAuthAws
    Handle hoAuthAws
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Integer iRespStatusCode
    Handle hoJResp
    String sDestinationCidrBlock
    String sDefinition
    Integer iIsMiddlebox
    String sNameTag
    String sRegisteredGatewayArn
    String sResourceArn
    String sResourceType
    Integer iSequence
    String sResourceDefinition
    Integer iResourceIsMiddlebox
    String sResourceNameTag
    String sResourceRegisteredGatewayArn
    String sResourceResourceArn
    String sResourceResourceType
    String sIpAddress
    String sTransitGatewayArn
    String sTransitGatewayAttachmentArn
    String sReasonCode
    String sV_String
    String sResultCode
    String sGlobalNetworkId
    Integer iIncludeReturnPath
    String sOwnerAccountId
    String sCompletionStatusReasonCode
    String sReasonContextString
    String sCompletionStatusResultCode
    String sRouteAnalysisId
    String sSourceIpAddress
    String sSourceTransitGatewayArn
    String sSourceTransitGatewayAttachmentArn
    Integer iStartTimestamp
    String sStatus
    Integer iUseMiddleboxes
    Integer i
    Integer iCount_i
    String sTemp1
    Integer iTemp1

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    Get Create (RefClass(cComChilkatAuthAws)) To hoAuthAws
    If (Not(IsComObjectCreated(hoAuthAws))) Begin
        Send CreateComObject of hoAuthAws
    End
    Set ComAccessKey Of hoAuthAws To "AWS_ACCESS_KEY"
    Set ComSecretKey Of hoAuthAws To "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.)
    Set ComRegion Of hoAuthAws To "us-west-2"
    Set ComServiceName Of hoAuthAws To "networkmanager"
    // SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
    Get pvComObject of hoAuthAws to vAuthAws
    Get ComSetAuthAws Of hoRest vAuthAws To iSuccess

    // URL: https://networkmanager.us-west-2.amazonaws.com/
    // Use the same region as specified above.
    Get ComConnect Of hoRest "networkmanager.us-west-2.amazonaws.com" 443 True True To iSuccess
    If (iSuccess <> True) Begin
        Get ComConnectFailReason Of hoRest To iTemp1
        Showln "ConnectFailReason: " iTemp1
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComAddHeader Of hoRest "Content-Type" "application/x-amz-json-1.1" To iSuccess
    Get ComAddHeader Of hoRest "X-Amz-Target" "GetRouteAnalysis" To iSuccess

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComFullRequestNoBodySb Of hoRest "GET" "/global-networks/{globalNetworkId}/route-analyses/{routeAnalysisId}" vSbResponseBody To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iRespStatusCode
    Showln "response status code = " iRespStatusCode
    If (iRespStatusCode <> 200) Begin
        Showln "Response Header:"
        Get ComResponseHeader Of hoRest To sTemp1
        Showln sTemp1
        Showln "Response Body:"
        Get ComGetAsString Of hoSbResponseBody To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess

    // 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

    Get ComStringOf Of hoJResp "RouteAnalysis.Destination.IpAddress" To sIpAddress
    Get ComStringOf Of hoJResp "RouteAnalysis.Destination.TransitGatewayArn" To sTransitGatewayArn
    Get ComStringOf Of hoJResp "RouteAnalysis.Destination.TransitGatewayAttachmentArn" To sTransitGatewayAttachmentArn
    Get ComStringOf Of hoJResp "RouteAnalysis.ForwardPath.CompletionStatus.ReasonCode" To sReasonCode
    Get ComStringOf Of hoJResp "RouteAnalysis.ForwardPath.CompletionStatus.ReasonContext.string" To sV_String
    Get ComStringOf Of hoJResp "RouteAnalysis.ForwardPath.CompletionStatus.ResultCode" To sResultCode
    Get ComStringOf Of hoJResp "RouteAnalysis.GlobalNetworkId" To sGlobalNetworkId
    Get ComIntOf Of hoJResp "RouteAnalysis.IncludeReturnPath" To iIncludeReturnPath
    Get ComStringOf Of hoJResp "RouteAnalysis.OwnerAccountId" To sOwnerAccountId
    Get ComStringOf Of hoJResp "RouteAnalysis.ReturnPath.CompletionStatus.ReasonCode" To sCompletionStatusReasonCode
    Get ComStringOf Of hoJResp "RouteAnalysis.ReturnPath.CompletionStatus.ReasonContext.string" To sReasonContextString
    Get ComStringOf Of hoJResp "RouteAnalysis.ReturnPath.CompletionStatus.ResultCode" To sCompletionStatusResultCode
    Get ComStringOf Of hoJResp "RouteAnalysis.RouteAnalysisId" To sRouteAnalysisId
    Get ComStringOf Of hoJResp "RouteAnalysis.Source.IpAddress" To sSourceIpAddress
    Get ComStringOf Of hoJResp "RouteAnalysis.Source.TransitGatewayArn" To sSourceTransitGatewayArn
    Get ComStringOf Of hoJResp "RouteAnalysis.Source.TransitGatewayAttachmentArn" To sSourceTransitGatewayAttachmentArn
    Get ComIntOf Of hoJResp "RouteAnalysis.StartTimestamp" To iStartTimestamp
    Get ComStringOf Of hoJResp "RouteAnalysis.Status" To sStatus
    Get ComIntOf Of hoJResp "RouteAnalysis.UseMiddleboxes" To iUseMiddleboxes
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "RouteAnalysis.ForwardPath.Path" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "RouteAnalysis.ForwardPath.Path[i].DestinationCidrBlock" To sDestinationCidrBlock
        Get ComStringOf Of hoJResp "RouteAnalysis.ForwardPath.Path[i].Resource.Definition" To sDefinition
        Get ComIntOf Of hoJResp "RouteAnalysis.ForwardPath.Path[i].Resource.IsMiddlebox" To iIsMiddlebox
        Get ComStringOf Of hoJResp "RouteAnalysis.ForwardPath.Path[i].Resource.NameTag" To sNameTag
        Get ComStringOf Of hoJResp "RouteAnalysis.ForwardPath.Path[i].Resource.RegisteredGatewayArn" To sRegisteredGatewayArn
        Get ComStringOf Of hoJResp "RouteAnalysis.ForwardPath.Path[i].Resource.ResourceArn" To sResourceArn
        Get ComStringOf Of hoJResp "RouteAnalysis.ForwardPath.Path[i].Resource.ResourceType" To sResourceType
        Get ComIntOf Of hoJResp "RouteAnalysis.ForwardPath.Path[i].Sequence" To iSequence
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "RouteAnalysis.ReturnPath.Path" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "RouteAnalysis.ReturnPath.Path[i].DestinationCidrBlock" To sDestinationCidrBlock
        Get ComStringOf Of hoJResp "RouteAnalysis.ReturnPath.Path[i].Resource.Definition" To sResourceDefinition
        Get ComIntOf Of hoJResp "RouteAnalysis.ReturnPath.Path[i].Resource.IsMiddlebox" To iResourceIsMiddlebox
        Get ComStringOf Of hoJResp "RouteAnalysis.ReturnPath.Path[i].Resource.NameTag" To sResourceNameTag
        Get ComStringOf Of hoJResp "RouteAnalysis.ReturnPath.Path[i].Resource.RegisteredGatewayArn" To sResourceRegisteredGatewayArn
        Get ComStringOf Of hoJResp "RouteAnalysis.ReturnPath.Path[i].Resource.ResourceArn" To sResourceResourceArn
        Get ComStringOf Of hoJResp "RouteAnalysis.ReturnPath.Path[i].Resource.ResourceType" To sResourceResourceType
        Get ComIntOf Of hoJResp "RouteAnalysis.ReturnPath.Path[i].Sequence" To iSequence
        Move (i + 1) To i
    Loop

    // 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
    //   }
    // }


End_Procedure