bce-python-sdk 0.9.17__py3-none-any.whl → 0.9.19__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 CHANGED
@@ -18,7 +18,7 @@ from builtins import bytes
18
18
  from . import protocol
19
19
 
20
20
 
21
- SDK_VERSION = b'0.9.17'
21
+ SDK_VERSION = b'0.9.19'
22
22
  DEFAULT_SERVICE_DOMAIN = b'bcebos.com'
23
23
  URL_PREFIX = b'/v1'
24
24
  DEFAULT_ENCODING = 'UTF-8'
@@ -1069,7 +1069,7 @@ class BccClient(bce_base_client.BceBaseClient):
1069
1069
  body['userData'] = user_data
1070
1070
  if res_group_id is not None:
1071
1071
  body['resGroupId'] = res_group_id
1072
- body['isEipAutoRelatedDelete'] = is_eip_auto_related_delete
1072
+ body['isEipAutoRelatedDelete'] = is_eip_auto_related_delete
1073
1073
 
1074
1074
  return self._send_request(http_methods.POST, path, json.dumps(body),
1075
1075
  params=params, config=config)
@@ -4741,7 +4741,7 @@ class BccClient(bce_base_client.BceBaseClient):
4741
4741
  return self._send_request(http_methods.PUT, path, json.dumps(body), params=params, config=config)
4742
4742
 
4743
4743
  @required(instance_id=(bytes, str), is_eip_auto_related_delete=bool)
4744
- def modify_related_delete_policy(self, instance_id, is_eip_auto_related_delete, client_token=None, config=None):
4744
+ def modify_related_delete_policy(self, instance_id, is_eip_auto_related_delete, client_token=None, config=None):
4745
4745
  """
4746
4746
  Set bid instance eip_auto_related_delete.
4747
4747
 
@@ -5228,7 +5228,9 @@ class BccClient(bce_base_client.BceBaseClient):
5228
5228
  return self._send_request(http_methods.GET, path, prefix=b"/v1", params=params, config=config)
5229
5229
 
5230
5230
  def instance_change_subnet(self, instance_id, subnet_id=None,
5231
- internal_ip=None, reboot=None, client_token=None, config=None):
5231
+ internal_ip=None, reboot=None,
5232
+ security_group_ids=None, enterprise_security_group_ids=None,
5233
+ client_token=None, config=None):
5232
5234
  """
5233
5235
  Change instance subnet by id.
5234
5236
 
@@ -5248,6 +5250,12 @@ class BccClient(bce_base_client.BceBaseClient):
5248
5250
  Reboot instance or not. Default value is False.
5249
5251
  :type reboot: bool
5250
5252
 
5253
+ :param security_group_ids:
5254
+ :type security_group_ids: list<string>
5255
+
5256
+ :param enterprise_security_group_ids:
5257
+ :type enterprise_security_group_ids: list<string>
5258
+
5251
5259
  :return:
5252
5260
  :rtype baidubce.bce_response.BceResponse
5253
5261
  """
@@ -5268,6 +5276,12 @@ class BccClient(bce_base_client.BceBaseClient):
5268
5276
  if reboot is not None:
5269
5277
  body['reboot'] = reboot
5270
5278
 
5279
+ if security_group_ids is not None:
5280
+ body['securityGroupIds'] = security_group_ids
5281
+
5282
+ if enterprise_security_group_ids is not None:
5283
+ body['enterpriseSecurityGroupIds'] = enterprise_security_group_ids
5284
+
5271
5285
  return self._send_request(http_methods.PUT, path, body=json.dumps(body), params=params, config=config)
5272
5286
 
5273
5287
  def instance_change_vpc(self, instance_id, subnet_id=None,
@@ -5542,7 +5556,7 @@ class BccClient(bce_base_client.BceBaseClient):
5542
5556
  return self._send_request(http_methods.POST, path, body=json.dumps(body), params=params, config=config)
5543
5557
 
5544
5558
  def batch_create_auto_renew_rules(self, instance_id, renew_time_unit="month", renew_time=1,
5545
- client_token=None, config=None):
5559
+ renew_cds=None, renew_eip=None, client_token=None, config=None):
5546
5560
  """
5547
5561
  create auto renew rules for instance
5548
5562
 
@@ -5557,6 +5571,10 @@ class BccClient(bce_base_client.BceBaseClient):
5557
5571
  :param renew_time:
5558
5572
  renew time of year, values: 1/2/3, default value: 1
5559
5573
  :type renew_time: int
