bce-python-sdk 0.9.41__py3-none-any.whl → 0.9.45__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.41'
21
+ SDK_VERSION = b'0.9.45'
22
22
  DEFAULT_SERVICE_DOMAIN = b'bcebos.com'
23
23
  URL_PREFIX = b'/v1'
24
24
  DEFAULT_ENCODING = 'UTF-8'
@@ -42,6 +42,7 @@ class BceClientConfiguration(object):
42
42
  proxy_port=None,
43
43
  path_style_enable=False,
44
44
  auto_follow_redirect=False,
45
+ under_line_headers=True,
45
46
  ):
46
47
  self.credentials = credentials
47
48
  self.endpoint = compat.convert_to_bytes(endpoint) if endpoint is not None else endpoint
@@ -61,6 +62,7 @@ class BceClientConfiguration(object):
61
62
  self.path_style_enable = path_style_enable
62
63
  self.backup_endpoint = compat.convert_to_bytes(backup_endpoint) if backup_endpoint is not None else backup_endpoint
63
64
  self.auto_follow_redirect = auto_follow_redirect
65
+ self.under_line_headers = under_line_headers
64
66
 
65
67
  def merge_non_none_values(self, other):
66
68
  """
baidubce/bce_response.py CHANGED
@@ -41,6 +41,17 @@ class BceResponse(object):
41
41
  if k.lower() == compat.convert_to_string(http_headers.ETAG.lower()):
42
42
  v = v.strip('"')
43
43
  setattr(self.metadata, k, v)
44
+
45
+ def set_metadata_from_headers_no_underlined(self, headers):
46
+ """
47
+
48
+ :param headers:
49
+ :return:
50
+ """
51
+ for k, v in iteritems(headers):
52
+ if k.lower() == compat.convert_to_string(http_headers.ETAG.lower()):
53
+ v = v.strip('"')
54
+ setattr(self.metadata, k, v)
44
55
 
45
56
  def __getattr__(self, item):
46
57
  if item.startswith('__'):
@@ -229,7 +229,10 @@ def send_request(
229
229
  _logger.debug(
230
230
  'request return: status=%d, headers=%s' % (http_response.status, headers_list))
231
231
  response = BceResponse()
232
- response.set_metadata_from_headers(dict(headers_list))
232
+ if config.under_line_headers:
233
+ response.set_metadata_from_headers(dict(headers_list))
234
+ else:
235
+ response.set_metadata_from_headers_no_underlined(dict(headers_list))
233
236
  if config.auto_follow_redirect:
234
237
  if http_method == b'GET' and 300 <= http_response.status < 400:
235
238
  headers_map = {k: v for k, v in headers_list}
@@ -25,6 +25,7 @@ import string
25
25
  import uuid
26
26
 
27
27
  from baidubce import bce_base_client
28
+ from baidubce import compat
28
29
  from baidubce.auth import bce_v1_signer
29
30
  from baidubce.http import bce_http_client
30
31
  from baidubce.http import handler
@@ -32,7 +33,6 @@ from baidubce.http import http_methods
32
33
  from baidubce.services.bcc import bcc_model
33
34
  from baidubce.utils import aes128_encrypt_16char_key
34
35
  from baidubce.utils import required
35
- from baidubce import compat
36
36
 
37
37
  _logger = logging.getLogger(__name__)
38
38
 
@@ -6988,7 +6988,6 @@ class BccClient(bce_base_client.BceBaseClient):
6988
6988
  return self._send_request(http_methods.PUT, path, json.dumps(body),
6989
6989
  params=params, config=config)
6990
6990
 
6991
-
6992
6991
  def bind_sg(self, instance_ids, security_group_ids, security_group_type, client_token=None, config=None):
6993
6992
  """
6994
6993
  绑定安全组。
@@ -7016,7 +7015,6 @@ class BccClient(bce_base_client.BceBaseClient):
7016
7015
  return self._send_request(http_methods.PUT, path, json.dumps(body),
7017
7016
  params=params, config=config)
7018
7017
 
7019
-
7020
7018
  def replace_sg(self, instance_ids, security_group_ids, security_group_type, client_token=None, config=None):
