Updated on 2024-12-03 GMT+08:00

Creating VPN Users in Batches

Function

This API is used to create VPN users in batches on a specified VPN server.

Calling Method

For details, see Calling APIs.

URI

POST /v5/{project_id}/p2c-vpn-gateways/vpn-servers/{vpn_server_id}/users/batch-create
Table 1 Parameter description

Parameter

Type

Mandatory

Description

project_id

String

Yes

Specifies a project ID. You can obtain the project ID by referring to Obtaining the Project ID.

vpn_server_id

String

Yes

Specifies the ID of a VPN server.

Table 2 Parameters in the request header

Parameter

Type

Mandatory

Description

X-Client-Token

String

No

  • Specifies the ID of an idempotent request.
  • The value is a UUID containing 36 characters.

Request

  • Request parameters
    Table 3 Request parameters

    Parameter

    Type

    Mandatory

    Description

    users

    Array of

    CreateVpnUser

    objects

    Yes

    Specifies the list of VPN users to be created.

    Table 4 CreateVpnUser

    Parameter

    Type

    Mandatory

    Description

    name

    String

    Yes

    • Specifies a username.
    • The value is a string of 4 to 32 characters, which can contain letters, digits, periods (.), underscores (_), and hyphens (-)

    password

    String

    Yes

    • Specifies a password for a user.
    • Constraints:
      • The value contains 8 to 32 characters.
      • The value must contain at least two types of the following characters: uppercase letters, lowercase letters, digits, and special characters including `~!@#$%^&*()-_=+\|[{}];:'",<.>/? and spaces.
      • The password cannot be the username or the reverse of the username.

    description

    String

    No

    • Specifies user description.
    • The value is a string of 0 to 64 characters, which can contain letters, digits, and underscores (_).

    user_group_name

    String

    No

    • Specifies the name of the user group to which users belong.
    • Constraints:
      • The value is a string of 1 to 64 characters, which can contain letters, digits, underscores (_), and hyphens (-).
      • The value must be the name of an existing user group.
    • Example request
      POST https://{Endpoint}/v5/{project_id}/p2c-vpn-gateways/vpn-servers/{vpn_server_id}/users 
      
      {
        "users": [
      	{
      	  "name": "user1",
      	  "password": "******",
      	  "description": "UserDescription1",
      	  "user_group_name": "default"
      	},
      	{
      	  "name": "user2",
      	  "password": "******",
      	  "description": "UserDescription2",
      	  "user_group_name": "UserGroup1"
      	}
        ]
      }

Response

  • Response parameters

    Returned status code 201: successful operation

    Table 5 Parameters in the response body

    Parameter

    Type

    Description

    invalid_users

    Arrays of

    InvalidVpnUser

    Object

    Specifies the list of invalid VPN users. If the invalid_users parameter is not empty, all users fail to be created in batches. You need to correct parameter settings in the request and try again.

    request_id

    String

    Specifies a request ID.

    Table 6 InvalidVpnUser

    Parameter

    Type

    Description

    name

    String

    Specifies a username.

    description

    String

    Specifies user description.

    user_group_name

    String

    Specifies the name of the user group to which the user belongs.

    cause

    String

    Specifies the cause.

    • Example response
      Response of successful batch creation:
      {
        "invalid_users": [],
        "request_id": "b19ba5a0be8f7b7f664b14596f8f35db"
      }

      Response to a request that contains invalid users:

      {
          "invalid_users": [
              {
                  "name": "USER1",
                  "description": "UserDescription",
                  "user_group_name": "default",
                  "cause": "Duplicate user name."
              },
              {
                  "name": "USER2",
                  "description": "UserDescription",
                  "user_group_name": "default",
                  "cause": "Password length invalid."
              }
          ],
          "request_id": "49b52ed16992baa4650d093b512a59b6"
      }

Status Codes

For details, see Status Codes.