5574
+ :param renew_cds:
5575
+ renew cds, values: True/False, default value: True
5576
+ :param renew_eip:
5577
+ renew eip, values: True/False, default value: True
5560
5578
 
5561
5579
  :return:
5562
5580
  :rtype baidubce.bce_response.BceResponse
@@ -5572,16 +5590,25 @@ class BccClient(bce_base_client.BceBaseClient):
5572
5590
  "renewTimeUnit": renew_time_unit,
5573
5591
  "renewTime": renew_time
5574
5592
  }
5593
+ if renew_cds is not None:
5594
+ body["renewCds"] = renew_cds
5595
+ if renew_eip is not None:
5596
+ body["renewEip"] = renew_eip
5597
+
5575
5598
  return self._send_request(http_methods.POST, path, body=json.dumps(body), params=params, config=config)
5576
5599
 
5577
- def batch_delete_auto_renew_rules(self, instance_id, client_token=None, config=None):
5600
+ def batch_delete_auto_renew_rules(self, instance_id, renew_cds=None, renew_eip=None,
5601
+ client_token=None, config=None):
5578
5602
  """
5579
5603
  delete auto renew rules for instance
5580
5604
 
5581
5605
  :param instance_id:
5582
5606
  Identify of the instance to auto renew
5583
5607
  :type instance_id: string
5584
-
5608
+ :param renew_cds:
5609
+ renew cds, values: True/False, default value: True
5610
+ :param renew_eip:
5611
+ renew eip, values: True/False, default value: True
5585
5612
  :return:
5586
5613
  :rtype baidubce.bce_response.BceResponse
5587
5614
  """
@@ -5594,6 +5621,12 @@ class BccClient(bce_base_client.BceBaseClient):
5594
5621
  body = {
5595
5622
  "instanceId": instance_id
5596
5623
  }
5624
+
5625
+ if renew_cds is not None:
5626
+ body["renewCds"] = renew_cds
5627
+ if renew_eip is not None:
5628
+ body["renewEip"] = renew_eip
5629
+
5597
5630
  return self._send_request(http_methods.POST, path, body=json.dumps(body), params=params, config=config)
5598
5631
 
5599
5632
  def delete_recycled_instance(self, instance_id, client_token=None, config=None):
@@ -6577,6 +6610,153 @@ class BccClient(bce_base_client.BceBaseClient):
6577
6610
 
6578
6611
  return self._send_request(http_methods.GET, path, params=params, config=config)
6579
6612
 
