doc-exports/docs/vpn/api-ref/vpn_api_0041.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

12 KiB

Example 2: Creating a Customer Gateway

Scenario

This section describes how to create a customer gateway 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 customer gateway

Parameter

Description

Example Value

name

Specifies a customer gateway name.

stub-customer-gateway-id-1

route_mode

Specifies the gateway routing mode.

static

ip

Specifies the IP address of the customer gateway.

10.12.13.21

Procedure

  1. Create a customer gateway.
    1. Send POST https://{endpoint}/v5/{project_id}/customer-gateways.
    2. Add X-Auth-Token to the request header.
    3. Specify the following parameters in the request body:
      {
          "customer_gateway": {
              "name": "cgw-3ebf",
              "id_type": "ip",
              "id_value": "10.***.***.21"
          }
      }
    4. Check the response.
      • The request is successful if the following response is displayed. In the response, id indicates a customer gateway ID.
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        {
            "customer_gateway": {
                "id": "03c0aa3d-demo-a8df-va86-9d82473765d4",
                "name": "cgw-3ebf",
                "id_type": "ip",
                "id_value": "10.***.***.21",
                "created_at": "2024-06-25T13:19:37.335+02:00",
                "updated_at": "2024-06-25T13:19:37.335+02:00"
            },
            "request_id": "e55783ba-5cc8-40c1-ad81-12cce6f773d2"
        }
        
  2. Query details about the customer gateway.
    1. Send GET https://{endpoint}/v5/{project_id}/customer-gateways/{customer_gateway_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 a customer gateway ID.
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        {
            "customer_gateway": {
                "id": "03c0aa3d-demo-a8df-va86-9d82473765d4",
                "name": "cgw-3ebf",
                "id_type": "ip",
                "id_value": "10.***.***.21",
                "created_at": "2024-06-25T13:19:37.335Z",
                "updated_at": "2024-06-25T13:19:37.335Z"
            },
            "request_id": "8cf476c4-c3d4-4516-bfbc-01e2473e549b"
        }