Initialization
Confirm Endpoint
When confirming the Endpoint configured when you use the SDK, you can first read the section on BLB Access Domain Name in the Developer Guide to understand the Endpoint concept. Baidu AI Cloud currently supports multi-regions. Please see Region Selection Instructions.
Currently support the regions of "Beijing", "Guangzhou", "Suzhou", "Hong Kong", "Wuhan" and "Baoding".
The corresponding information of the service domain name is:
Access region | Corresponding Endpoint |
---|---|
bj | blb.bj.baidubce.com |
gz | blb.gz.baidubce.com |
su | blb.su.baidubce.com |
hkg | blb.hkg.baidubce.com |
fwh | blb.fwh.baidubce.com |
bd | blb.bd.baidubce.com |
New BlbClient
Create BlbClient Using AK/SK
To access BOS through AK/SK, users can create a BlbClient referring to the following code:
class Sample():
def setUp(self):
AK = 'your-access-key-id' # User's Access Key ID
SK = 'your-secret-access-key' # User's Secret Access Key
# Initialize a BlbClient
config = BceClientConfiguration(credentials=BceCredentials(AK, SK))
client = blb_client.BlbClient(config)
In the above code, AK
corresponds to the "Access Key ID" in the console, and SK
corresponds to the "Access Key Secret" in the console. For how to obtain them, see <ACCESSKEY Management in the Operation Guide>.
The above method uses the default domain name as the service address of the BLB. If the user needs to specify the domain name himself, he can specify it by passing in the ENDPOINT parameter.
AK = 'your-access-key-id' # User's Access Key ID
SK = 'your-secret-access-key' # User's Secret Access Key
HOST = 'domain-name' # User-specified domain name (please see "Region List" below for domain name selection)
# Initialize a BlbClient
config = BceClientConfiguration(credentials=BceCredentials(AK, SK), endpoint=HOST)
client = blb_client.BlbClient(config)
Note: The
ENDPOINT
parameter can only be defined with the specified domain name of the areas included. If not specified, it defaults to the Beijing area. (http://blb.bj.baidubce.com
).