Enterprise security group
Initialization
Confirm Endpoint
When confirming SDK usage and configuring endpoint, understand the related concepts of endpoint. Baidu AI Cloud currently supports multiple regions. Please refer toRegion Selection Guide. North China - Beijing, South China-Guangzhou, East China - Suzhou, Hong Kong, Central China-Wuhan (Financial) and North China - Baoding are supported currently. Corresponding endpoint details are as follows:
| Access region | Endpoint |
|---|---|
| North China-Beijing | bcc.bj.baidubce.com |
| South China-Guangzhou | bcc.gz.baidubce.com |
| East China-Suzhou | bcc.su.baidubce.com |
| Hong Kong | bcc.hkg.baidubce.com |
| Central China-Wuhan (Financial) | bcc.fwh.baidubce.com |
| North China-Baoding | bcc.bd.baidubce.com |
Retrieve access key
To use the security group of Baidu AI Cloud, you need a valid AK (Access Key ID) and SK (Secret Access Key) for signature certification. AK/SK are system-assigned strings used to identify users and perform signature certification for BOS. Your AK/SK information can be obtained and understood through the following steps: Register a Baidu AI Cloud account Create AK/SK
Create EsgClient
EsgClient serves as the client for the enterprise security group service, providing developers with a variety of interaction methods.
When creating an EsgClient, first configure an EsgClientConfiguration-type config instance using Endpoint, AK and SK, and then use the config instance to configure the EsgClient. The specific configuration method is as follows:
1 static final String HOST = "";
2 static final String AK = "";
3 static final String SK = "";
4 EsgClientConfiguration config = new EsgClientConfiguration();
5 config.setCredentials(new DefaultBceCredentials(AK, SK));
6 config.setEndpoint(HOST);
7 EsgClient bccClient = new EsgClient(config);
Create enterprise security group
Function declaration
1public CreateSecurityGroupResponse createSecurityGroup(CreateSecurityGroupRequest request) {
2 }
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Creating Enterprise Security Group
Response Value
- Operation succeeded
1{
2 "metadata": For details, refer to the metadata section in the appendix,
3 "enterpriseSecurityGroupId":"esg-p09p0ihp7498"
4}
- Operation failed
For response exception list of operation failure, refer to the Security Group Exception List.
Code example
For specific code examples, refer to ExampleCreateEsg.java
List enterprise security groups
Function declaration
1 public ListEsgResponse listEsg(ListEsgRequest request) {
2 }
Parameter meaning
Please refer to the OpenAPI documentation: Request Parameters for Listing Enterprise Security Groups
Response value
- Operation succeeded
1{
2 "metadata": For details, refer to the metadata section in the appendix,
3 "marker": "",
4 "isTruncated": false,
5 "maxKeys": 1000,
6 "enterpriseSecurityGroups": [
7 {
8 "id": "esg-cza4aa7z2wtd",
9 "name": "esgName",
10 "desc": "desc",
11 "createdTime": "2023-12-05T08:31:10Z",
12 "updatedTime": "2023-12-05T08:47:23Z",
13 "rules": [
14 {
15 "remark": "",
16 "direction": "ingress",
17 "action": "allow",
18 "priority": 100,
19 "ethertype": "IPv4",
20 "portRange": "2000-3000",
21 "sourcePortRange": "",
22 "localIp": "all",
23 "sourceIp": "all",
24 "destIp": "",
25 "enterpriseSecurityGroupRuleId": "esgr-q4vza39iwgv0",
26 "createdTime": "2023-12-05T08:43:14Z",
27 "updatedTime": "2023-12-05T08:43:14Z",
28 "protocol": "tcp"
29 }
30 ],
31 "tags": []
32 }
33 ]
34}
- Operation failed
For response exception list of operation failure, refer to the Security Group Exception List.
Code example
For specific code examples, refer to ExampleEsgList.java
Delete enterprise security group
Function declaration
1public void deleteEsg(String esgId) {
2}
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Deleting Enterprise Security Groups
Response Value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Security Group Exception List.
Code example
For specific code examples, refer to ExampleDeleteEsg.java
Authorize enterprise security group rules
Function declaration
1public void authorizeSecurityGroupRule(SecurityGroupRuleOperateRequest request) {
2 }
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Authorizing Enterprise Security Groups
Response Value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Security Group Exception List.
Code example
For specific code examples, refer to ExampleAddEsgRule.java
Delete enterprise security group rules
Function declaration
1 public void deleteEsgRule(String esgRuleId) {
2 }
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Revoking Enterprise Security Groups
Response Value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Security Group Exception List.
Code example
For specific code examples, refer to ExampleDeleteEsgRule.java
Update enterprise security group rules
Function declaration
1 public void updateEsgRule(UpdateEsgRuleRequest request){
2 }
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Updating Enterprise Security Group
Response Value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Security Group Exception List.
Code example
For specific code examples, refer to ExampleUpdateEsgRule.java
Appendix
Public response information in Metadata format
1 {
2 "bceRequestId":"f5f0821d-45fe-439b-bbf4-fc48b639f84a",
3 "contentLength":28,
4 "contentType":"application/json;charset=UTF-8",
5 "date":1701917695000,
6 "server":"openresty/1.15.8.1"
7 }
