1
0
forked from docs/doc-exports
doc-exports/docs/vpn/api-ref/vpn_api_0043.html
Hongwei, King Wang 32c06a10a2 vpn_api
Reviewed-by: Sarda, Priya <prsarda@noreply.gitea.eco.tsi-dev.otc-service.com>
Co-authored-by: Hongwei, King Wang <king.wanghongwei@huawei.com>
Co-committed-by: Hongwei, King Wang <king.wanghongwei@huawei.com>
2024-08-15 14:18:28 +00:00

7.7 KiB

Example 4: Creating a VPN Connection Monitor

Scenario

This section describes how to create a VPN connection monitor by calling APIs.

Prerequisites

  • You have obtained a user token if you need to use token authentication. In addition, you need to add X-Auth-Token to the request header when calling an API. For details about token authentication, see "Authentication" in the Virtual Private Cloud API Reference.

Data Preparation

Table 1 Key parameters in the request for creating a VPN connection monitor

Parameter

Description

Example Value

vpn_connection_id

Specifies the ID of the VPN connection to be monitored.

cae286f2-demo-a8df-va86-e22416ca1220

Procedure

  1. Create a VPN connection monitor.
    1. Send POST https://{endpoint}/v5/{project_id}/connection-monitors.
    2. Add X-Auth-Token to the request header.
    3. Specify the following parameters in the request body:
      {
          "connection_monitor": {
              "vpn_connection_id": "cae286f2-demo-a8df-va86-e22416ca1220"
          }
      }
    4. Check the response.
      • The request is successful if the following response is displayed. In the response, id indicates the ID of a VPN connection monitor.
        {
            "connection_monitor": {
                "id": "76f64229-demo-a8df-va86-3907e2815b6d",
                "vpn_connection_id": "cae286f2-demo-a8df-va86-e22416ca1220",
                "type": "gateway",
                "source_ip": "88.***.***.60",
                "destination_ip": "192.***.***.0",
                "proto_type": "icmp"
            },
            "request_id": "54af23d8-989e-445d-bb48-0a9da33d7f0f"
        }
  2. Query details about the VPN connection monitor.
    1. Send GET https://{endpoint}/v5/{project_id}/connection-monitors/{connection_monitor_id}.
    2. Add X-Auth-Token to the request header.
    3. Check the response.
      • The request is successful if the following response is displayed. In the response, id indicates the ID of a VPN connection monitor.
        {
            "connection_monitor": {
                "id": "76f64229-demo-a8df-va86-3907e2815b6d",
                "status": "ACTIVE",
                "vpn_connection_id": "cae286f2-demo-a8df-va86-e22416ca1220",
                "type": "gateway",
                "source_ip": "88.***.***.60",
                "destination_ip": "192.***.***.0",
                "proto_type": "icmp"
            },
            "request_id": "72d05395-0637-4f93-9844-b4979e9d7bdc"
        }