BccClient
BccClient is the client for the BCC service, providing developers with various methods to interact with the BCC service, including instances, disks, images, snapshots, security groups, availability zones, and more.
Access BCC via AK/SK
Users can refer to the following code to create BccClient:
1class sample_default_host():
2
3 def setUp(self):
4
5 AK = 'your-access-key-id' # User's Access Key ID
6
7 SK = 'your-secret-access-key' # User's Secret Access Key
8
9# Initialize a BCCClient
10
11 config = BceClientConfiguration(credentials=BceCredentials(AK, SK))
12
13 client = bcc_client.BccClient(config)
In the code above, the variables AK and SK are system-assigned strings that identify users and handle signature verification for BCC access.
Here, AK corresponds to "Access Key ID" in the console, and SK corresponds to “Access Key Secret” in the console. For the method to obtain them, please refer to [Obtaining AK/SK](Reference/Retrieve AK and SK/How to Obtain AKSK.md)
The above method uses the default domain name (Beijing region) as the BCC service address. To use a custom domain, provide the Endpoint parameter.
1class sample_customize_host():
2
3 def setUp(self):
4
5 AK = 'your-access-key-id' # User's Access Key ID
6
7 SK = 'your-secret-access-key' # User's Secret Access Key
8©
9 HOST = 'domain-name' # User-specified domain name. For domain selection, refer to the Region List below
10
11# Initialize a BCCClient
12
13 config = BceClientConfiguration(credentials=BceCredentials(AK, SK),endpoint = HOST)
14
15 client = bcc_client.BccClient(config)
Note: The Endpoint parameter must use region-specific domains. If unspecified, it defaults to the Beijing regionhttp://bcc.bj.baidubce.com
For the regions supported by BCC, please refer to [Region List](BCC/API Reference/Service domain.md)
