bce-python-sdk 0.9.70__py3-none-any.whl → 0.9.72__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.70'
21
+ SDK_VERSION = b'0.9.72'
22
22
  DEFAULT_SERVICE_DOMAIN = b'bcebos.com'
23
23
  URL_PREFIX = b'/v1'
24
24
  DEFAULT_ENCODING = 'UTF-8'
@@ -43,6 +43,7 @@ class BceClientConfiguration(object):
43
43
  path_style_enable=False,
44
44
  auto_follow_redirect=False,
45
45
  under_line_headers=True,
46
+ request_payer=False,
46
47
  ):
47
48
  self.credentials = credentials
48
49
  self.endpoint = compat.convert_to_bytes(endpoint) if endpoint is not None else endpoint
@@ -63,6 +64,9 @@ class BceClientConfiguration(object):
63
64
  self.backup_endpoint = compat.convert_to_bytes(backup_endpoint) if backup_endpoint is not None else backup_endpoint
64
65
  self.auto_follow_redirect = auto_follow_redirect
65
66
  self.under_line_headers = under_line_headers
67
+ if request_payer is not None and not isinstance(request_payer, bool):
68
+ raise TypeError(b'request_payer must be a bool value')
69
+ self.request_payer = request_payer
66
70
 
67
71
  def merge_non_none_values(self, other):
68
72
  """
@@ -190,6 +190,7 @@ def send_request(
190
190
  errors = []
191
191
  while True:
192
192
  conn = None
193
+ redirect_conn = None
193
194
  try:
194
195
  # restore the offset of fp body when retrying
195
196
  if should_get_new_date is True:
@@ -247,7 +248,6 @@ def send_request(
247
248
  location = headers_map.get('location')
248
249
  _logger.debug('request auto follow redirect location is %s', location)
249
250
  parsed_url = urlparse(location)
250
- redirect_conn = None
251
251
  if protocol.name == baidubce.protocol.HTTP.name:
252
252
  redirect_conn = http.client.HTTPConnection(parsed_url.netloc,
253
253
  timeout=config.connection_timeout_in_mills / 1000)
@@ -256,7 +256,10 @@ def send_request(
256
256
  timeout=config.connection_timeout_in_mills / 1000)
257
257
  else:
258
258
  raise ValueError('Invalid protocol: %s, either HTTP or HTTPS is expected.' % protocol)
259
- redirect_conn.putrequest("GET", parsed_url.path + "?" + parsed_url.query,
259
+ redirect_uri = parsed_url.path
260
+ if parsed_url.query:
261
+ redirect_uri += "?" + parsed_url.query
262
+ redirect_conn.putrequest("GET", redirect_uri,
260
263
  skip_host=True, skip_accept_encoding=True)
261
264
  redirect_conn.putheader("Host", parsed_url.netloc)
262
265
  redirect_conn.endheaders()
@@ -268,6 +271,8 @@ def send_request(
268
271
  except Exception as e:
269
272
  if conn is not None:
270
273
  conn.close()
274
+ if redirect_conn is not None:
275
+ redirect_conn.close()
271
276
 
272
277
  # insert ">>>>" before all trace back lines and then save it
273
278
  errors.append('\n'.join('>>>>' + line for line in traceback.format_exc().splitlines()))
@@ -122,8 +122,12 @@ BOS_OBJECT_EXPIRES = b"x-bce-object-expires"
122
122
 
123
123
  BOS_TAGGING = b"x-bce-tagging"
124
124
 
125
+ BOS_TAG_LIST = b"x-bce-tag-list"
126
+
125
127
  BOS_PROCESS = b"x-bce-process"
126
128
 
129
+ BOS_REQUEST_PAYER = b"x-bce-request-payer"
130
+
127
131
  BOS_BASE_ALLOW_HEADERS = set([BOS_TRAFFIC_LIMIT, BOS_VERSIONING, BOS_TAGGING, BOS_PROCESS, BOS_OBJECT_EXPIRES])
128
132
 
129
133
  BOS_IF_MATCH = b"If-Match"
@@ -1093,6 +1093,7 @@ class BccClient(bce_base_client.BceBaseClient):
1093
1093
 
1094
1094
  def list_instances(self, marker=None, max_keys=None, internal_ip=None, dedicated_host_id=None,
1095
1095
  zone_name=None, instance_ids=None, instance_names=None, cds_ids=None, ehc_cluster_id=None,
1096
+ show_rdma_topo=None,
1096
1097
  deployset_ids=None, security_group_ids=None, payment_timing=None, status=None, tags=None,
1097
1098
  vpc_id=None, private_ips=None, ipv6_addresses=None, auto_renew=None, fuzzy_instance_name=None,
1098
1099
  config=None):
@@ -1139,6 +1140,10 @@ class BccClient(bce_base_client.BceBaseClient):
1139
1140
  get instance list filtered by id of ehc cluster
1140
1141
  :type ehc_cluster_id: string
1141
1142
 
1143
+ :param show_rdma_topo:
1144
+ filter instance list with rdma topology info
1145
+ :type show_rdma_topo: boolean
1146
+
1142
1147
  :param deployset_ids:
1143
1148
  filter instance list with multiple deployset ids join by ','
1144
1149
  :type deployset_ids: string
@@ -1205,6 +1210,8 @@ class BccClient(bce_base_client.BceBaseClient):
1205
1210
  params['cdsIds'] = cds_ids
1206
1211
  if ehc_cluster_id is not None:
1207
1212
  params['ehcClusterId'] = ehc_cluster_id
1213
+ if show_rdma_topo is not None:
1214
+ params['showRdmaTopo'] = show_rdma_topo
1208
1215
  if deployset_ids is not None:
1209
1216
  params['deploySetIds'] = deployset_ids
1210
1217
  if security_group_ids is not None:
@@ -2059,7 +2066,7 @@ class BccClient(bce_base_client.BceBaseClient):
2059
2066
  description=None, renew_time_unit=None, renew_time=None,
2060
2067
  cluster_id=None, relation_tag=False,
2061
2068
  tags=None, auto_snapshot_policy=None,
2062
- client_token=None, config=None, charge_type=None):
2069
+ client_token=None, config=None, charge_type=None, enable_delete_protection=None):
2063
2070
  """
2064
2071
  Create a volume with the specified options.
2065
2072
  You can use this method to create a new empty volume by specified options
@@ -2145,6 +2152,10 @@ class BccClient(bce_base_client.BceBaseClient):
2145
2152
  If the instance is post paid, create a post paid CDS
2146
2153
  :type charge_type: menu{'Prepaid', 'Postpaid'}
2147
2154
 
2155
+ :param enable_delete_protection:
2156
+ The optional parameter to specify whether to enable delete protection.
2157
+ :type enable_delete_protection: boolean
2158
+
2148
2159
  :return:
2149
2160
  :rtype baidubce.bce_response.BceResponse
2150
2161
  """
@@ -2189,6 +2200,8 @@ class BccClient(bce_base_client.BceBaseClient):
2189
2200
  body['instanceId'] = instance_id
2190
2201
  if charge_type is not None:
2191
2202
  body['chargeType'] = charge_type
2203
+ if enable_delete_protection is not None:
2204
+ body['enableDeleteProtection'] = enable_delete_protection
2192
2205
  return self._send_request(http_methods.POST, path, json.dumps(body),
2193
2206
  params=params, config=config)
2194
2207
 
@@ -4151,7 +4164,7 @@ class BccClient(bce_base_client.BceBaseClient):
4151
4164
  hosteye_type=None, res_group_id=None, enable_ht=None, data_partition_type=None,
4152
4165
  root_partition_type=None, file_systems=None, disable_root_disk_serial=None,
4153
4166
  internal_ips=None, network_purchase_type=None, is_keep_image_login=None,
4154
- reserved_instance=None, is_eip_auto_related_delete=None):
4167
+ reserved_instance=None, is_eip_auto_related_delete=None, enable_delete_protection=None):
4155
4168
  """
4156
4169
  Create a bcc Instance with the specified options.