6613
+ def create_reserved_instances(self, reserved_instance_name=None, scope=None, zone_name=None, spec=None,
6614
+ offering_type=None, instance_count=None, reserved_instance_count=None,
6615
+ reserved_instance_time=None, reserved_instance_time_unit=None,
6616
+ auto_renew_time_unit=None, auto_renew_time=None, auto_renew=None,
6617
+ effective_time=None, ehc_cluster_id=None, ticket_id=None,
6618
+ tags=None, client_token=None, config=None):
6619
+
6620
+ """
6621
+ Create reserved instances.
6622
+
6623
+ :param reserved_instance_name:
6624
+ The name of the reserved instance.
6625
+ :type reserved_instance_name: string
6626
+
6627
+ :param scope:
6628
+ The scope.
6629
+ :type scope: string
6630
+
6631
+ :param zone_name:
6632
+ The name of the availability zone.
6633
+ :type zone_name: string
6634
+
6635
+ :param spec:
6636
+ The instance specification.
6637
+ :type spec: string
6638
+
6639
+ :param offering_type:
6640
+ The offering type.
6641
+ :type offering_type: string
6642
+
6643
+ :param instance_count:
6644
+ The number of instances.
6645
+ :type instance_count: int
6646
+
6647
+ :param reserved_instance_count:
6648
+ The number of reserved instances.
6649
+ :type reserved_instance_count: int
6650
+
6651
+ :param reserved_instance_time:
6652
+ The duration of the reserved instance.
6653
+ :type reserved_instance_time: int
6654
+
6655
+ :param reserved_instance_time_unit:
6656
+ The time unit of the reserved instance.
6657
+ :type reserved_instance_time_unit: string
6658
+
6659
+ :param auto_renew_time_unit:
6660
+ The time unit for automatic renewal.
6661
+ :type auto_renew_time_unit: string
6662
+
6663
+ :param auto_renew_time:
6664
+ The duration for automatic renewal.
6665
+ :type auto_renew_time: int
6666
+
6667
+ :param auto_renew:
6668
+ Whether to enable automatic renewal, defaults to False.
6669
+ :type auto_renew: bool
6670
+
6671
+ :param effective_time:
6672
+ The effective time.
6673
+ It is immediately effective by default.
6674
+ :type effective_time: string
6675
+
6676
+ :param ehc_cluster_id:
6677
+ The EHC cluster ID.
6678
+ :type ehc_cluster_id: string
6679
+
6680
+ :param ticket_id:
6681
+ The ticket ID.
6682
+ :type ticket_id: string
6683
+
6684
+ :param tags:
6685
+ The optional list of tag to be bonded.
6686
+ :type tags: list<bcc_model.TagModel>
6687
+
6688
+ :return:
6689
+ :rtype: baidubce.bce_response.BceResponse
6690
+ """
6691
+
6692
+ path = b'/instance/reserved/create' # 请替换为实际的请求路径
6693
+ params = {}
6694
+ if client_token is not None:
6695
+ params['clientToken'] = client_token
6696
+
6697
+ body = {}
6698
+
6699
+ if reserved_instance_name is not None:
6700
+ body['reservedInstanceName'] = reserved_instance_name
6701
+ if scope is not None:
6702
+ body['scope'] = scope
6703
+ if zone_name is not None:
6704
+ body['zoneName'] = zone_name
6705
+ if spec is not None:
6706
+ body['spec'] = spec
6707
+ if offering_type is not None:
6708
+ body['offeringType'] = offering_type
6709
+ if instance_count is not None:
6710
+ body['instanceCount'] = instance_count
6711
+ if reserved_instance_count is not None:
6712
+ body['reservedInstanceCount'] = reserved_instance_count
6713
+ if reserved_instance_time is not None:
6714
+ body['reservedInstanceTime'] = reserved_instance_time
6715
+ if reserved_instance_time_unit is not None:
6716
+ body['reservedInstanceTimeUnit'] = reserved_instance_time_unit
6717
+ if auto_renew_time_unit is not None:
6718
+ body['autoRenewTimeUnit'] = auto_renew_time_unit
6719
+ if auto_renew_time is not None:
6720
+ body['autoRenewTime'] = auto_renew_time
6721
+ if auto_renew is not False:
6722
+ body['autoRenew'] = str(auto_renew).lower()
6723
+ if effective_time is not None:
6724
+ body['effectiveTime'] = effective_time
6725
+ if ehc_cluster_id is not None:
6726
+ body['ehcClusterId'] = ehc_cluster_id
6727
+ if ticket_id is not None:
6728
+ body['ticketId'] = ticket_id
6729
+ if tags is not None:
6730
+ tag_list = [tag.__dict__ for tag in tags]
6731
+ body['tags'] = tag_list
6732
+
6733
+ return self._send_request(http_methods.POST, path, body=json.dumps(body), params=params, config=config)
6734
+
6735
+ def modify_reserved_instances(self, reserved_instances=None, client_token=None, config=None):
6736
+
6737
+ """
6738
+ Modify the information of reserved instances.
6739
+
6740
+ :param reserved_instances:
6741
+ A list of dictionaries containing the information of reserved instances to be updated.
6742
+ :type reserved_instances: list<bcc_model.ModifyReservedInstanceModel>
6743
+
6744
+ :return:
6745
+ :rtype: baidubce.bce_response.BceResponse
6746
+ """
6747
+ path = b'/instance/reserved/modify'
6748
+ params = {}
6749
+ if client_token is not None:
6750
+ params['clientToken'] = client_token
6751
+
6752
+ body = {}
6753
+
6754
+ if reserved_instances is not None:
6755
+ reserved_instances_list = [reserved_instance.__dict__ for reserved_instance in reserved_instances]
6756
+ body['reservedInstances'] = reserved_instances_list
6757
+
6758
+ return self._send_request(http_methods.PUT, path, body=json.dumps(body), params=params, config=config)
6759
+
6580
6760
 
6581
6761
  def generate_client_token_by_uuid():
6582
6762
  """
@@ -170,6 +170,18 @@ class AutoSnapshotPolicyModel(object):
170
170
  self.retentionDays = retentionDays
171
171
 
172
172
 
173
+ class ModifyReservedInstanceModel(object):
174
+ """
175
+ ModifyReservedInstanceModel
176
+ """
177
+
178
+ def __init__(self, reservedInstanceId=None, zoneName=None, reservedInstanceName=None, ehcClusterId=None):
179
+ self.reservedInstanceId = reservedInstanceId
180
+ self.zoneName = zoneName
181
+ self.reservedInstanceName = reservedInstanceName
182
+ self.ehcClusterId = ehcClusterId
183
+
184
+
173
185
  class FileSystemModel(object):
174
186
  """
