bce-python-sdk 0.9.67__py3-none-any.whl → 0.9.69__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- baidubce/__init__.py +1 -1
- baidubce/bce_response.py +44 -0
- baidubce/http/handler.py +1 -0
- baidubce/services/bcc/bcc_client.py +77 -1
- baidubce/services/bcm/bcm_client.py +1490 -0
- baidubce/services/endpoint/endpoint_client.py +25 -7
- baidubce/services/etGateway/et_gateway_client.py +28 -6
- baidubce/services/havip/havip_client.py +44 -47
- baidubce/services/probe/probe_client.py +2 -2
- baidubce/services/vpc/peerconn_client.py +46 -2
- baidubce/services/vpc/template_client.py +10 -9
- {bce_python_sdk-0.9.67.dist-info → bce_python_sdk-0.9.69.dist-info}/METADATA +1 -1
- {bce_python_sdk-0.9.67.dist-info → bce_python_sdk-0.9.69.dist-info}/RECORD +15 -15
- {bce_python_sdk-0.9.67.dist-info → bce_python_sdk-0.9.69.dist-info}/WHEEL +0 -0
- {bce_python_sdk-0.9.67.dist-info → bce_python_sdk-0.9.69.dist-info}/top_level.txt +0 -0
baidubce/__init__.py
CHANGED
baidubce/bce_response.py
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
"""
|
|
14
14
|
This module provides a general response class for BCE services.
|
|
15
15
|
"""
|
|
16
|
+
import json
|
|
17
|
+
|
|
16
18
|
from future.utils import iteritems
|
|
17
19
|
from builtins import str
|
|
18
20
|
from builtins import bytes
|
|
@@ -60,3 +62,45 @@ class BceResponse(object):
|
|
|
60
62
|
|
|
61
63
|
def __repr__(self):
|
|
62
64
|
return utils.print_object(self)
|
|
65
|
+
|
|
66
|
+
def to_map(self):
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
:return: dict
|
|
70
|
+
"""
|
|
71
|
+
result = dict()
|
|
72
|
+
result['headers'] = self._to_dict(self.metadata)
|
|
73
|
+
result['statusCode'] = self.status_code
|
|
74
|
+
result['body'] = self.get_body_map()
|
|
75
|
+
return result
|
|
76
|
+
|
|
77
|
+
def get_body_map(self):
|
|
78
|
+
"""
|
|
79
|
+
Deserialize self.raw_data JSON string into a Python object.
|
|
80
|
+
"""
|
|
81
|
+
content = self.raw_data
|
|
82
|
+
if not content:
|
|
83
|
+
return {}
|
|
84
|
+
try:
|
|
85
|
+
if isinstance(content, dict):
|
|
86
|
+
return content
|
|
87
|
+
if isinstance(content, str):
|
|
88
|
+
content = content.strip()
|
|
89
|
+
return json.loads(content)
|
|
90
|
+
except (json.JSONDecodeError, TypeError):
|
|
91
|
+
return {"raw_content": content}
|
|
92
|
+
|
|
93
|
+
@staticmethod
|
|
94
|
+
def _to_dict(obj):
|
|
95
|
+
"""
|
|
96
|
+
Recursively convert an object to a dictionary
|
|
97
|
+
"""
|
|
98
|
+
if isinstance(obj, (list, tuple, set)):
|
|
99
|
+
return [BceResponse._to_dict(i) for i in obj]
|
|
100
|
+
elif isinstance(obj, dict):
|
|
101
|
+
return {k: BceResponse._to_dict(v) for k, v in obj.items()}
|
|
102
|
+
elif hasattr(obj, "__dict__"):
|
|
103
|
+
return {k: BceResponse._to_dict(v) for k, v in obj.__dict__.items() if not k.startswith('_')}
|
|
104
|
+
else:
|
|
105
|
+
# Return primitive types directly
|
|
106
|
+
return obj
|
baidubce/http/handler.py
CHANGED
|
@@ -41,6 +41,7 @@ def parse_json(http_response, response):
|
|
|
41
41
|
body = compat.convert_to_string(body)
|
|
42
42
|
response.__dict__.update(json.loads(body, object_hook=utils.dict_to_python_object).__dict__)
|
|
43
43
|
response.__dict__["raw_data"] = body
|
|
44
|
+
response.__dict__["status_code"] = http_response.status
|
|
44
45
|
http_response.close()
|
|
45
46
|
return True
|
|
46
47
|
|
|
@@ -1341,6 +1341,39 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
1341
1341
|
return self._send_request(http_methods.PUT, path, json.dumps(body),
|
|
1342
1342
|
params=params, config=config)
|
|
1343
1343
|
|
|
1344
|
+
@required(instance_ids=list)
|
|
1345
|
+
def batch_reboot_instance(self, instance_ids=None, force_stop=False, config=None):
|
|
1346
|
+
"""
|
|
1347
|
+
Rebooting the instance owned by the user.
|
|
1348
|
+
You can reboot the instance only when the instance is Running,
|
|
1349
|
+
otherwise, it's will get 409 errorCode.
|
|
1350
|
+
This is an asynchronous interface,
|
|
1351
|
+
you can get the latest status by BccClient.get_instance.
|
|
1352
|
+
|
|
1353
|
+
:param instance_ids:
|
|
1354
|
+
The ids of instance.
|
|
1355
|
+
:type instance_ids: list
|
|
1356
|
+
|
|
1357
|
+
:param force_stop:
|
|
1358
|
+
The optional parameter to stop the instance forcibly.If true,
|
|
1359
|
+
it will stop the instance just like power off immediately
|
|
1360
|
+
and it may result in losing important data which have not been written to disk.
|
|
1361
|
+
:type force_stop: boolean
|
|
1362
|
+
|
|
1363
|
+
:return:
|
|
1364
|
+
:rtype baidubce.bce_response.BceResponse
|
|
1365
|
+
"""
|
|
1366
|
+
path = b'/instance/batchAction'
|
|
1367
|
+
body = {
|
|
1368
|
+
'instanceIds': instance_ids,
|
|
1369
|
+
'forceStop': force_stop
|
|
1370
|
+
}
|
|
1371
|
+
params = {
|
|
1372
|
+
'reboot': None
|
|
1373
|
+
}
|
|
1374
|
+
return self._send_request(http_methods.PUT, path, json.dumps(body),
|
|
1375
|
+
params=params, config=config)
|
|
1376
|
+
|
|
1344
1377
|
@required(instance_id=str)
|
|
1345
1378
|
def batch_add_ip(self, instance_id, private_ips=None, secondary_private_ip_address_count=None,
|
|
1346
1379
|
allocate_multi_ipv6_addr=None, config=None):
|
|
@@ -5879,7 +5912,7 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
5879
5912
|
return self._send_request(http_methods.POST, path, body=json.dumps(body), params=params, config=config)
|
|
5880
5913
|
|
|
5881
5914
|
def list_instance_no_charge(self, marker=None, max_keys=None, internal_ip=None, keypair_id=None,
|
|
5882
|
-
zone_name=None, client_token=None, config=None):
|
|
5915
|
+
zone_name=None, instance_ids=None, client_token=None, config=None):
|
|
5883
5916
|
"""
|
|
5884
5917
|
Return a list of no charge instances owned by the authenticated user.
|
|
5885
5918
|
|
|
@@ -5907,6 +5940,10 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
5907
5940
|
get instance list filtered by name of available zone
|
|
5908
5941
|
:type zone_name: string
|
|
5909
5942
|
|
|
5943
|
+
:param instance_ids:
|
|
5944
|
+
The id of instance.
|
|
5945
|
+
:type instance_ids: string
|
|
5946
|
+
|
|
5910
5947
|
:return:
|
|
5911
5948
|
:rtype baidubce.bce_response.BceResponse
|
|
5912
5949
|
"""
|
|
@@ -5926,6 +5963,8 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
5926
5963
|
params['keypairId'] = keypair_id
|
|
5927
5964
|
if zone_name is not None:
|
|
5928
5965
|
params['zoneName'] = zone_name
|
|
5966
|
+
if instance_ids is not None:
|
|
5967
|
+
params['instanceIds'] = instance_ids
|
|
5929
5968
|
return self._send_request(http_methods.GET, path, params=params, config=config)
|
|
5930
5969
|
|
|
5931
5970
|
def cancel_bid_order(self, order_id, client_token=None, config=None):
|
|
@@ -8112,6 +8151,43 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
8112
8151
|
return self._send_request(http_methods.POST, path, json.dumps(body),
|
|
8113
8152
|
params=params, config=config)
|
|
8114
8153
|
|
|
8154
|
+
def query_reserved_instance_price(self, spec_id, spec, offering_type, zone_name,
|
|
8155
|
+
scope=None, reserved_instance_count=None,
|
|
8156
|
+
price_time_unit=None, reserved_instance_time=None,
|
|
8157
|
+
purchase_num=None, client_token=None, config=None):
|
|
8158
|
+
"""
|
|
8159
|
+
query_reserved_instance_price
|
|
8160
|
+
"""
|
|
8161
|
+
path = b'/v2/reservedInstance/price'
|
|
8162
|
+
params = {
|
|
8163
|
+
'interfaceName': 'apiV2_reservedInstancePrice'
|
|
8164
|
+
}
|
|
8165
|
+
if client_token is None:
|
|
8166
|
+
params['clientToken'] = generate_client_token()
|
|
8167
|
+
else:
|
|
8168
|
+
params['clientToken'] = client_token
|
|
8169
|
+
|
|
8170
|
+
body = {
|
|
8171
|
+
'specId': spec_id,
|
|
8172
|
+
'spec': spec,
|
|
8173
|
+
'offeringType': offering_type,
|
|
8174
|
+
'zoneName': zone_name,
|
|
8175
|
+
}
|
|
8176
|
+
if scope is not None:
|
|
8177
|
+
body['scope'] = scope
|
|
8178
|
+
if reserved_instance_count is not None:
|
|
8179
|
+
body['reservedInstanceCount'] = reserved_instance_count
|
|
8180
|
+
if price_time_unit is not None:
|
|
8181
|
+
body['priceTimeUnit'] = price_time_unit
|
|
8182
|
+
if reserved_instance_time is not None:
|
|
8183
|
+
body['reservedInstanceTime'] = reserved_instance_time
|
|
8184
|
+
if purchase_num is not None:
|
|
8185
|
+
body['purchaseNum'] = purchase_num
|
|
8186
|
+
|
|
8187
|
+
return self._send_request(http_methods.POST, path, json.dumps(body),
|
|
8188
|
+
params=params, config=config)
|
|
8189
|
+
|
|
8190
|
+
|
|
8115
8191
|
|
|
8116
8192
|
def generate_client_token_by_uuid():
|
|
8117
8193
|
"""
|