4157
4170
  You must fill the field of clientToken,which is especially for keeping idempotent.
@@ -4419,6 +4432,10 @@ class BccClient(bce_base_client.BceBaseClient):
4419
4432
  The default value is False.
4420
4433
  :type is_eip_auto_related_delete: boolean
4421
4434
 
4435
+ :param enable_delete_protection:
4436
+ The optional parameter to specify whether to enable delete protection.
4437
+ :type enable_delete_protection: boolean
4438
+
4422
4439
  :return:
4423
4440
  :rtype baidubce.bce_response.BceResponse
4424
4441
  """
@@ -4546,6 +4563,8 @@ class BccClient(bce_base_client.BceBaseClient):
4546
4563
  body['keepImageLogin'] = is_keep_image_login
4547
4564
  if reserved_instance is not None:
4548
4565
  body['reservedInstance'] = reserved_instance
4566
+ if enable_delete_protection is not None:
4567
+ body['enableDeleteProtection'] = enable_delete_protection
4549
4568
  return self._send_request(http_methods.POST, path, json.dumps(body),
4550
4569
  params=params, config=config)
4551
4570
 
@@ -7235,6 +7254,30 @@ class BccClient(bce_base_client.BceBaseClient):
7235
7254
  return self._send_request(http_methods.POST, path, json.dumps(body),
7236
7255
  params=params, config=config)
7237
7256
 
7257
+ def modify_volume_delete_protection(self, volume_ids, enable_delete_protection, client_token=None, config=None):
7258
+ """
7259
+ modify_volume_delete_protection
7260
+
7261
+ :param volume_ids:
7262
+ A list of volume ids.
7263
+ :type volume_ids: list<bcc_model.VolumeIdModel>
7264
+
7265
+ :param enable_delete_protection:
7266
+ enable_delete_protection
7267
+ :type enable_delete_protection: bool
7268
+ """
7269
+ path = b'/volume/modifyDeleteProtection'
7270
+ params = {}
7271
+ if client_token is None:
7272
+ params['clientToken'] = generate_client_token()
7273
+ else:
7274
+ params['clientToken'] = client_token
7275
+ body = {
7276
+ 'volumeIds': volume_ids,
7277
+ 'enableDeleteProtection': enable_delete_protection
7278
+ }
7279
+ return self._send_request(http_methods.POST, path, json.dumps(body), params=params, config=config)
7280
+
7238
7281
  def create_snapshot_share(self, snapshot_id, account_ids, client_token=None, config=None):
7239
7282
  """
7240
7283
  Create a share link for the specified snapshot.
@@ -17,6 +17,7 @@ This module provides a client class for BOS.
17
17
  import io
18
18
  import copy
19
19
  import http.client
20
+ import math
20
21
  import os
21
22
  import json
22
23
  import logging
@@ -45,6 +46,7 @@ from baidubce.http import http_headers
45
46
  from baidubce.http import http_methods
46
47
  from baidubce.services import bos
47
48
  from baidubce.services.bos import bos_handler
49
+ from baidubce.services.bos import common
48
50
  from baidubce.services.bos import storage_class
49
51
  from baidubce.utils import required
50
52
  from baidubce import compat
@@ -122,7 +124,7 @@ class BosClient(BceBaseClient):
122
124
  return response.location_constraint
123
125
 
124
126
  @required(bucket_name=(bytes, str))
125
- def create_bucket(self, bucket_name, config=None):
127
+ def create_bucket(self, bucket_name, tag_list=None, enable_maz=False, config=None):
126
128
  """
127
129
  Create bucket with specific name
128
130
 
@@ -133,7 +135,23 @@ class BosClient(BceBaseClient):
133
135
  :returns:
134
136
  :rtype: baidubce.bce_response.BceResponse
135
137
  """
136
- return self._send_request(http_methods.PUT, bucket_name, config=config)
138
+ headers = {}
139
+ if tag_list is not None:
140
+ headers[http_headers.BOS_TAG_LIST] = tag_list
141
+
142
+ if enable_maz:
143
+ headers[http_headers.CONTENT_TYPE] = http_content_types.JSON
144
+ body = json.dumps({'enableMultiAz': True})
145
+ else:
146
+ body = None
147
+
148
+ return self._send_request(
149
+ http_methods.PUT,
150
+ bucket_name,
151
+ headers=headers,
152
+ body=body,
153
+ config=config
154
+ )
137
155
 
138
156
  @required(bucket_name=(bytes, str))
139
157
  def does_bucket_exist(self, bucket_name, config=None):
@@ -193,7 +211,7 @@ class BosClient(BceBaseClient):
193
211
  :return:
194
212
  **HttpResponse Class**
195
213
  """
196
- self._send_request(http_methods.PUT,
214
+ return self._send_request(http_methods.PUT,
197
215
  bucket_name,
198
216
  body=json.dumps({'accessControlList': acl},
199
217
  default=BosClient._dump_acl_object),
@@ -201,7 +219,7 @@ class BosClient(BceBaseClient):
201
219
  params={b'acl': b''},
202
220
  config=config)
203
221
 
204
- @required(bucket_name=(bytes, str), canned_acl=bytes)
222
+ @required(bucket_name=(bytes, str), canned_acl=(bytes, ))
205
223
  def set_bucket_canned_acl(self, bucket_name, canned_acl, config=None):
206
224
  """
207
225
 
@@ -210,13 +228,13 @@ class BosClient(BceBaseClient):
210
228
  :param config:
211
229
  :return:
212
230
  """
213
- self._send_request(http_methods.PUT,
231
+ return self._send_request(http_methods.PUT,
214
232
  bucket_name,
215
233
  headers={http_headers.BCE_ACL: canned_acl},
216
234
  params={b'acl': b''},
217
235
  config=config)
218
236
 
219
- @required(bucket_name=(bytes, str))
237
+ @required(bucket_name=(bytes, str), storage_class=(bytes, str))
220
238
  def set_bucket_storage_class(self, bucket_name, storage_class, config=None):
221
239
  """
222
240
 
@@ -259,7 +277,7 @@ class BosClient(BceBaseClient):
259
277
  """
260
278
  return self._send_request(http_methods.DELETE, bucket_name, config=config)
261
279
 
262
- # bucket static website
280
+ # bucket static website
263
281
  @required(bucket_name=(bytes, str))
264
282
  def put_bucket_static_website(self, bucket_name, index=None, not_found=None, config=None):
265
283
  """
@@ -383,7 +401,7 @@ class BosClient(BceBaseClient):
383
401
 
384
402
  # Bucket Copyright Protection
385
403
 
386
- @required(bucket_name=(bytes, str), resource=(list))
404
+ @required(bucket_name=(bytes, str), resource=(list, ))
387
405
  def put_bucket_copyright_protection(self, bucket_name, resource, config=None):
388
406
  """
389
407
  Open image copyright protection and set resource
@@ -439,7 +457,7 @@ class BosClient(BceBaseClient):
439
457
  config=config)
440
458
 
441
459
  # bucket replication
442
- @required(bucket_name=(bytes, str), replication=(dict))
460
+ @required(bucket_name=(bytes, str), replication=(dict, ))
443
461
  def put_bucket_replication(self, bucket_name, replication, config=None):
444
462
  """
445
463
  Open cross-region replication
@@ -549,7 +567,7 @@ class BosClient(BceBaseClient):
549
567
  params={b'replication': b'', b'list': b''},
550
568
  config=config)
551
569
 
552
- @required(bucket_name=(bytes, str), inventory=(dict))
570
+ @required(bucket_name=(bytes, str), inventory=(dict, ))
553
571
  def put_bucket_inventory(self, bucket_name, inventory, config=None):
554
572
  """
555
573
  set bucket inventoru
@@ -709,13 +727,17 @@ class BosClient(BceBaseClient):
709
727
  """
710
728
  key = compat.convert_to_string(key)
711
729
  key = (key or "").strip('/')
730
+ bos_handler.validate_bucket_name(bucket_name)
731
+ bos_handler.validate_object_key(key)
712
732
  key = compat.convert_to_bytes(key)
