Private DNS
Retrieve Endpoint
Before configuring the endpoint for SDK usage, please refer to the developer guide section on DNS Service Domain Name to understand endpoint-related concepts.
Note: DNS API supports both HTTP and HTTPS calling methods. To enhance data security, it is recommended to call via HTTPS.
Retrieve AK/SK
To use Baidu AI Cloud DNS, you must have a valid AK (Access Key ID) and SK (Secret Access Key) for signature verification. AK/SK are system-generated strings used to identify users and authorize service access. You can obtain and understand your AK/SK information by following these steps:
Create a new LdClient
LdClient serves as the client for local DNS services, providing developers with a range of methods to interact with DNS services. When creating an LdClient, first configure a BceClientConfiguration-type config instance using endpoint, AK and SK, and then use the config instance to configure the DnsClient. The specific configuration method is as follows:
1static final String ENDPOINT = "";
2static final String AK = "";
3static final String SK = "";
4BceClientConfiguration config = new BceClientConfiguration();
5config.setCredentials(new DefaultBceCredentials(AK, SK));
6config.setEndpoint(ENDPOINT);
7LdClient ldClient = new LdClient(config);
Create a PrivateZone
Function declaration
1public CreatePrivateZoneResponse createPrivateZone(CreatePrivateZoneRequest body, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Creating a PrivateZone
Response value
- Operation succeeded
1{
2 "metadata": For details, refer to the metadata section in the appendix,
3 "zoneId":"zone-jkgdns3h"
4}
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, please refer to: ExampleCreatePrivateZone.java
Delete PrivateZone
Function declaration
1public void deletePrivateZone(String zoneId, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Deleting a PrivateZone
Response value
- Operation succeeded
None
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, please refer to: ExampleDeletePrivateZone.java
Query PrivateZone list
Function declaration
1public ListPrivateZoneResponse listPrivateZone(String marker, Integer maxKeys) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Querying a PrivateZone List
Response value
- Operation succeeded
1{
2 "metadata": For details, refer to the metadata section in the appendix,
3 "nextMarker": "zone-xktdeMSf",
4 "marker": "zone-IyWRnII7",
5 "maxKeys": 1,
6 "isTruncated": true,
7 "zones": [
8 {
9 "zoneId": "zone-IyWRnII7",
10 "zoneName": "baidu.com",
11 "recordCount": 2,
12 "createTime": "2018-12-26 20:30:45",
13 "updateTime": "2018-12-28 21:35:40"
14 }
15 ]
16}
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, please refer to: ExampleListPrivateZone.java
Query details of a PrivateZone
Function declaration
1public GetPrivateZoneResponse getPrivateZone(String zoneId) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Querying a PrivateZone
Response value
- Operation succeeded
1{
2 "metadata": For details, refer to the metadata section in the appendix,
3 "zoneId": "zone-xktdeMSf",
4 "zoneName": "baidu1.com",
5 "recordCount": 2,
6 "createTime": "2018-12-26 20:30:45",
7 "updateTime": "2018-12-28 21:35:40"
8 "bindVpcs": [
9 {
10 "vpcId": "vpc-jikh8hds",
11 "vpcName": "vpcTest",
12 "vpcRegion": "bj"
13 }
14 ]
15}
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, please refer to: ExampleDetailPrivateZone.java
Associate VPC
Function declaration
1public void bindVpc(String zoneId, BindVpcRequest body, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Associating a VPC
Response value
- Operation succeeded
None
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, please refer to: ExampleBindVpcOnPrivateZone.java
Disassociate VPC
Function declaration
1public void unbindVpc(String zoneId, UnbindVpcRequest body, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Disassociating VPC
Response value
- Operation succeeded
None
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, please refer to: ExampleUnBindVpcFromPrivateZone.java
Add resolution record
Function declaration
1public AddRecordResponse addRecord(String zoneId, AddRecordRequest body, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Adding Resolution Records
Response value
- Operation succeeded
1{
2 "metadata": For details, refer to the metadata section in the appendix,
3 "recordId":"rc-jih8hd5s"
4}
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, please refer to: ExampleAddRecordOnPrivateZone.java
Modify resolution record
Function declaration
1public void updateRecord(String recordId, UpdateRecordRequest body, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Modifying Resolution Records
Response value
- Operation succeeded
None
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, please refer to: ExampleUpdateRecordOnPrivateZone.java
Delete resolution record
Function declaration
1public void deleteRecord(String recordId, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Deleting Resolution Records
Response value
- Operation succeeded
None
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, please refer to: ExampleDeleteRecordOnPrivateZone.java
Query resolution record list
Function declaration
1public ListRecordResponse listRecord(String zoneId) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Querying Resolution Record List
Response value
- Operation succeeded
1{
2 "metadata": For details, refer to the metadata section in the appendix,
3 "nextMarker": "rc-Iy8p6arqenI7",
4 "marker": "rc-ik9p9zq6u5ry",
5 "maxKeys": 1,
6 "isTruncated": true,
7 "records": [
8 {
9 "recordId": "rc-djkf8hf9",
10 "rr": "ip",
11 "value": "192.184.18.233",
12 "status": "enable",
13 "type": "A",
14 "ttl": 60,
15 "description": "desc"
16 }
17 ]
18}
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, please refer to: ExampleListRecordsOfPrivateZone.java
Enable resolution record
Function declaration
1public void enableRecord(String recordId, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Enabling Resolution Records
Response value
- Operation succeeded
None
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, please refer to: ExampleEnableRecordOnPrivateZone.java
Disable resolution record
Function declaration
1public void disableRecord(String recordId, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Disabling Resolution Records
Response value
- Operation succeeded
None
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, please refer to: ExampleDisableRecordOnPrivateZone.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 }