7021
7019
  """
7022
7020
  替换安全组。
@@ -7610,6 +7608,70 @@ class BccClient(bce_base_client.BceBaseClient):
7610
7608
  return self._send_action_request(http_methods.POST, path, json.dumps(body),
7611
7609
  params=params, config=config)
7612
7610
 
7611
+ def get_task(self, task_ids, max_keys=100, config=None):
7612
+ """
7613
+ get_task
7614
+
7615
+ :param task_ids:
7616
+ task_ids to be used to query the task
7617
+ :type task_ids: list of string
7618
+
7619
+ :param max_keys:
7620
+ The optional parameter to specifies the max number of list result to return.
7621
+ The default value is 100.
7622
+ :type max_keys: int
7623
+
7624
+ :return:
7625
+ :rtype baidubce.bce_response.BceResponse
7626
+ """
7627
+ path = b'/task/detail'
7628
+ params = {}
7629
+
7630
+ body = {
7631
+ "taskIds": task_ids,
7632
+ "maxKeys": max_keys
7633
+ }
7634
+ return self._send_request(http_methods.POST, path, json.dumps(body),
7635
+ params=params, config=config)
7636
+
7637
+ def list_task(self, max_keys=10, task_ids=None, task_action=None, task_status=None, resource_ids=None,
7638
+ start_time=None, end_time=None, config=None):
7639
+ """
7640
+ list_task
7641
+
7642
+ :param task_ids:
7643
+ task_ids to be used to query the task
7644
+ :param task_action:
7645
+ task_action to be used to query the task
7646
+ :param task_status:
7647
+ task_status to be used to query the task
7648
+ :param start_time:
7649
+ The format is yyyy-MM-dd'T'HH: mm: ss'Z ', if it is empty, query the operation log of the day
7650
+ :param end_time:
7651
+ The format is yyyy-MM-dd'T'HH: mm: ss'Z ', if it is empty, query the operation log of the day
7652
+ :param max_keys:
7653
+ The optional parameter to specifies the max number of list result to return.
7654
+ The default value is 10.
7655
+ :param config:
7656
+ :return:
7657
+
7658
+ """
7659
+ path = b'/task/list'
7660
+ params = {}
7661
+
7662
+ body = {
7663
+ "taskIds": task_ids,
7664
+ "taskAction": task_action,
7665
+ "taskStatus": task_status,
7666
+ "startTime": start_time,
7667
+ "endTime": end_time,
7668
+ "resourceIds": resource_ids,
7669
+ "maxKeys": max_keys,
7670
+ }
7671
+ return self._send_request(http_methods.POST, path, json.dumps(body),
7672
+ params=params, config=config)
7673
+
7674
+
7613
7675
  def generate_client_token_by_uuid():
7614
7676
  """
7615
7677
  The default method to generate the random string for client_token
@@ -1803,6 +1803,7 @@ class BosClient(BceBaseClient):
1803
1803
  def complete_multipart_upload(self, bucket_name, key,
1804
1804
  upload_id, part_list,
1805
1805
  user_metadata=None,
1806
+ user_headers=None,
1806
1807
  config=None):