713
- if len(key) == 0 or key == b'v1':
733
+ if key == b'v1':
714
734
  raise ValueError('generate url the key param error!')
715
735
 
716
736
  config = self._merge_config(config, bucket_name)
717
- headers = headers or {}
718
- params = params or {}
737
+ headers = dict(headers) if headers else {}
738
+ params = dict(params) if params else {}
739
+ params.pop(http_headers.AUTHORIZATION.lower(), None)
740
+ params.pop(http_headers.AUTHORIZATION, None)
719
741
 
720
742
  # specified protocol in endpoint > protocal > default protocol in config
721
743
  if protocol is not None:
@@ -737,6 +759,9 @@ class BosClient(BceBaseClient):
737
759
  full_host += b':' + compat.convert_to_bytes(endpoint_port)
738
760
  headers[http_headers.HOST] = full_host
739
761
 
762
+ if config.request_payer is True:
763
+ params[http_headers.BOS_REQUEST_PAYER] = common.REQUEST_PAYER_REQUESTER
764
+
740
765
  path = self._get_path(config, bucket_name, key)
741
766
  if httpmethod != http_methods.GET and httpmethod != http_methods.HEAD:
742
767
  headers_to_sign = set([b'host'])
@@ -812,7 +837,7 @@ class BosClient(BceBaseClient):
812
837
  params={b'lifecycle': b''},
813
838
  config=config)
814
839
 
815
- @required(bucket_name=(bytes, str), cors_configuration=list)
840
+ @required(bucket_name=(bytes, str), cors_configuration=(list, ))
816
841
  def put_bucket_cors(self,
817
842
  bucket_name,
818
843
  cors_configuration,
@@ -863,7 +888,7 @@ class BosClient(BceBaseClient):
863
888
  params={b'cors': b''},
864
889
  config=config)
865
890
 
866
- @required(bucket_name=(bytes, str))
891
+ @required(bucket_name=(bytes, str))
867
892
  def list_objects(self, bucket_name,
868
893
  max_keys=1000, prefix=None, marker=None, delimiter=None,
869
894
  config=None):
@@ -1161,8 +1186,8 @@ class BosClient(BceBaseClient):
1161
1186
 
1162
1187
  @required(bucket_name=(bytes, str),
1163
1188
  key=(bytes, str),
1164
- data=object,
1165
- content_length=compat.integer_types)
1189
+ data=(object, ),
1190
+ content_length=(compat.integer_types, ))
1166
1191
  def append_object(self, bucket_name, key, data,
1167
1192
  content_length,
1168
1193
  content_md5=None,
@@ -1316,8 +1341,8 @@ class BosClient(BceBaseClient):
1316
1341
 
1317
1342
  @required(bucket_name=(bytes, str),
1318
1343
  key=(bytes, str),
1319
- data=object,
1320
- content_length=compat.integer_types)
1344
+ data=(object, ),
1345
+ content_length=(compat.integer_types, ))
1321
1346
  def put_object(self, bucket_name, key, data,
1322
1347
  content_length,
1323
1348
  content_md5=None,
@@ -1381,7 +1406,7 @@ class BosClient(BceBaseClient):
1381
1406
  content_crc32 = compat.convert_to_bytes(content_crc32)
1382
1407
  if content_crc32c:
1383
1408
  content_crc32c = compat.convert_to_bytes(content_crc32c)
1384
- if content_crc32c_flag:
1409
+ if content_crc32c_flag is not None:
1385
1410
  content_crc32c_flag = compat.convert_to_bytes(content_crc32c_flag)
1386
1411
  if content_crc64ecma:
1387
1412
  content_crc64ecma = compat.convert_to_bytes(content_crc64ecma)
@@ -1605,6 +1630,7 @@ class BosClient(BceBaseClient):
1605
1630
  """
1606
1631
  source_key = compat.convert_to_bytes(source_key)
1607
1632
  target_key = compat.convert_to_bytes(target_key)
1633
+ bos_handler.validate_object_key(source_key)
1608
1634
  headers = self._prepare_object_headers(
1609
1635
  content_type=content_type,
1610
1636
  user_metadata=user_metadata,
@@ -1662,7 +1688,7 @@ class BosClient(BceBaseClient):
1662
1688
  return self._send_request(http_methods.DELETE, bucket_name, key,
1663
1689
  params=query_params, config=config)
1664
1690
 
1665
- @required(bucket_name=(bytes, str), key_list=list)
1691
+ @required(bucket_name=(bytes, str), key_list=(list, ))
1666
1692
  def delete_multiple_objects(self, bucket_name, key_list, config=None):
1667
1693
  """
1668
1694
  Delete Multiple Objects
@@ -1701,11 +1727,14 @@ class BosClient(BceBaseClient):
1701
1727
  :return:
1702
1728
  **HttpResponse Class**
1703
1729
  """
1730
+ body = {'targetBucket': compat.convert_to_string(target_bucket)}
1731
+ if target_prefix is not None:
1732
+ body['targetPrefix'] = compat.convert_to_string(target_prefix)
1733
+
1704
1734
  return self._send_request(http_methods.PUT,
1705
1735
  source_bucket,
1706
1736
  params={b'logging': b''},
1707
- body=json.dumps({'targetBucket': target_bucket,
1708
- 'targetPrefix': target_prefix}),
1737
+ body=json.dumps(body),
1709
1738
  config=config)
1710
1739
 
1711
1740
  @required(bucket_name=(bytes, str))
@@ -1784,9 +1813,9 @@ class BosClient(BceBaseClient):
1784
1813
  @required(bucket_name=(bytes, str),
1785
1814
  key=(bytes, str),
1786
1815
  upload_id=(bytes, str),
1787
- part_number=int,
1788
- part_size=compat.integer_types,
1789
- part_fp=object)
1816
+ part_number=(int, ),
1817
+ part_size=(compat.integer_types, ),
1818
+ part_fp=(object, ))
1790
1819
  def upload_part(self, bucket_name, key, upload_id, part_number, part_size, part_fp, part_md5=None,
1791
1820
  part_crc32=None, part_sha256=None, part_crc32c=None, part_crc32c_flag=None,
1792
1821
  part_crc64ecma=None, progress_callback=None, traffic_limit=None, config=None):
@@ -1871,9 +1900,7 @@ class BosClient(BceBaseClient):
1871
1900
 
1872
1901
  if progress_callback:
1873
1902
  part_fp = utils.make_progress_adapter(part_fp, progress_callback, part_size)
1874
-
1875
- if traffic_limit is not None:
1876
- headers[http_headers.BOS_TRAFFIC_LIMIT] = traffic_limit
1903
+
1877
1904
  return self._send_request(
1878
1905
  http_methods.PUT,
1879
1906
  bucket_name,
@@ -1888,9 +1915,9 @@ class BosClient(BceBaseClient):
1888
1915
  target_bucket_name=(bytes, str),
1889
1916
  target_key=(bytes, str),
1890
1917
  upload_id=(bytes, str),
1891
- part_number=int,
1892
- part_size=compat.integer_types,
1893
- offset=compat.integer_types)
1918
+ part_number=(int, ),
1919
+ part_size=(compat.integer_types, ),
1920
+ offset=(compat.integer_types, ))
1894
1921
  def upload_part_copy(self,
1895
1922
  source_bucket_name, source_key,
1896
1923
  target_bucket_name, target_key,
@@ -1923,6 +1950,7 @@ class BosClient(BceBaseClient):
1923
1950
  """
1924
1951
  source_key = compat.convert_to_bytes(source_key)
1925
1952
  target_key = compat.convert_to_bytes(target_key)
1953
+ bos_handler.validate_object_key(source_key)
1926
1954
  headers = self._prepare_object_headers(
1927
1955
  content_type=content_type,
1928
1956
  user_metadata=user_metadata,
@@ -1946,10 +1974,10 @@ class BosClient(BceBaseClient):
1946
1974
  @required(bucket_name=(bytes, str),
1947
1975
  key=(bytes, str),
1948
1976
  upload_id=(bytes, str),
1949
- part_number=int,
1950
- part_size=compat.integer_types,
1977
+ part_number=(int, ),
1978
+ part_size=(compat.integer_types, ),
1951
1979
  file_name=(bytes, str),
1952
- offset=compat.integer_types)
1980
+ offset=(compat.integer_types, ))
1953
1981
  def upload_part_from_file(self, bucket_name, key, upload_id,
1954
1982
  part_number, part_size, file_name, offset, part_md5=None,
1955
1983
  part_crc32=None, part_sha256=None, part_crc32c=None,
@@ -1984,7 +2012,7 @@ class BosClient(BceBaseClient):
1984
2012
  @required(bucket_name=(bytes, str),
1985
2013
  key=(bytes, str),
1986
2014
  upload_id=(bytes, str),
1987
- part_list=list)
2015
+ part_list=(list, ))
1988
2016
  def complete_multipart_upload(self, bucket_name, key,
1989
2017
  upload_id, part_list,
1990
2018
  user_headers=None,
@@ -2032,7 +2060,8 @@ class BosClient(BceBaseClient):
2032
2060
  key,
2033
2061
  body=json.dumps({'parts': part_list}),
2034
2062
  headers=headers,
2035
- params={b'uploadId': upload_id})
2063
+ params={b'uploadId': upload_id},
2064
+ config=config)
2036
2065
 