175
187
  This class define file system.
File without changes
@@ -0,0 +1,326 @@
1
+ """
2
+ This module provides a client class for CA.
3
+ """
4
+ import copy
5
+ import json
6
+ import uuid
7
+
8
+ from baidubce import bce_base_client, compat
9
+ from baidubce.auth import bce_v1_signer
10
+ from baidubce.http import handler, bce_http_client, http_methods
11
+ from baidubce.services.ca import ca_handler
12
+ from baidubce.utils import required
13
+
14
+
15
+ class CaClient(bce_base_client.BceBaseClient):
16
+ """
17
+ CA base sdk client
18
+ """
19
+ version = b'/v1'
20
+
21
+ content_type_header_key = b"content-type"
22
+ content_type_header_value = b"application/json;charset=UTF-8"
23
+ request_id_header_key = b"x-bce-request-id"
24
+
25
+ def __init__(self, config=None):
26
+ bce_base_client.BceBaseClient.__init__(self, config)
27
+
28
+ def _merge_config(self, config=None):
29
+ if config is None:
30
+ return self.config
31
+ else:
32
+ new_config = copy.copy(self.config)
33
+ new_config.merge_non_none_values(config)
34
+ return new_config
35
+
36
+ def _send_request(self, http_method, path,
37
+ body=None, headers=None, params=None, config=None, body_parser=None):
38
+ config = self._merge_config(config)
39
+ if body_parser is None:
40
+ body_parser = handler.parse_json
41
+ if headers is None:
42
+ headers = {}
43
+ if self.content_type_header_key not in headers:
44
+ headers[self.content_type_header_key] = self.content_type_header_value
45
+ if self.request_id_header_key not in headers:
46
+ headers[self.request_id_header_key] = uuid.uuid4()
47
+
48
+ return bce_http_client.send_request(
49
+ config, bce_v1_signer.sign, [ca_handler.parse_error, body_parser],
50
+ http_method, CaClient.version + path, body, headers, params)
51
+
52
+ def batch_get_agent(self, instance_list=None):
53
+ """
54
+ Batch get agent info
55
+
56
+ :param instance_list:
57
+ Instance List
58
+ :type instance: dict
59
+ """
60
+ path = b'/ca/agent/batch'
61
+ body = {
62
+ "hosts": instance_list
63
+ }
64
+ return self._send_request(http_methods.POST, path, body=json.dumps(body))
65
+
66
+ def create_action(self, execution=None, user_id=None, action=None, targets=None,
67
+ parameters=None, target_selector=None, target_selector_type=None):
68
+ """
69
+ create execution
70
+ :param execution:
71
+ execution info
72
+ :type execution: string
73
+
74
+ :param user_id:
75
+ user_id
76
+ :type user_id: string
77
+
78
+ :param action:
79
+ action info
80
+ :type action: dict
81
+
82
+ :param targets:
83
+ targets info
84
+ :type targets:list
85
+
86
+ :param parameters:
87
+ parameters info
88
+ :type parameters:dict
89
+
90
+ :param target_selector:
91
+ target_selector info
92
+ :type target_selector:dict
93
+
94
+ :param target_selector_type:
95
+ target_selector_type info
96
+ :type target_selector_type:string
97
+
98
+ """
99
+ path = b'/ca/action'
100
+ body = {
101
+ "execution": execution,
102
+ "action": action,
103
+ "targets": targets,
104
+ "userId": user_id,
105
+ "parameters": parameters,
106
+ "targetSelector": target_selector,
107
+ "targetSelectorType": target_selector_type
108
+ }
109
+ return self._send_request(http_methods.POST, path, body=json.dumps(body))
110
+
111
+ def delete_action(self, id):
112
+ """
113
+ Delete action
114
+ :param id: The ID of the execution to be deleted
115
+ :type id: str
116
+ """
117
+ id = compat.convert_to_bytes(id)
118
+ path = b'/ca/action/%s' % id
119
+ return self._send_request(http_methods.DELETE, path)
120
+
121
+ def get_action(self, id, user_id):
122
+ """
123
+ Query id
124
+ :param id: The ID of the execution to be queried
125
+ :type id: str
126
+
127
+ Query user_id
128
+ :param user_id: user_id
129
+ :type user_id: str
130
+
131
+ """
132
+ path = b'/ca/action'
133
+ params = {
134
+ "userId": user_id,
135
+ "id": id
136
+ }
137
+ return self._send_request(http_methods.GET, path, params=params)
138
+
139
+ def update_action(self, action=None, execution=None):
140
+ """
141
+ :param action:
142
+ action info
143
+ :type action: dict
144
+
145
+ :param execution
146
+ execution info
147
+ :type execution: string
148
+ """
149
+ path = b'/ca/action'
150
+ body = {
151
+ "action": action,
152
+ "execution": execution,
153
+ }
154
+ return self._send_request(http_methods.PUT, path, body=json.dumps(body))
155
+
156
+ def action_list(self, action=None, page_no=None, page_size=None, sort=None, ascending=None, user_id=None):
157
+ """
158
+ :param action:
159
+ action info
160
+ :type action: dict
161
+
162
+ :param page_no:
163
+ page number
164
+ :type page_no: int
165
+
166
+ :param page_size:
167
+ page number
168
+ :type page_size: int
169
+
170
+ :param sort:
171
+ sort order
172
+ :type sort: str
173
+
174
+ :param ascending:
175
+ ascending order
176
+ :type ascending: bool
177
+
178
+ :param user_id:
179
+ :type user_id: str
180
+ """
181
+ path = b'/ca/action/list'
182
+ body = {
183
+ "action": action,
184
+ "pageNo": page_no,
185
+ "pageSize": page_size,
186
+ "sort": sort,
187
+ "ascending": ascending,
188
+ "userId": user_id
189
+ }
190
+ return self._send_request(http_methods.POST, path, body=json.dumps(body))
191
+
192
+ def action_run(self, action=None, parameters=None, user_id=None,
193
+ target_selector_type=None, targets=None, target_selector=None):
194
+ """
195
+ :param action:
196
+ action info
197
+ :type action: dict
198
+
199
+ :param parameters:
200
+ :param target_selector_type:map
201
+
202
+ :param user_id:
203
+ :type user_id: str
204
+
205
+ target selector type
206
+ :type target_selector_type: str
207
+
208
+ :param targets:
209
+ :type targets: list
210
+
211
+ :param target_selector:
212
+ :type target_selector: dict
213
+ """
214
+ path = b'/ca/actionRun'
215
+ body = {
216
+ "action": action,
217
+ "parameters": parameters,
218
+ "targetSelectorType": target_selector_type,
219
+ "targets": targets,
220
+ "targetSelector": target_selector,
221
+ "userId": user_id,
222
+ "execution": "RUN"
223
+ }
224
+ return self._send_request(http_methods.POST, path, body=json.dumps(body))
225
+
226
+ def get_action_run(self, id=None, user_id=None):
227
+ """
228
+ Query id
229
+ :param id: The ID of the execution to be queried
230
+ :type id: str
231
+
232
+ user_id
233
+ :user_id id: str
234
+ """
235
+ params = {
236
+ "userId": user_id,
237
+ "id": id
238
+ }
239
+ path = b'/ca/actionRun'
240
+ return self._send_request(http_methods.GET, path, params=params)
241
+
242
+ def action_run_list(self, action=None, page_no=None, page_size=None, sort=None, ascending=None, user_id=None,
243
+ start_time=None, end_time=None, keyword=None, keyword_type=None, run_id=None, is_inited=False):
244
+ """
245
+ :param action:
246
+ action info
247
+ :type action: dict
248
+
249
+ :param page_no:
250
+ page number
251
+ :type page_no: int
252
+
253
+ :param page_size:
254
+ page number
255
+ :type page_size: int
256
+
257
+ :param sort:
258
+ sort order
259
+ :type sort: str
260
+
261
+ :param ascending:
262
+ ascending order
263
+ :type ascending: bool
264
+
265
+ :param user_id:
266
+ :type user_id: str
267
+
268
+ :param start_time:
269
+ start time
270
+ :type start_time:
271
+
272
+ :param end_time:
273
+ end time
274
+ :type end_time:
275
+
276
+ :param keyword:
277
+ keyword type
278
+ :type keyword: str
279
+
280
+ :param keyword_type:
281
+ keyword type
282
+ :type keyword_type: str
283
+
284
+ :param run_id:
285
+ run id
286
+ :type run_id: str
287
+
288
+ :param is_inited:
289
+ is inited or not inited
290
+ :type is_inited: bool
291
+ """
292
+ body = {
293
+ "action": action,
294
+ "pageNo": page_no,
295
+ "pageSize": page_size,
296
+ "sort": sort,
297
+ "ascending": ascending,
298
+ "userId": user_id,
299
+ "startTime": start_time,
300
+ "endTime": end_time,
301
+ "keyword": keyword,
302
+ "keyword_type": keyword_type,
303
+ "runId": run_id,
304
+ "isInited": is_inited
305
+ }
306
+ path = b'/ca/actionRun/list'
307
+ return self._send_request(http_methods.POST, path, body=json.dumps(body))
308
+
309
+ def action_log(self, run_id=None, child_id=None, cursor=None):
310
+ """
311
+ :param run_id:
312
+ :type run_id: str
313
+
314
+ :param child_id:
315
+ :type child_id: str
316
+
317
+ :param cursor:
318
+ :type cursor: int
319
+ """
320
+ body = {
321
+ "runId": run_id,
322
+ "childId": child_id,
323
+ "cursor": cursor
324
+ }
325
+ path = b'/ca/log'
326
+ return self._send_request(http_methods.POST, path, body=json.dumps(body))
@@ -0,0 +1,84 @@
1
+ # Copyright 2014 Baidu, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
4
+ # except in compliance with the License. You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software distributed under the
9
+ # License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
10
+ # either express or implied. See the License for the specific language governing permissions
11
+ # and limitations under the License.
12
+
13
+ """
14
+ This module provides general http handler functions for processing http responses from CA services.
15
+ """
16
+
17
+ import http.client
18
+ import json
19
+ from baidubce import compat, utils
20
+ from baidubce.exception import BceClientError
21
+ from baidubce.exception import BceServerError
22
+
23
+
24
+ def parse_json_list(http_response, response):
25
+ """If the body is not empty, convert it to a python object and set autoscaling the value of
26
+ response.body. http_response is always closed if no error occurs.
27
+
28
+ :param http_response: the http_response object returned by HTTPConnection.getresponse()
29
+ :type http_response: http.HTTPResponse
30
+
31
+ :param response: general response object which will be returned to the caller
32
+ :type response: baidubce.BceResponse
33
+
34
+ :return: always true
35
+ :rtype bool
36
+ """
37
+ body = http_response.read()
38
+ if body:
39
+ body = compat.convert_to_string(body)
40
+ response.__dict__["result"] = json.loads(body, object_hook=utils.dict_to_python_object)
41
+ response.__dict__["raw_data"] = body
42
+ http_response.close()
43
+ return True
44
+
45
+
46
+ def parse_error(http_response, response):
47
+ """If the body is not empty, convert it to a python object and set autoscaling the value of
48
+ response.body. http_response is always closed if no error occurs.
49
+
50
+ :param http_response: the http_response object returned by HTTPConnection.getresponse()
51
+ :type http_response: http.HTTPResponse
52
+
53
+ :param response: general response object which will be returned to the caller
54
+ :type response: baidubce.BceResponse
55
+
56
+ :return: false if http status code is 2xx, raise an error otherwise
57
+ :rtype bool
58
+
59
+ :raise baidubce.exception.BceClientError: if http status code is NOT 2xx
60
+ """
61
+ if http_response.status // 100 == http.client.OK // 100:
62
+ return False
63
+ if http_response.status // 100 == http.client.CONTINUE // 100:
64
+ raise BceClientError(b'Can not handle 1xx http status code')
65
+ body = http_response.read()
66
+ if not body:
67
+ bse = BceServerError(http_response.reason, request_id=response.metadata.bce_request_id)
68
+ bse.status_code = http_response.status
69
+ raise bse
70
+
71
+ error_dict = json.loads(compat.convert_to_string(body))
72
+ message = str(error_dict)
73
+ if 'message' in error_dict and error_dict['message'] is not None:
74
+ message = error_dict['message']
75
+ code = "Exception"
76
+ if 'code' in error_dict and error_dict['code'] is not None:
77
+ code = error_dict['code']
78
+ request_id = response.metadata.bce_request_id
79
+ if 'request_id' in error_dict and error_dict['request_id'] is not None:
80
+ request_id = error_dict['request_id']
81
+
82
+ bse = BceServerError(message, code=code, request_id=request_id)
83
+ bse.status_code = http_response.status
84
+ raise bse
@@ -0,0 +1,129 @@
1
+ """
2
+ This module provides a model class for CA.
3
+ """
4
+
5
+ class Instance(dict):
6
+ """
7
+ This class defines the Tag object.
8
+ """
9
+
10
+ def __init__(self, instance_id):
11
+ """
12
+ :param instance_id: Instance Id
13
+ :type instance_id: str
14
+ """
15
+ super(Instance, self).__init__()
16
+ self["instanceId"] = instance_id
17
+
18
+
19
+ class Command(dict):
20
+ """
21
+ This class defines the Command object.
22
+ """
23
+
24
+ def __init__(self, type, content, scope, enable_parameter, parameters, user, work_dir):
25
+ """
26
+ :param type: Command type
27
+ :type type: str
28
+ :param content: Command content
29
+ :type content: str
30
+ :param scope: Command scope
31
+ :type scope: str
32
+ :param enable_parameter: Enable parameter flag
33
+ :type enable_parameter: bool
34
+ :param user: User
35
+ :type user: str
36
+ :param work_dir: Working directory
37
+ :type work_dir: str
38
+ """
39
+ super(Command, self).__init__()
40
+ self["type"] = type
41
+ self["content"] = content
42
+ self["scope"] = scope
43
+ self["enableParameter"] = enable_parameter
44
+ self["parameters"] = parameters
45
+ self["user"] = user
46
+ self["workDir"] = work_dir
47
+
48
+
49
+ class Action(dict):
50
+ """
51
+ This class defines the Action object.
52
+ """
53
+
54
+ def __init__(self, ref=None, id=None, type=None, name=None, timeout_second=None, command=None):
55
+ """
56
+ :param ref: Action ref
57
+ :ref type: str
58
+ :param ref: Action id
59
+ :id type: str
60
+ :param type: Action type
61
+ :type type: str
62
+ :param name: Action name
63
+ :type name: str
64
+ :param timeout_second: Timeout in seconds
65
+ :type timeout_second: int
66
+ :param command: Command object
67
+ :type command: Command
68
+ """
69
+ super(Action, self).__init__()
70
+ self["ref"] = ref
71
+ self["id"] = id
72
+ self["type"] = type
73
+ self["name"] = name
74
+ self["timeoutSecond"] = timeout_second
75
+ self["command"] = command
76
+
77
+
78
+ class Target(dict):
79
+ """
80
+ This class defines the Target object.
81
+ """
82
+
83
+ def __init__(self, instance_type, instance_id):
84
+ """
85
+ :param instance_type: Instance type
86
+ :type instance_type: str
87
+ :param instance_id: Instance Id
88
+ :type instance_id: str
89
+ """
90
+ super(Target, self).__init__()
91
+ self["instanceType"] = instance_type
92
+ self["instanceId"] = instance_id
93
+
94
+
95
+ class TargetSelector(dict):
96
+ """
97
+ This class defines the Target object.
98
+ """
99
+
100
+ def __init__(self, instance_type, tags):
101
+ """
102
+ :param instance_type: Instance type
103
+ :type instance_type: str
104
+ :param tags: tags
105
+ :type tags: list
106
+ """
107
+ super(TargetSelector, self).__init__()
108
+ self["instanceType"] = instance_type
109
+ self["tags"] = tags
110
+
111
+
112
+ class Execution(dict):
113
+ """
114
+ This class defines the Execution object.
115
+ """
116
+
117
+ def __init__(self, execution, action, targets):
118
+ """
119
+ :param execution: Execution type
120
+ :type execution: str
121
+ :param action: Action object
122
+ :type action: Action
123
+ :param targets: List of Target objects
124
+ :type targets: list
125
+ """
126
+ super(Execution, self).__init__()
127
+ self["execution"] = execution
128
+ self["action"] = action
129
+ self["targets"] = targets
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bce-python-sdk
3
- Version: 0.9.17
3
+ Version: 0.9.19
4
4
  Summary: BCE SDK for python
