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
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. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
X-Client-Token |
String |
No |
|
Request
- Request parameters
Table 3 Request parameters Parameter
Type
Mandatory
Description
users
Array of
objects
Yes
Specifies the list of VPN users to be created.
Table 4 CreateVpnUser Parameter
Type
Mandatory
Description
name
String
No
- Specifies a username.
- The value is a string of 4 to 32 characters, which can contain letters, digits, periods (.), underscores (_), and hyphens (-)
password
String
No
- 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.
static_ip
String
No
- Specifies the static IP address of a client.
- The value is an IPv4 address in dotted decimal notation (for example, 192.168.0.5) or disable.
- The default value is disable, indicating that a client IP address is randomly allocated.
- Constraints:
- The value must be within the client CIDR block.
- The value cannot be the gateway IP address of the client CIDR block. For example, if the client CIDR block is 192.168.0.0/24, 192.168.0.1 cannot be configured as a client address.
- The value must be the first host address in a CIDR block with a 30-bit mask. For example, for the CIDR block 192.168.10.4/30 with four IP addresses, you can only specify 192.168.10.5 as a client address.
- The value cannot be the same as the IP address of another user.
- 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
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.
static_ip
String
Specifies the static IP address of the client.
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" }
- Example response
Status Codes
For details, see Status Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.