2037
2066
  @required(bucket_name=(bytes, str), key=(bytes, str), upload_id=(bytes, str))
2038
2067
  def abort_multipart_upload(self, bucket_name, key, upload_id, config=None):
@@ -2052,7 +2081,8 @@ class BosClient(BceBaseClient):
2052
2081
  """
2053
2082
  key = compat.convert_to_bytes(key)
2054
2083
  return self._send_request(http_methods.DELETE, bucket_name, key,
2055
- params={b'uploadId': upload_id})
2084
+ params={b'uploadId': upload_id},
2085
+ config=config)
2056
2086
 
2057
2087
  @required(bucket_name=(bytes, str), key=(bytes, str), upload_id=(bytes, str))
2058
2088
  def list_parts(self, bucket_name, key, upload_id,
@@ -2198,7 +2228,7 @@ class BosClient(BceBaseClient):
2198
2228
  raise e
2199
2229
 
2200
2230
  @required(bucket_name=(bytes, str), key=(bytes, str), file_name=(bytes, str))
2201
- def put_super_object_from_file(self, bucket_name, key, file_name, chunk_size=5,
2231
+ def put_super_object_from_file(self, bucket_name, key, file_name, chunk_size=None,
2202
2232
  thread_num=None,
2203
2233
  uploadTaskHandle=None,
2204
2234
  content_type=None,
@@ -2215,15 +2245,26 @@ class BosClient(BceBaseClient):
2215
2245
  """
2216
2246
  Multipart Upload file to bos
2217
2247
 
2218
- param chunk_size: part size , default part size is 5MB
2248
+ param chunk_size: part size in MB, default will be auto-calculated based on file size.
2249
+ Minimum is 5MB, maximum is 5120MB (5GB). Maximum 10000 parts allowed.
2250
+ Maximum file size supported is 48.8TB.
2219
2251
  """
2220
- # check params
2221
- if chunk_size > 5 * 1024 or chunk_size <= 0:
2222
- raise BceClientError("chunk size is valid, it should be more than 0 and not nore than 5120!")
2223
2252
  left_size = os.path.getsize(file_name)
2224
2253
  # if file size more than 48.8TB, reject
2225
2254
  if left_size > 50000 * 1024 * 1024 * 1024:
2226
2255
  raise BceClientError("File size must not be more than 48.8TB!")
2256
+
2257
+ if chunk_size is None:
2258
+ # auto-calculate chunk_size based on file size
2259
+ # minimum chunk_size is 5MB, maximum parts is 10000
2260
+ chunk_size = 5
2261
+ min_chunk_size_mb = math.ceil(left_size / (10000 * 1024 * 1024))
2262
+ if min_chunk_size_mb > chunk_size:
2263
+ chunk_size = min_chunk_size_mb
2264
+
2265
+ # check params
2266
+ if chunk_size > 5 * 1024 or chunk_size <= 0:
2267
+ raise BceClientError("chunk size is invalid, it should be more than 0 and not more than 5120!")
2227
2268
  if thread_num is None or thread_num <= 1:
2228
2269
  thread_num = multiprocessing.cpu_count()
2229
2270
  part_size = chunk_size * 1024 * 1024
@@ -2303,7 +2344,7 @@ class BosClient(BceBaseClient):
2303
2344
  **HttpResponse Class**
2304
2345
  """
2305
2346
  key = compat.convert_to_bytes(key)