5
5
  Home-page: http://bce.baidu.com
6
6
  Author:
@@ -1,4 +1,4 @@
1
- baidubce/__init__.py,sha256=IiAUnCN3aPcgGEmH4gmPnUzzxhvnXo8uzgoifTgna_g,813
1
+ baidubce/__init__.py,sha256=4jhnanAX6CmYn6fEzwsN-t6UmwhG_b83UzLxHo7yyhc,813
2
2
  baidubce/bce_base_client.py,sha256=7gjkRy_YlTTb6TXHYHyZRYMjdVO7FTtHMdwXx8bPgsE,3428
3
3
  baidubce/bce_client_configuration.py,sha256=Wzuu9JR11hcHxgcKQIP63qIChEzVrT9ZA_fyqIfqqP4,3055
4
4
  baidubce/bce_response.py,sha256=V5a3bgRj04cM3Ml3s1OByLyZZSGDUy9PL52JSugmCgM,1655
@@ -27,8 +27,8 @@ baidubce/services/bbc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
27
27
  baidubce/services/bbc/bbc_client.py,sha256=OSDBnJK3b1TFLQJ8YALK-qEkzolFE1-J81mZy5512OE,37967
28
28
  baidubce/services/bbc/bbc_model.py,sha256=Dy80LZ4ro_iS3UejJ_CL9kI7OyMSBoDitTE4J1XAC_g,1790
