Private DNS
Confirm Endpoint
Local DNS is a global product, and the service domain name for its API is: privatezone.baidubce.com
Retrieve AK/SK
To use the Baidu AI Cloud products, you need a Baidu AI Cloud account, a valid AK (Access Key ID) and SK (Secret Access Key) for signature certification. Your AK/SK information can be obtained and understood through the following steps: 1. Register a Baidu AI Cloud Account 2. Create AK/SK
This document primarily introduces the installation and usage of the BOS Python SDK.
Before reading this document, you need to activate the BOS service first and understand the basic knowledge of BOS. If you are not yet familiar with BOS, you can refer to Product Description and Beginner’s Guide
Create a new LocalDnsClient
When creating a LocalDnsClient, first configure a HaVipClientConfiguration-type config instance using Endpoint, AK and SK, and then use the config instance to configure the LocalDnsClient. The specific configuration method is as follows:
1ak = "Your Ak" # AK of the account
2 ak = "Your Sk" # SK of the account
3 endpoint = "bcc.bj.baidubce.com" # Region domain name corresponding to the service
4config = BceClientConfiguration(credentials=BceCredentials(access_key_id=ak, secret_access_key=sk), endpoint=endpoint)
5 ld_client = ld_client.LdClient(config) # client initialization
Create a PrivateZone
Function declaration
1def create_private_zone(self, create_private_zone_request=None, client_token=None):
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/DNS/s/jkk6kkh7x
Response Value
Operation succeeded:
1{
2 "zoneId":"zone-jkgdns3h"
3}
Operation failed:
Throw an exception. For the exception list, refer to: Local DNS Exception List
Code example
For specific code examples, please refer to: example_create_private_zone.py
Delete PrivateZone
Function declaration
1def delete_private_zone(self, zone_id=None, client_token=None):
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/DNS/s/Kkk6kpur9
Response Value
Operation succeeded:
1# No return body
Operation failed:
Throw an exception. For the exception list, refer to: Local DNS Exception List
Code example
For specific code examples, please refer to: example_delete_private_zone.py
Query PrivateZone list
Function declaration
1def list_private_zone(self, marker=None, max_keys=None):
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/DNS/s/Bkk6l42dl
Response Value
Operation succeeded:
1{
2 "nextMarker": "zone-xktdeMSf",
3 "marker": "zone-IyWRnII7",
4 "maxKeys": 1,
5 "isTruncated": true,
6 "zones": [{
7 "zoneId": "zone-IyWRnII7",
8 "zoneName": "baidu.com",
9 "recordCount": 2,
10 "createTime": "2018-12-26 20:30:45",
11 "updateTime": "2018-12-28 21:35:40"
12 }]
13}
Operation failed:
Throw an exception. For the exception list, refer to: Local DNS Exception List
Code example
For specific code examples, please refer to: example_list_private_zone.py
Query details of a PrivateZone
Function declaration
1def get_private_zone(self, zone_id=None):
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/DNS/s/Jkk6lc8li
Response value
Operation succeeded:
1{
2 "zoneId": "zone-xktdeMSf",
3 "zoneName": "baidu1.com",
4 "recordCount": 2,
5 "createTime": "2018-12-26 20:30:45",
6 "updateTime": "2018-12-28 21:35:40"
7 "bindVpcs": [{
8 "vpcId": "vpc-jikh8hds",
9 "vpcName": "vpcTest",
10 "vpcRegion": "bj"
11 }]
12}
Operation failed:
Throw an exception. For the exception list, refer to: Local DNS Exception List
Code example
For specific code examples, please refer to: example_get_private_zone.py
Associate VPC
Function declaration
1def bind_vpc(self, zone_id=None, bind_vpc_request=None, client_token=None):
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/DNS/s/qkk6lg1af
Response Value
Operation succeeded:
1# No return body
Operation failed:
Throw an exception. For the exception list, refer to: Local DNS Exception List
Code example
For specific code examples, please refer to: example_bind_vpc.py
Disassociate VPC
Function declaration
1def unbind_vpc(self, zone_id=None, unbind_vpc_request=None, client_token=None):
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/DNS/s/Dkk6lkyy1
Response Value
Operation succeeded:
1# No return body
Operation failed:
Throw an exception. For the exception list, refer to: Local DNS Exception List
Code example
For specific code examples, please refer to: example_unbind_vpc.py
Add resolution record
Function declaration
1def add_record(self, zone_id=None, add_record_request=None, client_token=None):
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/DNS/s/Pkk6lpe4e
Response Value
Operation succeeded:
1{
2 "recordId":"rc-jih8hd5s"
3}
Operation failed:
Throw an exception. For the exception list, refer to: Local DNS Exception List
Code example
For specific code examples, please refer to: example_add_record.py
Modify resolution record
Function declaration
1def update_record(self, record_id=None, update_record_request=None, client_token=None):
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/DNS/s/Dkk6lu5ds
Response Value
Operation succeeded:
1# No return body
Operation failed:
Throw an exception. For the exception list, refer to: Local DNS Exception List
Code example
For specific code examples, please refer to: example_update_record.py
Delete resolution record
Function declaration
1def delete_record(self, record_id=None, delete_record_request=None, client_token=None):
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/DNS/s/Lkk6lx4f1
Response value
Operation succeeded:
1# No return body
Operation failed:
Throw an exception. For the exception list, refer to: Local DNS Exception List
Code example
For specific code examples, please refer to: example_delete_record.py
Query resolution record list
Function declaration
1def list_record(self, zone_id=None):
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/DNS/s/Ckk6m3d7a
Response Value
Operation succeeded:
1{
2 "nextMarker": "rc-Iy8p6arqenI7",
3 "marker": "rc-ik9p9zq6u5ry",
4 "maxKeys": 1,
5 "isTruncated": true,
6 "records": [{
7 "recordId": "rc-djkf8hf9",
8 "rr": "ip",
9 "value": "192.184.18.233",
10 "status": "enable",
11 "type": "A",
12 "ttl": 60,
13 "description": "desc"
14 }]
15}
Operation failed:
Throw an exception. For the exception list, refer to: Local DNS Exception List
Code example
For specific code examples, please refer to: example_list_record.py
Enable resolution record
Function declaration
1def enable_record(self, record_id=None, client_token=None):
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/DNS/s/Bkk6m60y1
Response Value
Operation succeeded:
1# No return body
Operation failed:
Throw an exception. For the exception list, refer to: Local DNS Exception List
Code example
For specific code examples, please refer to: example_enable_record.py
Disable the resolution record
Function declaration
1def disable_record(self, record_id=None, client_token=None):
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/DNS/s/Bkk6m60y1
Response Value
Operation succeeded:
1# No return body
Operation failed:
Throw an exception. For the exception list, refer to: Local DNS Exception List
Code example
For specific code examples, please refer to: example_disable_record.py