2306
- self._send_request(http_methods.PUT,
2347
+ return self._send_request(http_methods.PUT,
2307
2348
  bucket_name,
2308
2349
  key,
2309
2350
  body=json.dumps({'accessControlList': acl},
@@ -2360,7 +2401,7 @@ class BosClient(BceBaseClient):
2360
2401
  elif num_args >= 2:
2361
2402
  raise ValueError("cann't get more than one object canned acl arguments!")
2362
2403
 
2363
- self._send_request(http_methods.PUT,
2404
+ return self._send_request(http_methods.PUT,
2364
2405
  bucket_name,
2365
2406
  key,
2366
2407
  headers=headers,
@@ -2450,7 +2491,7 @@ class BosClient(BceBaseClient):
2450
2491
  params={b'fetch': b''},
2451
2492
  config=config)
2452
2493
 
2453
- @required(bucket_name=(bytes, str), target_key=(bytes, str), symlink=(bytes, str), forbid_overwrite=(bool))
2494
+ @required(bucket_name=(bytes, str), target_key=(bytes, str), symlink=(bytes, str), forbid_overwrite=(bool, ))
2454
2495
  def put_object_symlink(self, bucket_name, target_key, symlink, forbid_overwrite=None,
2455
2496
  user_metadata=None, storage_class=None, target_bucket=None, content_type=None, config=None):
2456
2497
  """
@@ -2513,7 +2554,7 @@ class BosClient(BceBaseClient):
2513
2554
  params={b'symlink': b''},
2514
2555
  config=config)
2515
2556
 
2516
- @required(bucket_name=(bytes, str), key=(bytes, str), select_object_args=(dict, ))
2557
+ @required(bucket_name=(bytes, str), key=(bytes, str), select_object_args=(dict))
2517
2558
  def select_object(self, bucket_name, key, select_object_args, headers=None, config=None):
2518
2559
  """
2519
2560
 
@@ -2561,7 +2602,7 @@ class BosClient(BceBaseClient):
2561
2602
  return self._send_request(
2562
2603
  http_methods.GET, params={b'userQuota': b''}, config=config,)
2563
2604
 
2564
- @required(max_bucket_count=(int), max_capacity_mega_bytes=(int))
2605
+ @required(max_bucket_count=(int), max_capacity_mega_bytes=(int, ))
2565
2606
  def put_user_quota(self, max_bucket_count, max_capacity_mega_bytes, config=None):
2566
2607
  """
2567
2608
  put user quota
@@ -2626,6 +2667,7 @@ class BosClient(BceBaseClient):
2626
2667
  http_methods.PUT, bucket_name=bucket_name,
2627
2668
  body=json.dumps({'notifications': notifications}),
2628
2669
  params={b'notification': b''}, config=config,)
2670
+
2629
2671
  @required(bucket_name=(bytes, str))
2630
2672
  def delete_notification(self, bucket_name, config=None):
2631
2673
  """
@@ -2693,6 +2735,7 @@ class BosClient(BceBaseClient):
2693
2735
  config=config,
2694
2736
  )
2695
2737
 
2738
+ @required(bucket_name=(bytes, str), key=(bytes, str), obj_tag_args=(dict, ))
2696
2739
  def put_object_tagging(self, bucket_name, key, obj_tag_args, config=None):
2697
2740
  """
2698
2741
  put object tagging
@@ -2741,6 +2784,28 @@ class BosClient(BceBaseClient):
2741
2784
  params={b'tagging': b''},
2742
2785
  config=config,)
2743
2786
 
2787
+ @required(bucket_name=(bytes, str), key=(bytes, str))
2788
+ def delete_object_tagging(self, bucket_name, key, config=None):
2789
+ """
2790
+ delete object tagging
2791
+
2792
+ :type bucket_name: string
2793
+ :param bucket_name: bucket name
2794
+
2795
+ :type key: string
2796
+ :param key: object name
2797
+
2798
+ :return:
2799
+ """
2800
+ key = compat.convert_to_bytes(key)
2801
+ return self._send_request(
2802
+ http_methods.DELETE,
2803
+ bucket_name=bucket_name,
2804
+ key=key,
2805
+ params={b'tagging': b''},
2806
+ config=config)
2807
+
2808
+ @required(bucket_name=(bytes, str), key=(bytes, str))
2744
2809
  def get_object_tagging(self, bucket_name, key, config=None):
2745
2810
  """
2746
2811
  put object tagging
@@ -2760,6 +2825,7 @@ class BosClient(BceBaseClient):
2760
2825
  params={b'tagging': b''},
2761
2826
  config=config,)
2762
2827
 
2828
+ @required(bucket_name=(bytes, str), status=(bytes, str))
2763
2829
  def put_bucket_versioning(self, bucket_name, status, config=None):
2764
2830
  """
2765
2831
  put bucket versioning
@@ -2780,6 +2846,7 @@ class BosClient(BceBaseClient):
2780
2846
  headers={http_headers.CONTENT_TYPE: http_content_types.JSON},
2781
2847
  config=config,)
2782
2848
 
2849
+ @required(bucket_name=(bytes, str))
2783
2850
  def get_bucket_versioning(self, bucket_name, config=None):
2784
2851
  """
2785
2852
  get bucket versioning
@@ -2795,7 +2862,7 @@ class BosClient(BceBaseClient):
2795
2862
  params={b'versioning': b''},
2796
2863
  config=config,)
2797
2864
 
2798
- @required(bucket_name=(bytes, str))
2865
+ @required(bucket_name=(bytes, str))
2799
2866
  def list_objects_versions(self, bucket_name,
2800
2867
  max_keys=1000, prefix=None, marker=None, version_marker=None,
2801
2868
  delimiter=None, config=None):
@@ -2834,7 +2901,7 @@ class BosClient(BceBaseClient):
2834
2901
 
2835
2902
  return self._send_request(http_methods.GET, bucket_name, params=params, config=config)
2836
2903
 
2837
- @required(bucket_name=(bytes, str), cors_configuration=list)
2904
+ @required(bucket_name=(bytes, str), retention_days=(int, ))
2838
2905
  def init_bucket_object_lock(self,
2839
2906
  bucket_name,
2840
2907
  retention_days,
@@ -2885,8 +2952,8 @@ class BosClient(BceBaseClient):
2885
2952
  params={b'objectlock': b''},
2886
2953
  config=config)
2887
2954
 
2888
- @required(bucket_name=(bytes, str), cors_configuration=list)
2889
- def complete_bucket_object_lock(self,
2955
+ @required(bucket_name=(bytes, str))
2956
+ def complete_bucket_object_lock(self,
2890
2957
  bucket_name,
2891
2958
  config=None):
2892
2959
  """
@@ -2904,7 +2971,7 @@ class BosClient(BceBaseClient):
2904
2971
  params={b'completeobjectlock': b''},
2905
2972
  config=config)
2906
2973
 
2907
- @required(bucket_name=(bytes, str), cors_configuration=list)
2974
+ @required(bucket_name=(bytes, str), extend_retent_days=(int, ))
2908
2975
  def extend_bucket_object_lock(self,
2909
2976
  bucket_name,
2910
2977
  extend_retent_days,
@@ -2925,7 +2992,7 @@ class BosClient(BceBaseClient):
2925
2992
  body=json.dumps({'extendRetentionDays': extend_retent_days}),
2926
2993
  config=config)
2927
2994
 
2928
- @required(bucket_name=(bytes, str), cors_configuration=list)
2995
+ @required(bucket_name=(bytes, str))
2929
2996
  def get_bucket_quota(self,
2930
2997
  bucket_name,
2931
2998
  config=None):
@@ -2940,8 +3007,8 @@ class BosClient(BceBaseClient):
2940
3007
  bucket_name,
2941
3008
  params={b'quota': b''},
2942
3009
  config=config)
2943
-
2944
- @required(bucket_name=(bytes, str), cors_configuration=list)
3010
+
3011
+ @required(bucket_name=(bytes, str), quota_conf=(dict, ))
2945
3012
  def put_bucket_quota(self,
2946
3013
  bucket_name,
2947
3014
  quota_conf,
@@ -2962,7 +3029,7 @@ class BosClient(BceBaseClient):
2962
3029
  params={b'quota': b''},
2963
3030
  config=config)
2964
3031
 
2965
- @required(bucket_name=(bytes, str), cors_configuration=list)
3032
+ @required(bucket_name=(bytes, str))
2966
3033
  def delete_bucket_quota(self,
2967
3034
  bucket_name,
2968
3035
  config=None):
@@ -2978,7 +3045,7 @@ class BosClient(BceBaseClient):
2978
3045
  params={b'quota': b''},
2979
3046
  config=config)
2980
3047
 
2981
- @required(bucket_name=(bytes, str), cors_configuration=list)
3048
+ @required(bucket_name=(bytes, str))
2982
3049
  def get_bucket_tagging(self,
2983
3050
  bucket_name,
2984
3051
  config=None):
@@ -2994,7 +3061,7 @@ class BosClient(BceBaseClient):
2994
3061
  params={b'tagging': b''},
2995
3062
  config=config)
2996
3063
 
2997
- @required(bucket_name=(bytes, str), cors_configuration=list)
3064
+ @required(bucket_name=(bytes, str), tag_conf=(dict, ))
2998
3065
  def put_bucket_tagging(self,
2999
3066
  bucket_name,
3000
3067
  tag_conf,
@@ -3015,7 +3082,7 @@ class BosClient(BceBaseClient):
3015
3082
  params={b'tagging': b''},
3016
3083
  config=config)
3017
3084
 
3018
- @required(bucket_name=(bytes, str), cors_configuration=list)
3085
+ @required(bucket_name=(bytes, str))
3019
3086
  def delete_bucket_tagging(self,
3020
3087
  bucket_name,
3021
3088
  config=None):
@@ -3198,7 +3265,7 @@ class BosClient(BceBaseClient):
3198
3265
  if use_backup_endpoint:
3199
3266
  host = config.backup_endpoint
3200
3267
  endpoint_protocol, host_name, endpoint_port = \
3201
- utils.parse_host_port(config.endpoint, config.protocol)
3268
+ utils.parse_host_port(host, config.protocol)
3202
3269
  if config.cname_enabled or utils.is_cname_like_host(host_name) or utils.is_custom_host(host_name, bucket_name):
3203
3270
  return utils.append_uri(bos.URL_PREFIX, key)
3204
3271
 
@@ -3294,6 +3361,9 @@ class BosClient(BceBaseClient):
3294
3361
  self, http_method, bucket_name=None, key=None,
3295
3362
  body=None, headers=None, params=None,
3296
3363
  config=None, body_parser=None):
3364
+ bos_handler.validate_bucket_name(bucket_name)
3365
+ if key is not None:
3366
+ bos_handler.validate_object_key(key)
3297
3367
  config = self._merge_config(config, bucket_name)
3298
3368
 
3299
3369
  path = BosClient._get_path(config, bucket_name, key)
@@ -3304,8 +3374,19 @@ class BosClient(BceBaseClient):
3304
3374
  headers = headers or {}
3305
3375
  headers[http_headers.STS_SECURITY_TOKEN] = config.security_token
3306
3376
 
3377
+ if config.request_payer is True:
3378
+ headers = headers or {}
3379
+ headers[http_headers.BOS_REQUEST_PAYER] = common.REQUEST_PAYER_REQUESTER
3380
+
3307
3381
  last_exception = None
3308
3382
  e = None
3383
+ # record the initial position of fp body before any request attempt,
3384
+ # so retries (backup endpoint or BOS error) can seek back to the correct
3385
+ # starting offset instead of blindly seeking to 0 (which would break
3386
+ # upload_part_from_file where the fp starts at a non-zero offset).
3387
+ body_initial_offset = None
3388
+ if hasattr(body, 'tell') and hasattr(body, 'seek'):
3389
+ body_initial_offset = body.tell()
3309
3390
  try:
3310
3391
  return bce_http_client.send_request(
3311
3392
  config, bce_v1_signer.sign, [handler.parse_error, body_parser],
@@ -3314,10 +3395,14 @@ class BosClient(BceBaseClient):
3314
3395
  last_exception = ex
3315
3396
  e = ex
3316
3397
 
3398
+ original_path = path
3317
3399
  # retry backup endpoint
3318
- if e is not None and config.backup_endpoint is not None and BosClient._need_retry_backup_endpoint(e):
3400
+ if e is not None and config.backup_endpoint is not None \
3401
+ and BosClient._need_retry_backup_endpoint(e.last_error):
3319
3402
  try:
3320
- _logger.debug(b'Retry for backup endpoint error code: %d.', e.status_code)
3403
+ if body_initial_offset is not None:
3404
+ body.seek(body_initial_offset)
3405
+ _logger.debug(b'Retry for backup endpoint error code: %s.', e.status_code)
3321
3406
  path = BosClient._get_path(config, bucket_name, key, True)
3322
3407
  return bce_http_client.send_request(
3323
3408
  config, bce_v1_signer.sign, [handler.parse_error, body_parser],
@@ -3329,10 +3414,12 @@ class BosClient(BceBaseClient):
3329
3414
  # retry for bos error
3330
3415
  if e is not None and BosClient._need_retry_for_bos(config, e.last_error):
3331
3416
  try:
3332
- _logger.debug(b'Retry for BOS error code: %d.', e.status_code)
3417
+ if body_initial_offset is not None:
3418
+ body.seek(body_initial_offset)
3419
+ _logger.debug(b'Retry for BOS error code: %s.', e.status_code)
3333
3420
  return bce_http_client.send_request(
3334
3421
  config, bce_v1_signer.sign, [handler.parse_error, body_parser],
3335
- http_method, path, body, headers, params)
3422
+ http_method, original_path, body, headers, params)
3336
3423
  except BceHttpClientError as ex:
3337
3424
  last_exception = ex
3338
3425
  e = ex
@@ -3405,7 +3492,6 @@ class SelectResponse(object):
3405
3492
  prelude = f.read(8)
3406
3493
  if not prelude:
3407
3494
  raise StopIteration
3408
- return
3409
3495
  total_len = struct.unpack('>I', prelude[0:4])[0]
3410
3496
  headers_len = struct.unpack('>I', prelude[4:8])[0]
3411
3497
  headers = f.read(headers_len)
@@ -3430,7 +3516,6 @@ class SelectResponse(object):
3430
3516
  if headers_map["error-code"] != "success":
3431
3517
  raise BceServerError(headers_map['error-message'], code=headers_map['error-code'],
3432
3518
  request_id=self.response.metadata.bce_request_id)
3433
- return
3434
3519
  msg.set_end_message(headers_map, crc)
3435
3520
  self.finish = True
3436
3521
  yield msg
@@ -15,28 +15,65 @@ This module provides general http handler functions for processing http response
15
15
  """
16
16
 
17
17
  import json
18
+ import re
19
+ from baidubce import compat
18
20
  from baidubce import utils
19
21
  from baidubce.exception import BceServerError
20
22
  from baidubce.http import handler
21
23
  from builtins import str
22
24
  from builtins import bytes
23
25
 
26
+ # Bucket naming rules per BOS official specification:
27
+ # - Allowed characters: lowercase letters, digits, hyphens
28
+ # - Length: 3 ~ 63
29
+ # - Must start and end with a lowercase letter or digit
30
+ _BUCKET_NAME_REGEX = re.compile(r'^[a-z0-9][a-z0-9\-]{1,61}[a-z0-9]$')
31
+
32
+
33
+ def validate_bucket_name(bucket_name):
34
+ """
35
+ Validate bucket name against BOS official naming rules.
36
+ Raises ValueError for any violation, blocking the request before URL assembly or signing.
37
+
38
+ Rules:
39
+ - Allowed characters: [a-z0-9-]
40
+ - Length: 3 ~ 63
41
+ - Must start and end with a lowercase letter or digit
42
+ """
43
+ if bucket_name is None:
44
+ return
45
+ if isinstance(bucket_name, bytes):
46
+ try:
47
+ bucket_name = bucket_name.decode('utf-8')
48
+ except UnicodeDecodeError as e:
49
+ raise ValueError("Invalid bucket name: not valid UTF-8: %s" % e)
50
+ if not _BUCKET_NAME_REGEX.match(bucket_name):
51
+ raise ValueError(
52
+ "Invalid bucket name %r: must match ^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$ "
53
+ "(lowercase letters, digits and hyphens only, length 3-63, "
54
+ "start and end with letter or digit)" % bucket_name
55
+ )
56
+
24
57
  def parse_copy_object_response(http_response, response):
25
58
  """
26
59
  response parser for copy object
27
60
  """
28
- TRANSFER_ENCODING = b'transfer-encoding'
29
- headers_list = {k: v for k, v in http_response.getheaders()}
30
- if headers_list.get(TRANSFER_ENCODING, b'not exist') == b'chunked':
61
+ TRANSFER_ENCODING = compat.convert_to_string('transfer-encoding')
62
+ CHUNKED = compat.convert_to_string('chunked')
63
+ headers_list = {compat.convert_to_string(k).lower(): compat.convert_to_string(v)
64
+ for k, v in http_response.getheaders()}
65
+ if headers_list.get(TRANSFER_ENCODING, '') == CHUNKED:
31
66
  body = http_response.read()
32
67
  if body:
33
- d = json.loads(body)
34
- if b'code' in d:
68
+ # json.loads always returns str keys on both Py2 (unicode) and Py3 (str).
69
+ body_str = compat.convert_to_string(body)
70
+ d = json.loads(body_str)
71
+ if 'code' in d:
35
72
  http_response.close()
36
- raise BceServerError(d[b'message'], code=d[b'code'], request_id=d[b'requestId'])
73
+ raise BceServerError(d['message'], code=d['code'], request_id=d['requestId'])
37
74
  else:
38
75
  response.__dict__.update(
39
- json.loads(body, object_hook=utils.dict_to_python_object).__dict__)
76
+ json.loads(body_str, object_hook=utils.dict_to_python_object).__dict__)
40
77
  http_response.close()
41
78
  else:
42
79
  e = BceServerError(http_response.reason, request_id=response.metadata.bce_request_id)
@@ -45,3 +82,33 @@ def parse_copy_object_response(http_response, response):
45
82
  return True
46
83
  else:
47
84
  return handler.parse_json(http_response, response)
85
+
86
+ def validate_object_key(key):
87
+ """
88
+ Validate object key against path traversal and malformed URI attacks.
89
+ Rules align with BOS server-side behavior:
90
+ - empty key is rejected
91
+ - '..' segments are rejected (400 Bad Request)
92
+ - '.' segments are rejected (400 InvalidURI)
93
+ - Leading '//' double-slash is normalized away by strip('/') before this call
94
+ """
95
+ if isinstance(key, bytes):
96
+ try:
97
+ key = key.decode('utf-8')
98
+ except UnicodeDecodeError as e:
99
+ raise ValueError("Invalid object key: key is not valid UTF-8: %s" % e)
100
+ if not key:
101
+ raise ValueError("Invalid object key: key must not be empty")
102
+
103
+ if key == '/' or key == 'v1' or key == 'v1/' or key == 'V1' or key == 'V1/':
104
+ raise ValueError("Invalid object key: key must not be '/' or 'v1' or 'v1/' or 'V1' or 'V1/'")
105
+
106
+ for segment in key.split('/'):
107
+ if segment == '..':
108
+ raise ValueError(
109
+ "Invalid object key: path traversal with '..' is not allowed: %s" % key
110
+ )
111
+ if segment == '.':
112
+ raise ValueError(
113
+ "Invalid object key: '.' path segment is not allowed: %s" % key
114
+ )
@@ -6,3 +6,5 @@ This module defines string constants for BOS
6
6
  ENABLED = "enabled"
7
7
  SUSPENDED = "suspended"
8
8
  DISABLED = "disabled"
9
+
10
+ REQUEST_PAYER_REQUESTER = b"requester"
@@ -17,4 +17,7 @@ The type of storage to use for the object. Defaults to 'STANDARD'
17
17
  STANDARD = b"STANDARD"
18
18
  STANDARD_IA = b"STANDARD_IA"
19
19
  COLD = b"COLD"
20
- ARCHIVE= b"ARCHIVE"
20
+ ARCHIVE = b"ARCHIVE"
21
+ MAZ_STANDARD = b"MAZ_STANDARD"
22
+ MAZ_STANDARD_IA = b"MAZ_STANDARD_IA"
23
+ MAZ_COLD = b"MAZ_COLD"
@@ -86,16 +86,14 @@ class EtClient(bce_base_client.BceBaseClient):
86
86
  http_method, path, body, headers, params)