29
29
  baidubce/services/bcc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
- baidubce/services/bcc/bcc_client.py,sha256=WiepqJGVPs520164YiXsmIIHebMDEvW3-km_4n5906Q,248962
31
- baidubce/services/bcc/bcc_model.py,sha256=7v5WzqDDhl7MmI3vDdOuyM5S9isxkKoaIv5RAqzzTRI,5919
30
+ baidubce/services/bcc/bcc_client.py,sha256=JTsQfoE1LYvsuFwHBh_MG1pM6ZSLJQbmg5NBqDFHjVM,255608
31
+ baidubce/services/bcc/bcc_model.py,sha256=QKXqundXCjCjv7Q5Bl9NfHRgDzBxPxYOBuXoQ6yPG4A,6307
32
32
  baidubce/services/bcc/fpga_card_type.py,sha256=n6goqnapIgAC9_sciA_2he5HFqPRbRv109qitO7qpd8,948
33
33
  baidubce/services/bcc/gpu_card_type.py,sha256=HEfMzne-UC5F295JPrPUu7V9F5g-hbXF2TNBontEFes,1054
34
34
  baidubce/services/bcm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -53,6 +53,10 @@ baidubce/services/bts/__init__.py,sha256=714yrJr3fupwooCvp7LBsBwS151wRo7OltVUFCk