1807
1808
  """
1808
1809
  After finish all the task, complete multi_upload_file.
@@ -1825,7 +1826,8 @@ class BosClient(BceBaseClient):
1825
1826
  key = compat.convert_to_bytes(key)
1826
1827
  headers = self._prepare_object_headers(
1827
1828
  content_type=http_content_types.JSON,
1828
- user_metadata=user_metadata)
1829
+ user_metadata=user_metadata,
1830
+ user_headers=user_headers)
1829
1831
 
1830
1832
  return self._send_request(
1831
1833
  http_methods.POST,
@@ -2648,9 +2650,11 @@ class BosClient(BceBaseClient):
2648
2650
 
2649
2651
  if user_metadata is not None:
2650
2652
  meta_size = 0
2653
+ meta_data_set = set()
2651
2654
  if not isinstance(user_metadata, dict):
2652
2655
  raise TypeError('user_metadata should be of type dict.')
2653
2656
  for k, v in iteritems(user_metadata):
2657
+ meta_data_set.add(k.lower())
2654
2658
  k = utils.convert_to_standard_string(k)
2655
2659
  v = utils.convert_to_standard_string(v)
2656
2660
  normalized_key = http_headers.BCE_USER_METADATA_PREFIX + k
@@ -2660,6 +2664,8 @@ class BosClient(BceBaseClient):
2660
2664
  if meta_size > bos.MAX_USER_METADATA_SIZE:
2661
2665
  raise ValueError(
2662
2666
  'Metadata size should not be greater than %d.' % bos.MAX_USER_METADATA_SIZE)
2667
+ if len(meta_data_set) != len(user_metadata):
2668
+ raise ValueError('user_metadata has duplicate elements.')
2663
2669
 
2664
2670
  if storage_class is not None:
2665
2671
  headers[http_headers.BOS_STORAGE_CLASS] = storage_class
@@ -2833,7 +2839,7 @@ class BosClient(BceBaseClient):
2833
2839
  if BosClient._need_retry_backup_endpoint(e.last_error):
2834
2840
  _logger.debug(b'Retry for backup endpoint.')
2835
2841
  path = BosClient._get_path(config, bucket_name, key, True)
2836
- return bce_http_client.send_request(
2842
+ return bce_http_client.send_request_no_underlined(
2837
2843
  config, bce_v1_signer.sign, [handler.parse_error, body_parser],
2838
2844
  http_method, path, body, headers, params, True)
2839
2845
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bce-python-sdk
3
- Version: 0.9.41
3
+ Version: 0.9.45
4
4
  Summary: BCE SDK for python
5
5
  Home-page: http://bce.baidu.com
6
6
  Author:
@@ -1,7 +1,7 @@
1
- baidubce/__init__.py,sha256=PTVxbVyEB6WfQKjThW5COjmXRVtEhJW0NgbzaKVoVHw,813
1
+ baidubce/__init__.py,sha256=oVDTBA193X0Bi4yPGv9rsDp7iO_9hmGO4Ru7pihQyRc,813
2
2
  baidubce/bce_base_client.py,sha256=7gjkRy_YlTTb6TXHYHyZRYMjdVO7FTtHMdwXx8bPgsE,3428
3
- baidubce/bce_client_configuration.py,sha256=84xv1Hsi_6ddqZlU8Mde7JQHOl-zWNWX7CObPsorDbQ,3157
4
- baidubce/bce_response.py,sha256=V5a3bgRj04cM3Ml3s1OByLyZZSGDUy9PL52JSugmCgM,1655
3
+ baidubce/bce_client_configuration.py,sha256=i9z5wVXaRSlJxE0LD1odexza35KQyFy7m1Az5XclD_I,3252
4
+ baidubce/bce_response.py,sha256=gOj48U6iurYJsChzFdrB7Rj3RpkU-fUdhtftrIj9o8U,1985
5
5
  baidubce/compat.py,sha256=zv1_a09hkDyczAwizUty7puUzb2SvKPGcoGeNpDOUgA,3467
6
6
  baidubce/exception.py,sha256=p6JSeIl2z6iaO4spwjEZmRHWpBSkSGAtUQ1Ch43O6WU,1691
7
7
  baidubce/protocol.py,sha256=0DihT2fDN2YI_TBJob9pxt0deTwa9DS0gxbAChBn1Hw,1151
@@ -11,7 +11,7 @@ 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=f3jwZe9cCbSELJrlI-h4QP_ArjgfwsGuLGSIOHDC_2E,3211
13
13
  baidubce/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- baidubce/http/bce_http_client.py,sha256=Kg7bKhSSaIckFC7KT7wqUQ6srnTmOe95S6j3OREMZqg,11321
14
+ baidubce/http/bce_http_client.py,sha256=Hs2F8N-U59Z8542NK-I-y5ue87QEb7GGe2CV6Re12RM,11470
15
15
  baidubce/http/handler.py,sha256=FGotEXyM24t93E2Z4n9dJV9XD34im-gdmq8JDyncZA8,2930
16
16
  baidubce/http/http_content_types.py,sha256=tHTGDR9nK5beD9HmJ4Iwj42fc9avsMpJELbb6UdKtkQ,722
17
17
  baidubce/http/http_headers.py,sha256=fHZUEbzvTW9-JUAhBXXeag4mj7NbvMnwnRkyrxiFBUA,2978
@@ -27,7 +27,7 @@ baidubce/services/bbc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
27
27
  baidubce/services/bbc/bbc_client.py,sha256=6x2fWmjyKSZ02WvsmQ1pryE0c_mtXHCjI0Ev80MfzbY,38951
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=-E3a9m74YgpUmI3H9sXLPdsksG1ywExnJpfuYEXPY54,289908
30
+ baidubce/services/bcc/bcc_client.py,sha256=w8vGVi2xgq2oY2onJo8LbNIGZRbdV8Y8a1oqDdld0fs,292039
31
31
  baidubce/services/bcc/bcc_model.py,sha256=DLdpyU2x917zcyODd7OiyeDigkUTw8XxQvAdCCL9ur4,6647
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
@@ -49,7 +49,7 @@ baidubce/services/bls/bls_model.py,sha256=A4kLRQo0aOlh2t4IFjd0aJbju-CmhZdryuXESu
49
49
  baidubce/services/bmr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
50
  baidubce/services/bmr/bmr_client.py,sha256=ntJie-R6qFxdd6znpfCj25RSoJ6gOV0o2Tn9asJThQg,20565
51
51
  baidubce/services/bos/__init__.py,sha256=bRvJAiFjUIBF64HeoZ7bkTjGfqkKJAvxYWBSEvbUOIc,813
52
- baidubce/services/bos/bos_client.py,sha256=raN_E0Xxg7zoWUA-v3fatlTaaajfKlSZ9N1YbJs9SSY,103354
52
+ baidubce/services/bos/bos_client.py,sha256=IhA-fTH-a6Mgf_4jTfvkSacPy7pQ5Bvk0J9FvzHlmbw,103670
53
53
  baidubce/services/bos/bos_handler.py,sha256=ZWVjezraJsdNy0tsX8fZkWPmSBYLSlGolKqZ1CcWE7A,1832
54
54
  baidubce/services/bos/canned_acl.py,sha256=Y2qvU81OI_nT0uu96MyTemXyR2EnNVVYrJxfPS1rhBA,723
55
55
  baidubce/services/bos/common.py,sha256=X2_PDLRR3Lpr7i2mzzyMBI2jCQ779hIx3XwBDTQAXhE,138
@@ -174,7 +174,7 @@ baidubce/services/vpc/vpc_client.py,sha256=xmW-m7IIYrnvvH0epwvJ1JgG52AMA5-YIvKjx
174
174
  baidubce/services/vpn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
175
175
  baidubce/services/vpn/vpn_client.py,sha256=rrnQElD-LTttsqMbbIHoHK0Jdc7FrVVTZIdu-0Zthr8,31352
176
176
  baidubce/services/vpn/vpn_model.py,sha256=C9rEBYyFIDjrqvqJG4WEin6qVzEIvbhPvT5KwDYm1qA,3365
177
- bce_python_sdk-0.9.41.dist-info/METADATA,sha256=AuB3DM52zKwsq1taSpjd7_ONWqiD7VHPp2SOwDBZ-c8,416
178
- bce_python_sdk-0.9.41.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
179
- bce_python_sdk-0.9.41.dist-info/top_level.txt,sha256=Oh6eo_-T_AuEDpIaR54biUUPThxsoQiYMVHLBTaweQs,9
180
- bce_python_sdk-0.9.41.dist-info/RECORD,,
177
+ bce_python_sdk-0.9.45.dist-info/METADATA,sha256=xfailXOrYfaksH99Cp165ZtNMKycQ5uGyKoEeQi79vg,416
178
+ bce_python_sdk-0.9.45.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
179
+ bce_python_sdk-0.9.45.dist-info/top_level.txt,sha256=Oh6eo_-T_AuEDpIaR54biUUPThxsoQiYMVHLBTaweQs,9
180
+ bce_python_sdk-0.9.45.dist-info/RECORD,,