/
example_list_lbdc.py
57 lines (47 loc) · 1.62 KB
/
example_list_lbdc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
"""
Samples for lbdc client.
"""
import lbdc_sample_conf as sample_conf
from baidubce.services.lbdc.lbdc_client import LbdcClient
from baidubce import exception
def test_list_lbdc(lbdc_client, lbdc_name):
"""
Query the list lbdc with specified name
Args:
:type lbdc_client: LbdcClient
:param lbdc_client: lbdc sdk client
:type lbdc_name: str
:param lbdc_name: name of lbdc to be query
Return:
None
Raise:
BceHttpClientError: http request error
"""
try:
response = lbdc_client.list_lbdc(name=lbdc_name)
print(response)
except exception.BceHttpClientError as e:
# 异常处理
print(e.last_error)
print(e.request_id)
print(e.code)
return None
if __name__ == '__main__':
# 初始化LbdcClient
lbdc_client = LbdcClient(sample_conf.config)
# lbdc的集群名称
lbdc_name = b'test-lbdc'
# 查询lbdc集群列表
test_list_lbdc(lbdc_client, lbdc_name)