53
53
  baidubce/services/bts/bts_client.py,sha256=8J8BFllo3DEgFYloeliUxpGZHAuTQrKpnTEDkJdAwj4,21916
54
54
  baidubce/services/bts/model.py,sha256=venQTHnF4Yqg5TKF8uFcUrJ8TIqhkVBoJNKY54DERwg,11520
55
55
  baidubce/services/bts/util.py,sha256=0HbqDbALL2-KTlNlnt7N7XOlG1mnhv6VLkajScDSYZY,1521
56
+ baidubce/services/ca/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
+ baidubce/services/ca/ca_client.py,sha256=GIAmcaN-fY7uvh60McBRNFueVg5L1v--MMHAYu5SOBE,8838
58
+ baidubce/services/ca/ca_handler.py,sha256=DOqyHfUmN_INDo9ptb5YdSKRpN-Pnf0ErFR_zenanxc,3326
59
+ baidubce/services/ca/ca_model.py,sha256=gu52IMYiW_QjX4Z45nTT78kANwEw5T6FBuiDsIzZkTM,3389
56
60
  baidubce/services/cdn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
61
  baidubce/services/cdn/cdn_client.py,sha256=8PnvEumExNPgIzGlz1hVhTVLqlYvvInqAlJhBPhgWvE,59017