87
87
 
88
88
  def create_et_dcphy(self, name, isp, intf_type, ap_type, ap_addr, user_name, user_phone, user_email,
89
- user_idc, client_token=None, description=None, billing=None, tags=None, config=None):
89
+ user_idc, client_token=None, description=None, billing=None, tags=None,
90
+ link_delay=None, config=None):
90
91
  """
91
92
  Create new ET
92
93
 
93
94
  :param name: the name of ET
94
95
  :type name: string
95
96
 
96
- :param description: description of ET
97
- :type description: string
98
-
99
97
  :param isp: the type of isp
100
98
  :type isp: string
101
99
 
@@ -120,12 +118,18 @@ class EtClient(bce_base_client.BceBaseClient):
120
118
  :param user_idc: Idc of user
121
119
  :type user_idc: string
122
120
 
121
+ :param description: description of ET
122
+ :type description: string
123
+
123
124
  :param billing: billing information, currently only supports prepaid
124
125
  :type billing: dict
125
126
 
126
127
  :param tags: list of tag key-value pairs to be created
127
128
  :type tags: list<dict>
128
129
 
130
+ :param link_delay: port link down delay time in milliseconds
131
+ :type link_delay: int
132
+
129
133
  :param client_token:
130
134
  If the clientToken is not specified by the user, a random String
131
135
  generated by default algorithm will be used.
@@ -164,16 +168,26 @@ class EtClient(bce_base_client.BceBaseClient):
164
168
  if tags is not None:
165
169
  body['tags'] = tags
166
170
 
171
+ if link_delay is not None:
172
+ body['linkDelay'] = link_delay
173
+
167
174
  return self._send_request(http_methods.POST, path, body=json.dumps(body), params=params, config=config)
168
175
 
169
176
  def update_et_dcphy(self, et_id, name=None, description=None, user_name=None,
170
- user_phone=None, user_email=None, client_token=None, config=None):
177
+ user_phone=None, user_email=None, link_delay=None,
178
+ client_token=None, config=None):
171
179
  """
