Creating a Security Group
Function
This API is used to create a security group.
URI
POST /v1/{project_id}/security-groups
Name |
Mandatory |
Description |
---|---|---|
project_id |
Yes |
Specifies the project ID. For details about how to obtain a project ID, see Obtaining a Project ID. |
Request Message
- Request parameter
Table 2 Request parameter Name
Mandatory
Type
Description
security_group
Yes
Object
Specifies the security group objects. For details, see Table 3.
Table 3 Description of security_group fields Name
Mandatory
Type
Description
name
Yes
String
- Specifies the security group name.
- The value is a string of 1 to 64 characters that can contain letters, digits, underscores (_), hyphens (-), and periods (.).
vpc_id
No
String
Specifies the resource ID of the VPC to which the security group belongs.
NOTE:This parameter has been discarded, it is not recommended to use it.
- Example request
POST https://{Endpoint}/v1/{project_id}/security-groups { "security_group": { "name": "qq", "vpc_id": "3ec3b33f-ac1c-4630-ad1c-7dba1ed79d85" } }
Response Message
- Response parameter
Table 4 Response parameter Name
Type
Description
security_group
Object
Specifies the security group objects. For details, see Table 5.
Table 5 Description of security_group fields Name
Type
Description
name
String
Specifies the security group name.
description
String
Provides supplementary information about the security group.
id
String
Specifies the security group ID, which uniquely identifies the security group.
vpc_id
String
Specifies the resource ID of the VPC to which the security group belongs.
NOTE:This parameter has been discarded, it is not recommended to use it.
security_group_rules
Array of security_group_rule objects
Specifies the default security group rule, which ensures that resources in the security group can communicate with one another.
Table 6 security_group_rule objects Name
Type
Description
id
String
Specifies the security group rule ID, which uniquely identifies the security group rule.
description
String
- Provides supplementary information about the security group rule.
- The value is a string of no more than 255 characters that can contain letters and digits.
security_group_id
String
Specifies the security group rule ID, which uniquely identifies the security group rule.
direction
String
- Specifies the direction of access control.
- Possible values are as follows:
- egress
- ingress
ethertype
String
- Specifies the IP protocol version.
- The value can be IPv4 or IPv6.
protocol
String
- Specifies the protocol type.
- The value can be icmp, tcp, or udp.
- If the parameter is left blank, all protocols are supported.
port_range_min
Integer
- Specifies the start port number.
- The value ranges from 1 to 65535.
- The value cannot be greater than the port_range_max value. An empty value indicates all ports. If the protocol is icmp, the value range is shown in ICMP-Port Range Relationship Table.
port_range_max
Integer
- Specifies the end port number.
- The value ranges from 1 to 65535.
- If the protocol is not icmp, the value cannot be smaller than the port_range_min value. An empty value indicates all ports. If the protocol is icmp, the value range is shown in ICMP-Port Range Relationship Table.
remote_ip_prefix
String
- Specifies the remote IP address. If the access control direction is set to egress, the parameter specifies the source IP address. If the access control direction is set to ingress, the parameter specifies the destination IP address.
- The value can be in the CIDR format or IP addresses.
- The parameter is exclusive with parameter remote_group_id.
remote_group_id
String
- Specifies the ID of the peer security group.
- The value is exclusive with parameter remote_ip_prefix.
tenant_id
String
- Specifies the ID of the project to which the security group rule belongs.
- Example response
{ "security_group": { "id": "16b6e77a-08fa-42c7-aa8b-106c048884e6", "name": "qq", "description": "", "vpc_id": "3ec3b33f-ac1c-4630-ad1c-7dba1ed79d85", "security_group_rules": [ { "direction": "egress", "ethertype": "IPv4", "id": "369e6499-b2cb-4126-972a-97e589692c62", "description": "", "security_group_id": "16b6e77a-08fa-42c7-aa8b-106c048884e6" }, { "direction": "ingress", "ethertype": "IPv4", "id": "0222556c-6556-40ad-8aac-9fd5d3c06171", "description": "", "remote_group_id": "16b6e77a-08fa-42c7-aa8b-106c048884e6", "security_group_id": "16b6e77a-08fa-42c7-aa8b-106c048884e6" } ] } }
Status Code
See Status Codes.
Error Code
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot