Public 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 DnsClient
DnsClient serves as the client for public DNS services, providing developers with a range of methods to interact with DNS services. When creating a DnsClient, 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);
7DnsClient dnsClient = new DnsClient(config);
Add domain name
Function declaration
1public void createZone(CreateZoneRequest body, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Adding a Domain Name
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: ExampleCreateZone.java
Query domain name list
Function declaration
1public ListZoneResponse listZone(String name, String marker, Integer maxKeys) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Querying Domain Name List
Response value
- Operation succeeded
1{
2 "metadata": For details, refer to the metadata section in the appendix,
3 "nextMarker": "5678",
4 "marker": "1234",
5 "maxKeys": 1000,
6 "isTruncated": true,
7 "zones": [
8 {
9 "id": "1234",
10 "name": "baidu.com",
11 "status": "running",
12 "productVersion": "free",
13 "createTime": "2022-04-27 20:19:58",
14 "expireTime": "2023-04-27 20:19:58",
15 "tags": [
16 {
17 "tagKey": "Default project",
18 "tagValue": ""
19 }
20 ]
21 }
22 ]
23}
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, refer to ExampleListZone.java
Delete domain name
Function declaration
1public void deleteZone(String zoneName, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Deleting a Domain Name
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: ExampleDeleteZone.java
Purchase a paid domain name
Function declaration
1public void createPaidZone(CreatePaidZoneRequest body, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Purchasing Paid Domain Names
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: ExampleCreatePaidZone.java
Upgrade a free domain name to a discount domain name
Function declaration
1public void upgradeZone(UpgradeZoneRequest body, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Upgrading Free Domain Name to Discount Domain Name
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: ExampleUpgradeZone.java
Renew domain name
Function declaration
1public void renewZone(String name, RenewZoneRequest body, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Domain Name Renewal
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: ExampleRenewZone.java
Add resolution record
Function declaration
1public void createRecord(String zoneName, CreateRecordRequest body, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Adding 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: ExampleAddRecordOnZone.java
Query resolution record list
Function declaration
1public ListRecordResponse listRecord(String zoneName, String rr, String id, String marker, Integer maxKeys) {
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": "5678",
4 "marker": "1234",
5 "maxKeys": 1000,
6 "isTruncated": true,
7 "records": [
8 {
9 "id":"1234",
10 "rr":"www",
11 "status":"running",
12 "type":"A",
13 "value":"192.168.1.1",
14 "ttl":300,
15 "line":default,
16 "description":"desc"
17 }
18 ]
19}
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, please refer to: ExampleListRecordOfZone.java
Modify resolution record
Function declaration
1public void updateRecord(String zoneName, 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: ExampleUpdateRecordOfZone.java
Enable resolution record
Function declaration
1public void updateRecordEnable(String zoneName, String recordId, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Modifying Resolution Record Status
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: ExampleEnableRecordOfZone.java
Disable resolution record list
Function declaration
1public void updateRecordDisable(String zoneName, String recordId, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Modifying Resolution Record Status
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: ExampleDisableRecordOfZone.java
Delete resolution record
Function declaration
1public void deleteRecord(String zoneName, 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: ExampleDeleteRecordOfZone.java
Add line group
Function declaration
1public void addLineGroup(AddLineGroupRequest body, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Adding a Line Group
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: ExampleAddLineGroup.java
Update line group
Function declaration
1public void updateLineGroup(String lineId, UpdateLineGroupRequest body, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation: Request Parameters for Updating a Line Group
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: ExampleUpdateLineGroup.java
Query line group list
Function declaration
1public ListLineGroupResponse listLineGroup(String marker, Integer maxKeys) {
2 ......
3}
Parameter meaning
Refer to OpenAPI documentation: Request Parameters for Querying Line Group List
Response value
- Operation succeeded
1{
2 "metadata": For details, refer to the metadata section in the appendix,
3 "marker": "1234",
4 "isTruncated": true,
5 "nextMarker": "6056",
6 "maxKeys": 1000,
7 "lineList": [
8 {
9 "id": "6055",
10 "name": "abc",
11 "lines": ["yunnan.ct","sichuan.cmnet"],
12 "relatedZoneCount": 0,
13 "relatedRecordCount": 0
14 }
15 ]
16}
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Code example
For specific code examples, refer to ExampleListLineGroup.java
Delete line group
Function declaration
1public void deleteLineGroup(String lineId, String clientToken) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation: Request Parameters for Deleting a Line Group
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: ExampleDeleteLineGroup.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 }