172
180
  Update existed Et
173
181
 
174
182
  :param et_id: ET ID
175
183
  :type et_id: string
176
184
 
185
+ :param name: the name of ET
186
+ :type name: string
187
+
188
+ :param description: description of ET
189
+ :type description: string
190
+
177
191
  :param user_name: the name of user
178
192
  :type user_name: string
179
193
 
@@ -183,11 +197,8 @@ class EtClient(bce_base_client.BceBaseClient):
183
197
  :param user_email: email of user
184
198
  :type user_email: string
185
199
 
186
- :param user_idc: Idc of user
187
- :type user_idc: string
188
-
189
- :param description: description of ET
190
- :type description: string
200
+ :param link_delay: port link down delay time in milliseconds
201
+ :type link_delay: int
191
202
 
192
203
  :param client_token:
193
204
  If the clientToken is not specified by the user, a random String
@@ -199,23 +210,27 @@ class EtClient(bce_base_client.BceBaseClient):
199
210
  """
200
211
  path = utils.append_uri(self.prefix, self.et, et_id)
201
212
  params = {}
213
+ if client_token is None:
214
+ params[b'clientToken'] = generate_client_token()
215
+ else:
216
+ params[b'clientToken'] = client_token
217
+
218
+ body = {}
202
219
  if name is not None:
203
- params[b'name'] = name
220
+ body['name'] = name
204
221
  if description is not None:
205
- params[b'description'] = description
222
+ body['description'] = description
206
223
  if user_name is not None:
207
- params[b'userName'] = user_name
224
+ body['userName'] = user_name
208
225
  if user_phone is not None:
209
- params[b'userPhone'] = user_phone
226
+ body['userPhone'] = user_phone
210
227
  if user_email is not None:
211
- params[b'userEmail'] = user_email
212
-
213
- if client_token is None:
214
- params[b'clientToken'] = generate_client_token()
215
- else:
216
- params[b'clientToken'] = client_token
228
+ body['userEmail'] = user_email
229
+ if link_delay is not None:
230
+ body['linkDelay'] = link_delay
217
231
 
218
- return self._send_request(http_methods.PUT, path, params=params, config=config)
232
+ return self._send_request(http_methods.PUT, path, body=json.dumps(body),
233
+ params=params, config=config)
219
234
 
220
235
  def list_et_dcphy(self, status=None, marker=None, max_keys=1000, config=None):
221
236
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bce-python-sdk
3
- Version: 0.9.70
3
+ Version: 0.9.72
4
4
  Summary: BCE SDK for python
5
5
  Home-page: http://bce.baidu.com
6
6
  Author:
@@ -1,6 +1,6 @@
1
- baidubce/__init__.py,sha256=cIpPuDYZETh6U76-kL8v7bzDKAkz_WXCDJ9oIq1_pJo,813
1
+ baidubce/__init__.py,sha256=KsgM4TghseOO0BL6EUAbK1oheAShyRW_ZL-mxuhbUlM,813
2
2
  baidubce/bce_base_client.py,sha256=7gjkRy_YlTTb6TXHYHyZRYMjdVO7FTtHMdwXx8bPgsE,3428
3
- baidubce/bce_client_configuration.py,sha256=i9z5wVXaRSlJxE0LD1odexza35KQyFy7m1Az5XclD_I,3252
3
+ baidubce/bce_client_configuration.py,sha256=r6DGTdNSjWz857Ae_K1wedrV1WdxZUNmN9xkxYCOC0Y,3478
4
4
  baidubce/bce_response.py,sha256=kcebmFaCG6twa_GSchLGS5CQ5C8B9vV_4WszpbSqYtY,3326
5
5
  baidubce/compat.py,sha256=zv1_a09hkDyczAwizUty7puUzb2SvKPGcoGeNpDOUgA,3467
6
6
  baidubce/exception.py,sha256=p6JSeIl2z6iaO4spwjEZmRHWpBSkSGAtUQ1Ch43O6WU,1691
@@ -11,10 +11,10 @@ baidubce/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  baidubce/auth/bce_credentials.py,sha256=thRajmOSShtI5z0VTGHj9FuZvWj65noolDQCanj_pzs,1157
12
12
  baidubce/auth/bce_v1_signer.py,sha256=QjK4AYvxNum9jOhHcqzZzHFEN0PWyFiyBvGUop1wMQ8,5140
13
13
  baidubce/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- baidubce/http/bce_http_client.py,sha256=1sWG4hnhfiOrGxPtorKRsFJUtB1ybi9gV79nQUe7RBQ,12006
14
+ baidubce/http/bce_http_client.py,sha256=98y8lkkmg4aK6RXkZAgjMvKwCLK-oCXjInGvqQQydN4,12208
15
15
  baidubce/http/handler.py,sha256=JKvGfMLaewyFibSAlw8kT8Ok8Xt2VvNcT_Y2UmWc42M,2994
16
16
  baidubce/http/http_content_types.py,sha256=tHTGDR9nK5beD9HmJ4Iwj42fc9avsMpJELbb6UdKtkQ,722
17
- baidubce/http/http_headers.py,sha256=AZXDY9pU70z24Ky7__AJWzCVdtPl7Blu1Xv-Zp4IXAY,3433
17
+ baidubce/http/http_headers.py,sha256=s_jzTRQ13Msssm5uT7NgRJbLz6WFZYLxNsMFwqHa_Eg,3511
18
18
  baidubce/http/http_methods.py,sha256=Hn-A2fKoZiqmrtWVlHhk1cGxEoGDrbLfNykZuo1zDZc,782
19
19
  baidubce/retry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  baidubce/retry/retry_policy.py,sha256=A7cPvKxkVmd8PGA6_60sQU9hBzGbjXHVW0-QofP7-5E,4926
@@ -51,7 +51,7 @@ baidubce/services/bbc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
51
51
  baidubce/services/bbc/bbc_client.py,sha256=6x2fWmjyKSZ02WvsmQ1pryE0c_mtXHCjI0Ev80MfzbY,38951
52
52
  baidubce/services/bbc/bbc_model.py,sha256=Dy80LZ4ro_iS3UejJ_CL9kI7OyMSBoDitTE4J1XAC_g,1790
53
53
  baidubce/services/bcc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
- baidubce/services/bcc/bcc_client.py,sha256=qMogrdSuZS3AVu4CYoa2pVW372vVcTcyTqwhKsDGGQ4,311572
54
+ baidubce/services/bcc/bcc_client.py,sha256=vZWH7iNGivG1zlIyKOwh8yVexm2ohVVTHXPcqMya3UA,313363
55
55
  baidubce/services/bcc/bcc_model.py,sha256=xKYC4Z-gxWjFhe8b1AmMBEN_wYhnwcqAmer29ysS17k,6788
56
56
  baidubce/services/bcc/fpga_card_type.py,sha256=n6goqnapIgAC9_sciA_2he5HFqPRbRv109qitO7qpd8,948
57
57
  baidubce/services/bcc/gpu_card_type.py,sha256=HEfMzne-UC5F295JPrPUu7V9F5g-hbXF2TNBontEFes,1054
@@ -73,11 +73,11 @@ baidubce/services/bls/bls_model.py,sha256=A4kLRQo0aOlh2t4IFjd0aJbju-CmhZdryuXESu
73
73
  baidubce/services/bmr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
74
  baidubce/services/bmr/bmr_client.py,sha256=ntJie-R6qFxdd6znpfCj25RSoJ6gOV0o2Tn9asJThQg,20565
75
75
  baidubce/services/bos/__init__.py,sha256=bRvJAiFjUIBF64HeoZ7bkTjGfqkKJAvxYWBSEvbUOIc,813
76
- baidubce/services/bos/bos_client.py,sha256=95SI4v7DndYYfyNlLhfvGNBROYb_kzYaV1RoOIItASk,125273
77
- baidubce/services/bos/bos_handler.py,sha256=ZWVjezraJsdNy0tsX8fZkWPmSBYLSlGolKqZ1CcWE7A,1832
76
+ baidubce/services/bos/bos_client.py,sha256=TLgUW4W4_XGqUo5tIRdnWKp-uO_IKKx35HghIq3_cV4,128575
77
+ baidubce/services/bos/bos_handler.py,sha256=juTUXZ7rJTISvMKXJPsR9JpIWnnLTTn0ASe_Ss0Pzn0,4551
78
78
  baidubce/services/bos/canned_acl.py,sha256=Y2qvU81OI_nT0uu96MyTemXyR2EnNVVYrJxfPS1rhBA,723
79
- baidubce/services/bos/common.py,sha256=X2_PDLRR3Lpr7i2mzzyMBI2jCQ779hIx3XwBDTQAXhE,138
80
- baidubce/services/bos/storage_class.py,sha256=RiwV9b6N6dHFzNG6k4LUhjLngqfC837FWUvP-mr5BZ8,729
79
+ baidubce/services/bos/common.py,sha256=iW0n2ZvvHb4_tT-Nn5lPL_YPmTrGEM5zM1LBnG0b174,178
80
+ baidubce/services/bos/storage_class.py,sha256=mWtwyEHbtrGBpgPtNXi-iNDIzNBc6WVdmHeH1Qz8i3U,821
81
81
  baidubce/services/bts/__init__.py,sha256=714yrJr3fupwooCvp7LBsBwS151wRo7OltVUFCkstyg,749
82
82
  baidubce/services/bts/bts_client.py,sha256=4WtXqS8e0LDH5d61tN6Oc_F13fV-2nftAIx2VE4OyPQ,22108
83
83
  baidubce/services/bts/model.py,sha256=venQTHnF4Yqg5TKF8uFcUrJ8TIqhkVBoJNKY54DERwg,11520
@@ -128,7 +128,7 @@ baidubce/services/esg/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
128
128
  baidubce/services/esg/esg_client.py,sha256=8nqs7vnLrzaQ43tNSEZ_6tqQDhxu9hdTDu0yVidijJM,15504
129
129
  baidubce/services/esg/esg_model.py,sha256=4QOhtO3QzmwhNxveeVWfnbw9UmUpWPOAQvEbFMUOgj8,4159
130
130
  baidubce/services/et/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
131
- baidubce/services/et/et_client.py,sha256=yTKYQ7VU80EeRyuYhOqg5b793pF_v24ri6LDytF5-6Y,40322
131
+ baidubce/services/et/et_client.py,sha256=GHxXZ7utjBZ5Ll4vmXAdT7Qb9zKId7CKGpVtUWNAyME,40816
132
132
  baidubce/services/et/model.py,sha256=H0IkBVtMWYldFcLoXb_pFbrGQWGD4ZPthdfI443VQcc,975
133
133
  baidubce/services/etGateway/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
134
134
  baidubce/services/etGateway/et_gateway_client.py,sha256=_h_KPxiWNSiLNoG6HZHzrPHGkwviP1NvqGEvUCt4Olw,15744
@@ -201,7 +201,7 @@ baidubce/services/vpc/vpc_client.py,sha256=hTh_weKp7DzGkYxq-cfHPlzZp4v6NWgIPlrlX
201
201
  baidubce/services/vpn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
202
202
  baidubce/services/vpn/vpn_client.py,sha256=9OMhSPDVnSkLlJets2LbdTY7_2qqW4cB0_4a8kAxyhk,31571
203
203
  baidubce/services/vpn/vpn_model.py,sha256=C9rEBYyFIDjrqvqJG4WEin6qVzEIvbhPvT5KwDYm1qA,3365
204
- bce_python_sdk-0.9.70.dist-info/METADATA,sha256=i62ynHDC8pk6aYzuzsgtGCWoIqPOWY0N5DW0vWsZyTc,449
205
- bce_python_sdk-0.9.70.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
206
- bce_python_sdk-0.9.70.dist-info/top_level.txt,sha256=Oh6eo_-T_AuEDpIaR54biUUPThxsoQiYMVHLBTaweQs,9
207
- bce_python_sdk-0.9.70.dist-info/RECORD,,
204
+ bce_python_sdk-0.9.72.dist-info/METADATA,sha256=cUXTnF7uWFAYKiXC1m60_fd3Tl4Ni7QYxxpLLrZfIZU,449
205
+ bce_python_sdk-0.9.72.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
206
+ bce_python_sdk-0.9.72.dist-info/top_level.txt,sha256=Oh6eo_-T_AuEDpIaR54biUUPThxsoQiYMVHLBTaweQs,9
207
+ bce_python_sdk-0.9.72.dist-info/RECORD,,