58
62
  baidubce/services/cdn/cdn_stats_param.py,sha256=8ikq5ACllMhC1ArIm3xgH-jAK3MkFLaYYF0T1BMPdeo,1252
@@ -173,7 +177,7 @@ baidubce/services/vpc/vpc_client.py,sha256=6HD-TIxmNPujzIVc37Z9OOp_JUOoITUPzTwjm
173
177
  baidubce/services/vpn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
174
178
  baidubce/services/vpn/vpn_client.py,sha256=VGmPmnl7Il_NcbGMAgASmVK_1IF9HQ8PJ-WLij-7Axc,28554
175
179
  baidubce/services/vpn/vpn_model.py,sha256=r9V2At9ll9cZTOryGflS9tH9DlHdeelKYuGXvTNyTgg,3364
176
- bce_python_sdk-0.9.17.dist-info/METADATA,sha256=fuspq3e587v5i3rzX0OM6KWhyEVJ2NpN8kSJIuIx4gI,319
177
- bce_python_sdk-0.9.17.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
178
- bce_python_sdk-0.9.17.dist-info/top_level.txt,sha256=Oh6eo_-T_AuEDpIaR54biUUPThxsoQiYMVHLBTaweQs,9
179
- bce_python_sdk-0.9.17.dist-info/RECORD,,
180
+ bce_python_sdk-0.9.19.dist-info/METADATA,sha256=3Jizo3jDTSrtJaFKbzUDqpViWZJGoBrZ584Rmj7QA28,319
181
+ bce_python_sdk-0.9.19.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
182
+ bce_python_sdk-0.9.19.dist-info/top_level.txt,sha256=Oh6eo_-T_AuEDpIaR54biUUPThxsoQiYMVHLBTaweQs,9
183
+ bce_python_sdk-0.9.19.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.1.0)
2
+ Generator: setuptools (72.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5