bce-python-sdk 0.9.4__py3-none-any.whl → 0.9.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- baidubce/__init__.py +1 -1
- baidubce/bce_client_configuration.py +4 -1
- baidubce/http/http_headers.py +2 -0
- baidubce/services/bcc/bcc_client.py +31 -5
- baidubce/services/bcm/bcm_client.py +269 -29
- baidubce/services/bos/bos_client.py +137 -25
- baidubce/utils.py +28 -6
- {bce_python_sdk-0.9.4.dist-info → bce_python_sdk-0.9.6.dist-info}/METADATA +1 -1
- {bce_python_sdk-0.9.4.dist-info → bce_python_sdk-0.9.6.dist-info}/RECORD +11 -11
- {bce_python_sdk-0.9.4.dist-info → bce_python_sdk-0.9.6.dist-info}/WHEEL +1 -1
- {bce_python_sdk-0.9.4.dist-info → bce_python_sdk-0.9.6.dist-info}/top_level.txt +0 -0
baidubce/__init__.py
CHANGED
|
@@ -39,7 +39,9 @@ class BceClientConfiguration(object):
|
|
|
39
39
|
cname_enabled=False,
|
|
40
40
|
backup_endpoint=None,
|
|
41
41
|
proxy_host=None,
|
|
42
|
-
proxy_port=None,
|
|
42
|
+
proxy_port=None,
|
|
43
|
+
path_style_enable=False,
|
|
44
|
+
):
|
|
43
45
|
self.credentials = credentials
|
|
44
46
|
self.endpoint = compat.convert_to_bytes(endpoint) if endpoint is not None else endpoint
|
|
45
47
|
self.protocol = protocol
|
|
@@ -55,6 +57,7 @@ class BceClientConfiguration(object):
|
|
|
55
57
|
self.retry_policy = retry_policy
|
|
56
58
|
self.security_token = security_token
|
|
57
59
|
self.cname_enabled = cname_enabled
|
|
60
|
+
self.path_style_enable = path_style_enable
|
|
58
61
|
self.backup_endpoint = compat.convert_to_bytes(backup_endpoint) if backup_endpoint is not None else backup_endpoint
|
|
59
62
|
|
|
60
63
|
def merge_non_none_values(self, other):
|
baidubce/http/http_headers.py
CHANGED
|
@@ -1780,7 +1780,7 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
1780
1780
|
description=None, renew_time_unit=None, renew_time=None,
|
|
1781
1781
|
cluster_id=None, relation_tag=False,
|
|
1782
1782
|
tags=None, auto_snapshot_policy=None,
|
|
1783
|
-
client_token=None, config=None):
|
|
1783
|
+
client_token=None, config=None, charge_type=None):
|
|
1784
1784
|
"""
|
|
1785
1785
|
Create a volume with the specified options.
|
|
1786
1786
|
You can use this method to create a new empty volume by specified options
|
|
@@ -1795,7 +1795,7 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
1795
1795
|
:type cds_size_in_gb: int
|
|
1796
1796
|
|
|
1797
1797
|
:param billing:
|
|
1798
|
-
Billing information.
|
|
1798
|
+
Billing information.Deprecated
|
|
1799
1799
|
:type billing: bcc_model.Billing
|
|
1800
1800
|
|
|
1801
1801
|
:param purchase_count:
|
|
@@ -1855,6 +1855,17 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
1855
1855
|
The optional auto snapshot policy to be bonded.
|
|
1856
1856
|
:type auto_snapshot_policy: bcc_model.AutoSnapshotPolicyModel
|
|
1857
1857
|
|
|
1858
|
+
:param charge_type:
|
|
1859
|
+
The optional parameter to specify the payment for the volume.
|
|
1860
|
+
The billing type and payment method, including Prepaid and Postpaid,
|
|
1861
|
+
need to be specified only when the instanceId is not empty and the corresponding instance type is prepaid.
|
|
1862
|
+
If instanceId is empty:
|
|
1863
|
+
create a post payment type CDS;
|
|
1864
|
+
If the instanceId is not empty:
|
|
1865
|
+
If the instance is prepaid, a chargeType needs to be specified;
|
|
1866
|
+
If the instance is post paid, create a post paid CDS
|
|
1867
|
+
:type charge_type: menu{'Prepaid', 'Postpaid'}
|
|
1868
|
+
|
|
1858
1869
|
:return:
|
|
1859
1870
|
:rtype baidubce.bce_response.BceResponse
|
|
1860
1871
|
"""
|
|
@@ -1897,6 +1908,8 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
1897
1908
|
body['encryptKey'] = encrypt_key
|
|
1898
1909
|
if instance_id is not None:
|
|
1899
1910
|
body['instanceId'] = instance_id
|
|
1911
|
+
if charge_type is not None:
|
|
1912
|
+
body['chargeType'] = charge_type
|
|
1900
1913
|
return self._send_request(http_methods.POST, path, json.dumps(body),
|
|
1901
1914
|
params=params, config=config)
|
|
1902
1915
|
|
|
@@ -1907,7 +1920,7 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
1907
1920
|
description=None, renew_time_unit=None, renew_time=None,
|
|
1908
1921
|
cluster_id=None, relation_tag=False,
|
|
1909
1922
|
tags=None, auto_snapshot_policy=None,
|
|
1910
|
-
config=None):
|
|
1923
|
+
config=None, charge_type=None):
|
|
1911
1924
|
"""
|
|
1912
1925
|
Create a volume with the specified options.
|
|
1913
1926
|
You can use this method to create a new empty volume by specified options
|
|
@@ -1915,14 +1928,14 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
1915
1928
|
By using the cdsSizeInGB parameter you can create a newly empty volume.
|
|
1916
1929
|
By using snapshotId parameter to create a volume form specific snapshot.
|
|
1917
1930
|
|
|
1918
|
-
:param snapshot_id:
|
|
1931
|
+
:param snapshot_id:xx
|
|
1919
1932
|
The id of snapshot.
|
|
1920
1933
|
By specifying the snapshotId,
|
|
1921
1934
|
it will create volume from the specified snapshot and the parameter cdsSizeInGB will be ignored.
|
|
1922
1935
|
:type snapshot_id: string
|
|
1923
1936
|
|
|
1924
1937
|
:param billing:
|
|
1925
|
-
Billing information.
|
|
1938
|
+
Billing information.Deprecated
|
|
1926
1939
|
:type billing: bcc_model.Billing
|
|
1927
1940
|
|
|
1928
1941
|
:param purchase_count:
|
|
@@ -1982,6 +1995,17 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
1982
1995
|
https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
|
|
1983
1996
|
:type client_token: string
|
|
1984
1997
|
|
|
1998
|
+
:param charge_type:
|
|
1999
|
+
The optional parameter to specify the payment for the volume.
|
|
2000
|
+
The billing type and payment method, including Prepaid and Postpaid,
|
|
2001
|
+
need to be specified only when the instanceId is not empty and the corresponding instance type is prepaid.
|
|
2002
|
+
If instanceId is empty:
|
|
2003
|
+
create a post payment type CDS;
|
|
2004
|
+
If the instanceId is not empty:
|
|
2005
|
+
If the instance is prepaid, a chargeType needs to be specified;
|
|
2006
|
+
If the instance is post paid, create a post paid CDS
|
|
2007
|
+
:type charge_type: menu{'Prepaid', 'Postpaid'}
|
|
2008
|
+
|
|
1985
2009
|
:return:
|
|
1986
2010
|
:rtype baidubce.bce_response.BceResponse
|
|
1987
2011
|
"""
|
|
@@ -2024,6 +2048,8 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
2024
2048
|
body['encryptKey'] = encrypt_key
|
|
2025
2049
|
if instance_id is not None:
|
|
2026
2050
|
body['instanceId'] = instance_id
|
|
2051
|
+
if charge_type is not None:
|
|
2052
|
+
body['chargeType'] = charge_type
|
|
2027
2053
|
return self._send_request(http_methods.POST, path, json.dumps(body),
|
|
2028
2054
|
params=params, config=config)
|
|
2029
2055
|
|
|
@@ -29,6 +29,8 @@ if sys.version_info[0] == 2:
|
|
|
29
29
|
else:
|
|
30
30
|
value_type = (str, bytes)
|
|
31
31
|
|
|
32
|
+
MAX_INSTANCE_NUMBER = 100
|
|
33
|
+
|
|
32
34
|
|
|
33
35
|
class BcmClient(bce_base_client.BceBaseClient):
|
|
34
36
|
"""
|
|
@@ -2924,7 +2926,6 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
2924
2926
|
}
|
|
2925
2927
|
return self._send_csm_request(http_methods.GET, path, params=params)
|
|
2926
2928
|
|
|
2927
|
-
|
|
2928
2929
|
def push_metric_data(self, user_id=None, scope=None, metric_data=None, config=None):
|
|
2929
2930
|
|
|
2930
2931
|
"""
|
|
@@ -2945,7 +2946,6 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
2945
2946
|
|
|
2946
2947
|
return self._send_request(http_methods.POST, path, body=json.dumps(body), config=config)
|
|
2947
2948
|
|
|
2948
|
-
|
|
2949
2949
|
def get_custom_metric_data(self, user_id=None, namespaces=None, metric_name=None,
|
|
2950
2950
|
dimensions=None, statistics=None, start_time=None,
|
|
2951
2951
|
end_time=None, cycle=None, config=None):
|
|
@@ -3049,7 +3049,6 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3049
3049
|
|
|
3050
3050
|
return self._send_csm_request(http_methods.POST, path, body=json.dumps(body), config=config)
|
|
3051
3051
|
|
|
3052
|
-
|
|
3053
3052
|
def create_site_http_task_config(self, user_id=None, task_name=None, address=None,
|
|
3054
3053
|
method=None, post_content=None,
|
|
3055
3054
|
advance_config=None, cycle=None, idc=None, timeout=None, config=None):
|
|
@@ -3079,7 +3078,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3079
3078
|
|
|
3080
3079
|
user_id = compat.convert_to_bytes(user_id)
|
|
3081
3080
|
path = b'/userId/%s/site/http/create' % (user_id)
|
|
3082
|
-
body =
|
|
3081
|
+
body = {
|
|
3083
3082
|
"userId": user_id,
|
|
3084
3083
|
"taskName": task_name,
|
|
3085
3084
|
"address": address,
|
|
@@ -3124,7 +3123,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3124
3123
|
|
|
3125
3124
|
user_id = compat.convert_to_bytes(user_id)
|
|
3126
3125
|
path = b'/userId/%s/site/http/update' % (user_id)
|
|
3127
|
-
body =
|
|
3126
|
+
body = {
|
|
3128
3127
|
"userId": user_id,
|
|
3129
3128
|
"taskId": task_id,
|
|
3130
3129
|
"taskName": task_name,
|
|
@@ -3188,7 +3187,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3188
3187
|
|
|
3189
3188
|
user_id = compat.convert_to_bytes(user_id)
|
|
3190
3189
|
path = b'/userId/%s/site/https/create' % (user_id)
|
|
3191
|
-
body =
|
|
3190
|
+
body = {
|
|
3192
3191
|
"userId": user_id,
|
|
3193
3192
|
"taskName": task_name,
|
|
3194
3193
|
"address": address,
|
|
@@ -3233,7 +3232,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3233
3232
|
|
|
3234
3233
|
user_id = compat.convert_to_bytes(user_id)
|
|
3235
3234
|
path = b'/userId/%s/site/https/update' % (user_id)
|
|
3236
|
-
body =
|
|
3235
|
+
body = {
|
|
3237
3236
|
"userId": user_id,
|
|
3238
3237
|
"taskId": task_id,
|
|
3239
3238
|
"taskName": task_name,
|
|
@@ -3295,7 +3294,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3295
3294
|
|
|
3296
3295
|
user_id = compat.convert_to_bytes(user_id)
|
|
3297
3296
|
path = b'/userId/%s/site/ping/create' % (user_id)
|
|
3298
|
-
body =
|
|
3297
|
+
body = {
|
|
3299
3298
|
"userId": user_id,
|
|
3300
3299
|
"taskName": task_name,
|
|
3301
3300
|
"address": address,
|
|
@@ -3337,7 +3336,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3337
3336
|
|
|
3338
3337
|
user_id = compat.convert_to_bytes(user_id)
|
|
3339
3338
|
path = b'/userId/%s/site/ping/update' % (user_id)
|
|
3340
|
-
body =
|
|
3339
|
+
body = {
|
|
3341
3340
|
"userId": user_id,
|
|
3342
3341
|
"taskId": task_id,
|
|
3343
3342
|
"taskName": task_name,
|
|
@@ -3400,7 +3399,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3400
3399
|
|
|
3401
3400
|
user_id = compat.convert_to_bytes(user_id)
|
|
3402
3401
|
path = b'/userId/%s/site/tcp/create' % (user_id)
|
|
3403
|
-
body =
|
|
3402
|
+
body = {
|
|
3404
3403
|
"userId": user_id,
|
|
3405
3404
|
"taskName": task_name,
|
|
3406
3405
|
"address": address,
|
|
@@ -3456,7 +3455,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3456
3455
|
|
|
3457
3456
|
user_id = compat.convert_to_bytes(user_id)
|
|
3458
3457
|
path = b'/userId/%s/site/tcp/update' % (user_id)
|
|
3459
|
-
body =
|
|
3458
|
+
body = {
|
|
3460
3459
|
"userId": user_id,
|
|
3461
3460
|
"taskId": task_id,
|
|
3462
3461
|
"taskName": task_name,
|
|
@@ -3523,7 +3522,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3523
3522
|
|
|
3524
3523
|
user_id = compat.convert_to_bytes(user_id)
|
|
3525
3524
|
path = b'/userId/%s/site/udp/create' % (user_id)
|
|
3526
|
-
body =
|
|
3525
|
+
body = {
|
|
3527
3526
|
"userId": user_id,
|
|
3528
3527
|
"taskName": task_name,
|
|
3529
3528
|
"address": address,
|
|
@@ -3579,7 +3578,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3579
3578
|
|
|
3580
3579
|
user_id = compat.convert_to_bytes(user_id)
|
|
3581
3580
|
path = b'/userId/%s/site/udp/update' % (user_id)
|
|
3582
|
-
body =
|
|
3581
|
+
body = {
|
|
3583
3582
|
"userId": user_id,
|
|
3584
3583
|
"taskId": task_id,
|
|
3585
3584
|
"taskName": task_name,
|
|
@@ -3650,7 +3649,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3650
3649
|
|
|
3651
3650
|
user_id = compat.convert_to_bytes(user_id)
|
|
3652
3651
|
path = b'/userId/%s/site/ftp/create' % (user_id)
|
|
3653
|
-
body =
|
|
3652
|
+
body = {
|
|
3654
3653
|
"userId": user_id,
|
|
3655
3654
|
"taskName": task_name,
|
|
3656
3655
|
"address": address,
|
|
@@ -3700,7 +3699,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3700
3699
|
|
|
3701
3700
|
user_id = compat.convert_to_bytes(user_id)
|
|
3702
3701
|
path = b'/userId/%s/site/ftp/update' % (user_id)
|
|
3703
|
-
body =
|
|
3702
|
+
body = {
|
|
3704
3703
|
"userId": user_id,
|
|
3705
3704
|
"taskId": task_id,
|
|
3706
3705
|
"taskName": task_name,
|
|
@@ -3767,7 +3766,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3767
3766
|
|
|
3768
3767
|
user_id = compat.convert_to_bytes(user_id)
|
|
3769
3768
|
path = b'/userId/%s/site/dns/create' % (user_id)
|
|
3770
|
-
body =
|
|
3769
|
+
body = {
|
|
3771
3770
|
"userId": user_id,
|
|
3772
3771
|
"taskName": task_name,
|
|
3773
3772
|
"address": address,
|
|
@@ -3814,7 +3813,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3814
3813
|
|
|
3815
3814
|
user_id = compat.convert_to_bytes(user_id)
|
|
3816
3815
|
path = b'/userId/%s/site/dns/update' % (user_id)
|
|
3817
|
-
body =
|
|
3816
|
+
body = {
|
|
3818
3817
|
"userId": user_id,
|
|
3819
3818
|
"taskId": task_id,
|
|
3820
3819
|
"taskName": task_name,
|
|
@@ -3905,7 +3904,6 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3905
3904
|
b'taskId': task_id,
|
|
3906
3905
|
}
|
|
3907
3906
|
|
|
3908
|
-
|
|
3909
3907
|
return self._send_csm_request(http_methods.DELETE, path, params=params, config=config)
|
|
3910
3908
|
|
|
3911
3909
|
def get_site_task_config_info(self, user_id=None, task_id=None, config=None):
|
|
@@ -3924,7 +3922,6 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3924
3922
|
task_id = compat.convert_to_bytes(task_id)
|
|
3925
3923
|
path = b'/userId/%s/site/%s' % (user_id, task_id)
|
|
3926
3924
|
|
|
3927
|
-
|
|
3928
3925
|
return self._send_csm_request(http_methods.GET, path, config=config)
|
|
3929
3926
|
|
|
3930
3927
|
def create_site_alarm_config(self, user_id=None, task_id=None, comment=None, alias_name=None,
|
|
@@ -3969,7 +3966,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
3969
3966
|
|
|
3970
3967
|
user_id = compat.convert_to_bytes(user_id)
|
|
3971
3968
|
path = b'/userId/%s/site/alarm/config/create' % (user_id)
|
|
3972
|
-
body =
|
|
3969
|
+
body = {
|
|
3973
3970
|
"userId": user_id,
|
|
3974
3971
|
"taskId": task_id,
|
|
3975
3972
|
"comment": comment,
|
|
@@ -4008,7 +4005,6 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
4008
4005
|
"alarmNames": alarm_names
|
|
4009
4006
|
}
|
|
4010
4007
|
|
|
4011
|
-
|
|
4012
4008
|
return self._send_csm_request(http_methods.DELETE, path, body=json.dumps(body), config=config)
|
|
4013
4009
|
|
|
4014
4010
|
def update_site_alarm_config(self, user_id=None, task_id=None, alarm_name=None, comment=None, alias_name=None,
|
|
@@ -4055,7 +4051,7 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
4055
4051
|
|
|
4056
4052
|
user_id = compat.convert_to_bytes(user_id)
|
|
4057
4053
|
path = b'/userId/%s/site/alarm/config/update' % (user_id)
|
|
4058
|
-
body =
|
|
4054
|
+
body = {
|
|
4059
4055
|
"userId": user_id,
|
|
4060
4056
|
"taskId": task_id,
|
|
4061
4057
|
"alarmName": alarm_name,
|
|
@@ -4095,7 +4091,6 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
4095
4091
|
b'alarmName': alarm_name,
|
|
4096
4092
|
}
|
|
4097
4093
|
|
|
4098
|
-
|
|
4099
4094
|
return self._send_csm_request(http_methods.GET, path, params=params, config=config)
|
|
4100
4095
|
|
|
4101
4096
|
def get_site_alarm_config_list(self, user_id=None, task_id=None, alarm_name=None,
|
|
@@ -4122,7 +4117,6 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
4122
4117
|
path = b'/userId/%s/site/alarm/config/list' % (user_id)
|
|
4123
4118
|
params = {}
|
|
4124
4119
|
|
|
4125
|
-
|
|
4126
4120
|
if task_id is not None:
|
|
4127
4121
|
params[b'taskId'] = task_id
|
|
4128
4122
|
if alarm_name is not None:
|
|
@@ -4248,7 +4242,6 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
4248
4242
|
"taskId": task_id
|
|
4249
4243
|
}
|
|
4250
4244
|
|
|
4251
|
-
|
|
4252
4245
|
return self._send_csm_request(http_methods.GET, path, params=params,
|
|
4253
4246
|
body_parser=bcm_handler.parse_json_list, config=config)
|
|
4254
4247
|
|
|
@@ -4273,7 +4266,6 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
4273
4266
|
"isp": isp
|
|
4274
4267
|
}
|
|
4275
4268
|
|
|
4276
|
-
|
|
4277
4269
|
return self._send_csm_request(http_methods.GET, path, params=params,
|
|
4278
4270
|
body_parser=bcm_handler.parse_json_list, config=config)
|
|
4279
4271
|
|
|
@@ -4290,7 +4282,6 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
4290
4282
|
user_id = compat.convert_to_bytes(user_id)
|
|
4291
4283
|
path = b'/userId/%s/site/agent/list' % (user_id)
|
|
4292
4284
|
|
|
4293
|
-
|
|
4294
4285
|
return self._send_csm_request(http_methods.GET, path, body_parser=bcm_handler.parse_json_list, config=config)
|
|
4295
4286
|
|
|
4296
4287
|
def get_site_agent_for_task(self, user_id=None, task_id=None, config=None):
|
|
@@ -4313,7 +4304,6 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
4313
4304
|
|
|
4314
4305
|
return self._send_csm_request(http_methods.GET, path, params=params, config=config)
|
|
4315
4306
|
|
|
4316
|
-
|
|
4317
4307
|
def create_alarm_config(self, user_id, alias_name, scope, level, region, monitor_object, alarm_actions, rules,
|
|
4318
4308
|
src_type="INSTANCE", ok_actions=None, insufficient_actions=None, config_type="NORMAL",
|
|
4319
4309
|
insufficient_cycle=0, max_repeat_count=0, repeat_alarm_cycle=0, callback_url="",
|
|
@@ -5631,4 +5621,254 @@ class BcmClient(bce_base_client.BceBaseClient):
|
|
|
5631
5621
|
b'ipType': ip_type,
|
|
5632
5622
|
}
|
|
5633
5623
|
path = b'/site/once/siteAgent'
|
|
5634
|
-
return self._send_csm_request(http_methods.GET, path, params=params)
|
|
5624
|
+
return self._send_csm_request(http_methods.GET, path, params=params)
|
|
5625
|
+
|
|
5626
|
+
@required(user_id=str, scope=str, region=str, resource_type=str, dimensions=list,
|
|
5627
|
+
metric_names=list, timestamp=str, statistics=list, cycle=int)
|
|
5628
|
+
def get_multi_dimension_latest_metrics(self, user_id, scope, region=None, resource_type=None, dimensions=None,
|
|
5629
|
+
metric_names=None, timestamp=None, statistics=None, cycle=None):
|
|
5630
|
+
"""
|
|
5631
|
+
:param user_id: str
|
|
5632
|
+
:param scope: str
|
|
5633
|
+
:param region: str
|
|
5634
|
+
:param resource_type: str
|
|
5635
|
+
:param dimensions: list
|
|
5636
|
+
:param metric_names: list
|
|
5637
|
+
:param timestamp: str
|
|
5638
|
+
:param statistics: list
|
|
5639
|
+
:param cycle: int
|
|
5640
|
+
|
|
5641
|
+
:return:
|
|
5642
|
+
"""
|
|
5643
|
+
if len(user_id) <= 0:
|
|
5644
|
+
raise ValueError("user_id should not be null")
|
|
5645
|
+
if len(scope) <= 0:
|
|
5646
|
+
raise ValueError("scope should not be null")
|
|
5647
|
+
if metric_names is None:
|
|
5648
|
+
raise ValueError("metric_names should not be null")
|
|
5649
|
+
if len(dimensions) > MAX_INSTANCE_NUMBER:
|
|
5650
|
+
raise ValueError("dimensions size cannot more than " + MAX_INSTANCE_NUMBER)
|
|
5651
|
+
if cycle is None:
|
|
5652
|
+
cycle = 60
|
|
5653
|
+
body = {
|
|
5654
|
+
"userId": user_id,
|
|
5655
|
+
"scope": scope,
|
|
5656
|
+
"cycle": cycle
|
|
5657
|
+
}
|
|
5658
|
+
metric_names_req = []
|
|
5659
|
+
for res in metric_names:
|
|
5660
|
+
metric_names_req.append(res)
|
|
5661
|
+
body["metricNames"] = metric_names_req
|
|
5662
|
+
if region is not None:
|
|
5663
|
+
body["region"] = region
|
|
5664
|
+
if resource_type is not None:
|
|
5665
|
+
body["resourceType"] = resource_type
|
|
5666
|
+
if dimensions is not None:
|
|
5667
|
+
dimensions_res = []
|
|
5668
|
+
for res in dimensions:
|
|
5669
|
+
dimensions_res.append(res)
|
|
5670
|
+
body["dimensions"] = dimensions_res
|
|
5671
|
+
if timestamp is not None:
|
|
5672
|
+
body["timestamp"] = timestamp
|
|
5673
|
+
if statistics is not None:
|
|
5674
|
+
body["statistics"] = statistics
|
|
5675
|
+
user_id = compat.convert_to_bytes(user_id)
|
|
5676
|
+
scope = compat.convert_to_bytes(scope)
|
|
5677
|
+
path = b'/userId/%s/services/%s/data/metricData/latest/batch' % (user_id, scope)
|
|
5678
|
+
return self._send_csm_request(http_methods.POST, path, version=b'/v2', body=json.dumps(body))
|
|
5679
|
+
|
|
5680
|
+
|
|
5681
|
+
def get_metrics_by_partial_dimensions(self, user_id, scope, statistics, metric_name, start_time, end_time,
|
|
5682
|
+
region=None, resource_type=None, dimensions=None, cycle=None,
|
|
5683
|
+
pageNo=None, pageSize=None):
|
|
5684
|
+
"""
|
|
5685
|
+
:param user_id: str
|
|
5686
|
+
:param scope: str
|
|
5687
|
+
:param statistics: list
|
|
5688
|
+
:param metric_name: str
|
|
5689
|
+
:param start_time: str
|
|
5690
|
+
:param end_time: str
|
|
5691
|
+
:param region: str
|
|
5692
|
+
:param resource_type: str
|
|
5693
|
+
:param dimensions: list
|
|
5694
|
+
:param cycle: int
|
|
5695
|
+
:param pageNo: int
|
|
5696
|
+
:param pageSize: int
|
|
5697
|
+
|
|
5698
|
+
:return:
|
|
5699
|
+
"""
|
|
5700
|
+
if len(user_id) <= 0:
|
|
5701
|
+
raise ValueError("user_id should not be null")
|
|
5702
|
+
if len(scope) <= 0:
|
|
5703
|
+
raise ValueError("scope should not be null")
|
|
5704
|
+
if len(metric_name) <= 0:
|
|
5705
|
+
raise ValueError("metric_name should not be null")
|
|
5706
|
+
if len(start_time) <= 0:
|
|
5707
|
+
raise ValueError("start_time should not be null")
|
|
5708
|
+
if len(end_time) <= 0:
|
|
5709
|
+
raise ValueError("end_time should not be null")
|
|
5710
|
+
if len(statistics) <= 0:
|
|
5711
|
+
raise ValueError("statistics should not be null")
|
|
5712
|
+
if len(dimensions) > MAX_INSTANCE_NUMBER:
|
|
5713
|
+
raise ValueError("dimensions size cannot more than " + MAX_INSTANCE_NUMBER)
|
|
5714
|
+
body = {
|
|
5715
|
+
"userId": user_id,
|
|
5716
|
+
"scope": scope,
|
|
5717
|
+
"startTime": start_time,
|
|
5718
|
+
"endTime": end_time,
|
|
5719
|
+
"statistics": statistics,
|
|
5720
|
+
"metricName": metric_name
|
|
5721
|
+
}
|
|
5722
|
+
if region is not None:
|
|
5723
|
+
body["region"] = region
|
|
5724
|
+
if resource_type is not None:
|
|
5725
|
+
body["resourceType"] = resource_type
|
|
5726
|
+
if dimensions is not None:
|
|
5727
|
+
dimensions_res = []
|
|
5728
|
+
for res in dimensions:
|
|
5729
|
+
dimensions_res.append(res)
|
|
5730
|
+
body["dimensions"] = dimensions_res
|
|
5731
|
+
if cycle is not None:
|
|
5732
|
+
body["cycle"] = cycle
|
|
5733
|
+
if pageNo is not None:
|
|
5734
|
+
body["pageNo"] = pageNo
|
|
5735
|
+
if pageSize is not None:
|
|
5736
|
+
body["pageSize"] = pageSize
|
|
5737
|
+
user_id = compat.convert_to_bytes(user_id)
|
|
5738
|
+
scope = compat.convert_to_bytes(scope)
|
|
5739
|
+
path = b'/userId/%s/services/%s/data/metricData/PartialDimension' % (user_id, scope)
|
|
5740
|
+
return self._send_csm_request(http_methods.POST, path, version=b'/v2', body=json.dumps(body))
|
|
5741
|
+
|
|
5742
|
+
def get_all_data_metrics_v2(self, user_id, scope, region, dimensions, metric_names, statistics,
|
|
5743
|
+
start_time, end_time, type="Instance", cycle=60):
|
|
5744
|
+
|
|
5745
|
+
"""
|
|
5746
|
+
:param user_id: user_id
|
|
5747
|
+
:type string
|
|
5748
|
+
|
|
5749
|
+
:param scope: scope
|
|
5750
|
+
:type string
|
|
5751
|
+
|
|
5752
|
+
:param region: region
|
|
5753
|
+
:type string
|
|
5754
|
+
|
|
5755
|
+
:param type: resource type
|
|
5756
|
+
:type string
|
|
5757
|
+
|
|
5758
|
+
:param dimensions: dimensions
|
|
5759
|
+
:type double string array
|
|
5760
|
+
|
|
5761
|
+
:param metric_names: metric names
|
|
5762
|
+
:type string array
|
|
5763
|
+
|
|
5764
|
+
:param statistics: statistics
|
|
5765
|
+
:type string array
|
|
5766
|
+
|
|
5767
|
+
:param cycle: cycle
|
|
5768
|
+
:type int
|
|
5769
|
+
|
|
5770
|
+
:param start_time: start time
|
|
5771
|
+
:type string
|
|
5772
|
+
|
|
5773
|
+
:param end_time: end time
|
|
5774
|
+
:type string
|
|
5775
|
+
:return:
|
|
5776
|
+
"""
|
|
5777
|
+
if len(user_id) <= 0:
|
|
5778
|
+
raise ValueError("user_id should not be null")
|
|
5779
|
+
if len(scope) <= 0:
|
|
5780
|
+
raise ValueError("scope should not be null")
|
|
5781
|
+
if len(region) <= 0:
|
|
5782
|
+
raise ValueError("region should not be null")
|
|
5783
|
+
if metric_names is None:
|
|
5784
|
+
raise ValueError("metric_names should not be null")
|
|
5785
|
+
if dimensions is None:
|
|
5786
|
+
raise ValueError("dimensions should not be null")
|
|
5787
|
+
if statistics is None:
|
|
5788
|
+
raise ValueError("statistics should not be null")
|
|
5789
|
+
if len(dimensions) > MAX_INSTANCE_NUMBER:
|
|
5790
|
+
raise ValueError("dimensions size cannot more than " + MAX_INSTANCE_NUMBER)
|
|
5791
|
+
body = {
|
|
5792
|
+
"userId": user_id,
|
|
5793
|
+
"scope": scope,
|
|
5794
|
+
"cycle": cycle,
|
|
5795
|
+
"region": region,
|
|
5796
|
+
"startTime": start_time,
|
|
5797
|
+
"endTime": end_time,
|
|
5798
|
+
"metricNames": metric_names,
|
|
5799
|
+
"dimensions": dimensions,
|
|
5800
|
+
"statistics": statistics
|
|
5801
|
+
}
|
|
5802
|
+
if type is not None:
|
|
5803
|
+
body["type"] = type
|
|
5804
|
+
|
|
5805
|
+
path = b'/data/metricAllData'
|
|
5806
|
+
return self._send_csm_request(http_methods.POST, path, version=b'/v2', body=json.dumps(body))
|
|
5807
|
+
|
|
5808
|
+
def batch_get_all_data_metrics_v2(self, user_id, scope, region, dimensions, metric_names, statistics,
|
|
5809
|
+
start_time, end_time, type="Instance", cycle=60):
|
|
5810
|
+
|
|
5811
|
+
"""
|
|
5812
|
+
:param user_id: user_id
|
|
5813
|
+
:type string
|
|
5814
|
+
|
|
5815
|
+
:param scope: scope
|
|
5816
|
+
:type string
|
|
5817
|
+
|
|
5818
|
+
:param region: region
|
|
5819
|
+
:type string
|
|
5820
|
+
|
|
5821
|
+
:param dimensions: dimensions
|
|
5822
|
+
:type double dimensional dict array
|
|
5823
|
+
|
|
5824
|
+
:param metric_names: metric names
|
|
5825
|
+
:type string array
|
|
5826
|
+
|
|
5827
|
+
:param statistics: statistics
|
|
5828
|
+
:type string array
|
|
5829
|
+
|
|
5830
|
+
:param start_time: start time
|
|
5831
|
+
:type string
|
|
5832
|
+
|
|
5833
|
+
:param end_time: end time
|
|
5834
|
+
:type string
|
|
5835
|
+
|
|
5836
|
+
:param type: type
|
|
5837
|
+
:type string
|
|
5838
|
+
|
|
5839
|
+
:param cycle: cycle
|
|
5840
|
+
:type int
|
|
5841
|
+
:return:
|
|
5842
|
+
"""
|
|
5843
|
+
if len(user_id) <= 0:
|
|
5844
|
+
raise ValueError("user_id should not be null")
|
|
5845
|
+
if len(scope) <= 0:
|
|
5846
|
+
raise ValueError("scope should not be null")
|
|
5847
|
+
if len(region) <= 0:
|
|
5848
|
+
raise ValueError("region should not be null")
|
|
5849
|
+
if len(metric_names) <= 0:
|
|
5850
|
+
raise ValueError("metric_names should not be null")
|
|
5851
|
+
if len(dimensions) <= 0:
|
|
5852
|
+
raise ValueError("dimensions should not be null")
|
|
5853
|
+
if len(statistics) <= 0:
|
|
5854
|
+
raise ValueError("statistics should not be null")
|
|
5855
|
+
if len(dimensions) > MAX_INSTANCE_NUMBER:
|
|
5856
|
+
raise ValueError("dimensions size cannot more than " + MAX_INSTANCE_NUMBER)
|
|
5857
|
+
body = {
|
|
5858
|
+
"userId": user_id,
|
|
5859
|
+
"scope": scope,
|
|
5860
|
+
"cycle": cycle,
|
|
5861
|
+
"region": region,
|
|
5862
|
+
"startTime": start_time,
|
|
5863
|
+
"endTime": end_time,
|
|
5864
|
+
"metricNames": metric_names,
|
|
5865
|
+
"dimensions": dimensions,
|
|
5866
|
+
"statistics": statistics
|
|
5867
|
+
}
|
|
5868
|
+
if type is not None:
|
|
5869
|
+
body["type"] = type
|
|
5870
|
+
|
|
5871
|
+
path = b'/data/metricAllData/batch'
|
|
5872
|
+
return self._send_csm_request(http_methods.POST, path, version=b'/v2', body=json.dumps(body))
|
|
5873
|
+
|
|
5874
|
+
|
|
@@ -56,8 +56,6 @@ FETCH_MODE_ASYNC = b"async"
|
|
|
56
56
|
|
|
57
57
|
ENCRYPTION_ALGORITHM= "AES256"
|
|
58
58
|
|
|
59
|
-
DEFAULT_BOS_DOMAIN_SUFFIX = b'bcebos.com'
|
|
60
|
-
|
|
61
59
|
HTTP_PROTOCOL_HEAD = b'http'
|
|
62
60
|
|
|
63
61
|
|
|
@@ -1120,6 +1118,7 @@ class BosClient(BceBaseClient):
|
|
|
1120
1118
|
user_headers=None,
|
|
1121
1119
|
progress_callback=None,
|
|
1122
1120
|
traffic_limit=None,
|
|
1121
|
+
object_tagging=None,
|
|
1123
1122
|
config=None):
|
|
1124
1123
|
"""
|
|
1125
1124
|
Put an appendable object to BOS or add content to an appendable object
|
|
@@ -1145,7 +1144,8 @@ class BosClient(BceBaseClient):
|
|
|
1145
1144
|
user_metadata=user_metadata,
|
|
1146
1145
|
storage_class=storage_class,
|
|
1147
1146
|
user_headers=user_headers,
|
|
1148
|
-
traffic_limit=traffic_limit
|
|
1147
|
+
traffic_limit=traffic_limit,
|
|
1148
|
+
object_tagging=object_tagging)
|
|
1149
1149
|
|
|
1150
1150
|
if content_length > bos.MAX_APPEND_OBJECT_LENGTH:
|
|
1151
1151
|
raise ValueError('Object length should be less than %d. '
|
|
@@ -1232,6 +1232,7 @@ class BosClient(BceBaseClient):
|
|
|
1232
1232
|
customer_key_md5=None,
|
|
1233
1233
|
progress_callback=None,
|
|
1234
1234
|
traffic_limit=None,
|
|
1235
|
+
object_tagging=None,
|
|
1235
1236
|
config=None):
|
|
1236
1237
|
"""
|
|
1237
1238
|
Put object and put content of file to the object
|
|
@@ -1261,7 +1262,8 @@ class BosClient(BceBaseClient):
|
|
|
1261
1262
|
user_metadata=user_metadata,
|
|
1262
1263
|
storage_class=storage_class,
|
|
1263
1264
|
user_headers=user_headers,
|
|
1264
|
-
traffic_limit=traffic_limit
|
|
1265
|
+
traffic_limit=traffic_limit,
|
|
1266
|
+
object_tagging=object_tagging,)
|
|
1265
1267
|
|
|
1266
1268
|
buf_size = self._get_config_parameter(config, 'recv_buf_size')
|
|
1267
1269
|
|
|
@@ -1293,6 +1295,7 @@ class BosClient(BceBaseClient):
|
|
|
1293
1295
|
customer_key_md5=None,
|
|
1294
1296
|
progress_callback=None,
|
|
1295
1297
|
traffic_limit=None,
|
|
1298
|
+
object_tagging=None,
|
|
1296
1299
|
config=None):
|
|
1297
1300
|
"""
|
|
1298
1301
|
Create object and put content of string to the object
|
|
@@ -1334,6 +1337,7 @@ class BosClient(BceBaseClient):
|
|
|
1334
1337
|
customer_key_md5=customer_key_md5,
|
|
1335
1338
|
progress_callback = progress_callback,
|
|
1336
1339
|
traffic_limit=traffic_limit,
|
|
1340
|
+
object_tagging=object_tagging,
|
|
1337
1341
|
config=config)
|
|
1338
1342
|
finally:
|
|
1339
1343
|
if fp is not None:
|
|
@@ -1353,6 +1357,7 @@ class BosClient(BceBaseClient):
|
|
|
1353
1357
|
customer_key_md5=None,
|
|
1354
1358
|
progress_callback=None,
|
|
1355
1359
|
traffic_limit=None,
|
|
1360
|
+
object_tagging=None,
|
|
1356
1361
|
config=None,
|
|
1357
1362
|
):
|
|
1358
1363
|
|
|
@@ -1399,6 +1404,7 @@ class BosClient(BceBaseClient):
|
|
|
1399
1404
|
customer_key_md5=customer_key_md5,
|
|
1400
1405
|
progress_callback=progress_callback,
|
|
1401
1406
|
traffic_limit=traffic_limit,
|
|
1407
|
+
object_tagging=object_tagging,
|
|
1402
1408
|
config=config)
|
|
1403
1409
|
finally:
|
|
1404
1410
|
fp.close()
|
|
@@ -1417,6 +1423,7 @@ class BosClient(BceBaseClient):
|
|
|
1417
1423
|
user_headers=None,
|
|
1418
1424
|
copy_object_user_headers=None,
|
|
1419
1425
|
traffic_limit=None,
|
|
1426
|
+
object_tagging=None,
|
|
1420
1427
|
config=None):
|
|
1421
1428
|
"""
|
|
1422
1429
|
Copy one object to another object
|
|
@@ -1442,7 +1449,8 @@ class BosClient(BceBaseClient):
|
|
|
1442
1449
|
user_metadata=user_metadata,
|
|
1443
1450
|
storage_class=storage_class,
|
|
1444
1451
|
user_headers=user_headers,
|
|
1445
|
-
traffic_limit=traffic_limit
|
|
1452
|
+
traffic_limit=traffic_limit,
|
|
1453
|
+
object_tagging=object_tagging)
|
|
1446
1454
|
headers[http_headers.BCE_COPY_SOURCE] = utils.normalize_string(
|
|
1447
1455
|
b'/%s/%s' % (
|
|
1448
1456
|
compat.convert_to_bytes(source_bucket_name),
|
|
@@ -2434,6 +2442,74 @@ class BosClient(BceBaseClient):
|
|
|
2434
2442
|
params={b'mirroring': b''},
|
|
2435
2443
|
config=config,
|
|
2436
2444
|
)
|
|
2445
|
+
|
|
2446
|
+
def put_object_tagging(self, bucket_name, key, obj_tag_args, config=None):
|
|
2447
|
+
"""
|
|
2448
|
+
put object tagging
|
|
2449
|
+
|
|
2450
|
+
:type bucket_name: string
|
|
2451
|
+
:param bucket_name: bucket name
|
|
2452
|
+
|
|
2453
|
+
:type key: string
|
|
2454
|
+
:param key: object name
|
|
2455
|
+
|
|
2456
|
+
:type obj_tag_args: dict
|
|
2457
|
+
:param obj_tag_args: object tagging args
|
|
2458
|
+
|
|
2459
|
+
:return:
|
|
2460
|
+
"""
|
|
2461
|
+
return self._send_request(
|
|
2462
|
+
http_methods.PUT,
|
|
2463
|
+
bucket_name=bucket_name,
|
|
2464
|
+
key=key,
|
|
2465
|
+
body=json.dumps(obj_tag_args, default=BosClient._dump_acl_object),
|
|
2466
|
+
params={b'tagging': b''},
|
|
2467
|
+
config=config,)
|
|
2468
|
+
|
|
2469
|
+
def put_object_tagging_canned(self, bucket_name, key, tag_header, config=None):
|
|
2470
|
+
"""
|
|
2471
|
+
put object tagging
|
|
2472
|
+
|
|
2473
|
+
:type bucket_name: string
|
|
2474
|
+
:param bucket_name: bucket name
|
|
2475
|
+
|
|
2476
|
+
:type key: string
|
|
2477
|
+
:param key: object name
|
|
2478
|
+
|
|
2479
|
+
:type obj_tag_args: dict
|
|
2480
|
+
:param obj_tag_args: object tagging args
|
|
2481
|
+
|
|
2482
|
+
:return:
|
|
2483
|
+
"""
|
|
2484
|
+
headers = {}
|
|
2485
|
+
headers[http_headers.BOS_TAGGING] = compat.convert_to_bytes(tag_header)
|
|
2486
|
+
return self._send_request(
|
|
2487
|
+
http_methods.PUT,
|
|
2488
|
+
bucket_name=bucket_name,
|
|
2489
|
+
key=key,
|
|
2490
|
+
headers=headers,
|
|
2491
|
+
params={b'tagging': b''},
|
|
2492
|
+
config=config,)
|
|
2493
|
+
|
|
2494
|
+
def get_object_tagging(self, bucket_name, key, config=None):
|
|
2495
|
+
"""
|
|
2496
|
+
put object tagging
|
|
2497
|
+
|
|
2498
|
+
:type bucket_name: string
|
|
2499
|
+
:param bucket_name: bucket name
|
|
2500
|
+
|
|
2501
|
+
:type key: string
|
|
2502
|
+
:param key: object name
|
|
2503
|
+
|
|
2504
|
+
:return:
|
|
2505
|
+
"""
|
|
2506
|
+
return self._send_request(
|
|
2507
|
+
http_methods.GET,
|
|
2508
|
+
bucket_name=bucket_name,
|
|
2509
|
+
key=key,
|
|
2510
|
+
params={b'tagging': b''},
|
|
2511
|
+
config=config,)
|
|
2512
|
+
|
|
2437
2513
|
|
|
2438
2514
|
|
|
2439
2515
|
@staticmethod
|
|
@@ -2449,7 +2525,8 @@ class BosClient(BceBaseClient):
|
|
|
2449
2525
|
encryption=None,
|
|
2450
2526
|
customer_key=None,
|
|
2451
2527
|
customer_key_md5=None,
|
|
2452
|
-
traffic_limit=None
|
|
2528
|
+
traffic_limit=None,
|
|
2529
|
+
object_tagging=None,):
|
|
2453
2530
|
headers = {}
|
|
2454
2531
|
|
|
2455
2532
|
if content_length is not None:
|
|
@@ -2509,6 +2586,8 @@ class BosClient(BceBaseClient):
|
|
|
2509
2586
|
if traffic_limit is not None:
|
|
2510
2587
|
headers[http_headers.BOS_TRAFFIC_LIMIT] = traffic_limit
|
|
2511
2588
|
|
|
2589
|
+
if object_tagging is not None:
|
|
2590
|
+
headers[http_headers.BOS_TAGGING] = compat.convert_to_bytes(object_tagging)
|
|
2512
2591
|
return headers
|
|
2513
2592
|
|
|
2514
2593
|
|
|
@@ -2548,38 +2627,71 @@ class BosClient(BceBaseClient):
|
|
|
2548
2627
|
host = config.endpoint
|
|
2549
2628
|
if use_backup_endpoint:
|
|
2550
2629
|
host = config.backup_endpoint
|
|
2551
|
-
|
|
2630
|
+
endpoint_protocol, host_name, endpoint_port = \
|
|
2631
|
+
utils.parse_host_port(config.endpoint, config.protocol)
|
|
2632
|
+
if config.cname_enabled or utils.is_cname_like_host(host_name) or utils.is_custom_host(host_name, bucket_name):
|
|
2552
2633
|
return utils.append_uri(bos.URL_PREFIX, key)
|
|
2553
2634
|
return utils.append_uri(bos.URL_PREFIX, bucket_name, key)
|
|
2635
|
+
|
|
2554
2636
|
|
|
2555
2637
|
def _merge_config(self, config, bucket_name):
|
|
2556
|
-
# if config is None:
|
|
2557
|
-
# return self.config
|
|
2558
|
-
# else:
|
|
2559
|
-
# new_config = copy.copy(self.config)
|
|
2560
|
-
# new_config.merge_non_none_values(config)
|
|
2561
|
-
# return new_config
|
|
2562
|
-
|
|
2563
2638
|
new_config = copy.copy(self.config)
|
|
2564
2639
|
if config is not None:
|
|
2565
2640
|
new_config.merge_non_none_values(config)
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2641
|
+
|
|
2642
|
+
endpoint = self._change_user_endpoint(new_config, bucket_name)
|
|
2643
|
+
new_config.endpoint = endpoint
|
|
2644
|
+
return new_config
|
|
2645
|
+
|
|
2646
|
+
|
|
2647
|
+
def _change_user_endpoint(self, config, bucket_name):
|
|
2648
|
+
endpoint_protocol, user_host_name, endpoint_port = \
|
|
2649
|
+
utils.parse_host_port(config.endpoint, config.protocol)
|
|
2650
|
+
user_endpoint_split = compat.convert_to_bytes(user_host_name).split(b'.')
|
|
2651
|
+
user_endpoint = config.endpoint
|
|
2652
|
+
is_bos_path_style_host = utils.is_bos_suffixed_host(user_host_name) and len(user_endpoint_split) == 3
|
|
2653
|
+
# 1. check ipv4 or path style
|
|
2654
|
+
if utils.check_ipv4(user_host_name):
|
|
2655
|
+
return config.endpoint
|
|
2656
|
+
|
|
2657
|
+
if config.path_style_enable:
|
|
2658
|
+
# check path style
|
|
2659
|
+
if is_bos_path_style_host:
|
|
2660
|
+
return config.endpoint
|
|
2661
|
+
else:
|
|
2662
|
+
raise ValueError(
|
|
2663
|
+
'endpoint is not path style, please set path_style_enable=False')
|
|
2664
|
+
|
|
2665
|
+
# 2. check cname domain
|
|
2666
|
+
if config.cname_enabled or utils.is_cname_like_host(user_host_name):
|
|
2667
|
+
# cname domain
|
|
2668
|
+
if is_bos_path_style_host:
|
|
2669
|
+
raise ValueError(
|
|
2670
|
+
'endpoint is not cname domain, please set cname_enabled=False')
|
|
2671
|
+
else:
|
|
2672
|
+
return config.endpoint
|
|
2673
|
+
|
|
2674
|
+
# default use virtual-hosted endpoint
|
|
2675
|
+
if bucket_name is not None:
|
|
2676
|
+
if is_bos_path_style_host:
|
|
2570
2677
|
# split http head
|
|
2571
2678
|
if user_endpoint.startswith(HTTP_PROTOCOL_HEAD):
|
|
2572
2679
|
http_head_split = user_endpoint.split(b'//')
|
|
2573
2680
|
if len(http_head_split) < 2:
|
|
2574
|
-
return
|
|
2681
|
+
return config.endpoint
|
|
2575
2682
|
bucket_endpoint = http_head_split[0] + b'//' + compat.convert_to_bytes(bucket_name) +\
|
|
2576
2683
|
b'.' + http_head_split[1]
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2684
|
+
return compat.convert_to_bytes(bucket_endpoint)
|
|
2685
|
+
else:
|
|
2686
|
+
return compat.convert_to_bytes(bucket_name)+b'.'+\
|
|
2687
|
+
compat.convert_to_bytes(user_endpoint)
|
|
2688
|
+
|
|
2689
|
+
# check virtual-hosted endpoint's bucket_name is not query bucket_name
|
|
2690
|
+
if len(user_endpoint_split) == 4 and bucket_name is not None:
|
|
2691
|
+
if user_endpoint_split[0] != compat.convert_to_bytes(bucket_name):
|
|
2692
|
+
raise ValueError('your endpoint\'s bucket_name is not equal your query bucket_name!')
|
|
2693
|
+
|
|
2694
|
+
return config.endpoint
|
|
2583
2695
|
|
|
2584
2696
|
@staticmethod
|
|
2585
2697
|
def _need_retry_backup_endpoint(error):
|
baidubce/utils.py
CHANGED
|
@@ -38,6 +38,7 @@ from baidubce.http import http_headers
|
|
|
38
38
|
import codecs
|
|
39
39
|
|
|
40
40
|
DEFAULT_CNAME_LIKE_LIST = [b".cdn.bcebos.com"]
|
|
41
|
+
DEFAULT_BOS_DOMAIN_SUFFIX = b'bcebos.com'
|
|
41
42
|
HTTP_PROTOCOL_HEAD = b'http'
|
|
42
43
|
|
|
43
44
|
def get_md5_from_fp(fp, offset=0, length=-1, buf_size=8192):
|
|
@@ -558,14 +559,35 @@ def is_custom_host(host, bucket_name):
|
|
|
558
559
|
"""
|
|
559
560
|
if host is None or bucket_name is None:
|
|
560
561
|
return False
|
|
561
|
-
|
|
562
|
+
|
|
563
|
+
host_split = host.split(b'.')
|
|
562
564
|
# split http head
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
565
|
+
return host.lower().startswith(compat.convert_to_bytes(bucket_name.lower())) \
|
|
566
|
+
and len(host_split) == 4 and is_bos_suffixed_host(host)
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
def is_bos_suffixed_host(host):
|
|
570
|
+
"""
|
|
571
|
+
:param host: bos endpoint
|
|
572
|
+
:return: bos endpoint or not
|
|
573
|
+
"""
|
|
574
|
+
if host is None:
|
|
567
575
|
return False
|
|
568
|
-
|
|
576
|
+
if host.endswith(b'/'):
|
|
577
|
+
check_host = host[:-1]
|
|
578
|
+
else:
|
|
579
|
+
check_host = host
|
|
580
|
+
|
|
581
|
+
return check_host.lower().endswith(DEFAULT_BOS_DOMAIN_SUFFIX)
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
def check_ipv4(ipAddr):
|
|
585
|
+
"""
|
|
586
|
+
:param ipAddr: ip address
|
|
587
|
+
:return: true or false
|
|
588
|
+
"""
|
|
589
|
+
compile_ip=re.compile(b'((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}')
|
|
590
|
+
return compile_ip.match(ipAddr)
|
|
569
591
|
|
|
570
592
|
def _get_data_size(data):
|
|
571
593
|
if hasattr(data, '__len__'):
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
baidubce/__init__.py,sha256=
|
|
1
|
+
baidubce/__init__.py,sha256=4pnkvyMrf76aBZjNydEF6C7ykK7BcgF4sJ0epzwkj5w,813
|
|
2
2
|
baidubce/bce_base_client.py,sha256=7gjkRy_YlTTb6TXHYHyZRYMjdVO7FTtHMdwXx8bPgsE,3428
|
|
3
|
-
baidubce/bce_client_configuration.py,sha256=
|
|
3
|
+
baidubce/bce_client_configuration.py,sha256=Wzuu9JR11hcHxgcKQIP63qIChEzVrT9ZA_fyqIfqqP4,3055
|
|
4
4
|
baidubce/bce_response.py,sha256=V5a3bgRj04cM3Ml3s1OByLyZZSGDUy9PL52JSugmCgM,1655
|
|
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
|
|
8
8
|
baidubce/region.py,sha256=h4PypdsGeQYM8F5pUCXobY68aSOVEsoRA0c6PN0Mn_g,835
|
|
9
|
-
baidubce/utils.py,sha256=
|
|
9
|
+
baidubce/utils.py,sha256=ypgd7jbJ8Yau_0xAcwibu6Z6_smTc6XlGziU1YDatoE,20194
|
|
10
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=f3jwZe9cCbSELJrlI-h4QP_ArjgfwsGuLGSIOHDC_2E,3211
|
|
@@ -14,7 +14,7 @@ baidubce/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
14
14
|
baidubce/http/bce_http_client.py,sha256=hf7UpjEHq7aeo5bRXaBrPWUCptA4GQOZRIjllA1zQGU,9877
|
|
15
15
|
baidubce/http/handler.py,sha256=FGotEXyM24t93E2Z4n9dJV9XD34im-gdmq8JDyncZA8,2930
|
|
16
16
|
baidubce/http/http_content_types.py,sha256=tHTGDR9nK5beD9HmJ4Iwj42fc9avsMpJELbb6UdKtkQ,722
|
|
17
|
-
baidubce/http/http_headers.py,sha256=
|
|
17
|
+
baidubce/http/http_headers.py,sha256=tVhXo3XGLTMbxQl5Db3kY2RBP4Om5OMwlU39k-zeOS4,2659
|
|
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
|
|
@@ -27,12 +27,12 @@ baidubce/services/bbc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
|
|
|
27
27
|
baidubce/services/bbc/bbc_client.py,sha256=9jcIyysPYv9iLj0qD-NSENHmNZs7Lsfb3F1khqb__2I,35864
|
|
28
28
|
baidubce/services/bbc/bbc_model.py,sha256=Dx7HoUw73Uk3I2dxBL188-3i4pbt5v-8SZe4T1K99dg,1595
|
|
29
29
|
baidubce/services/bcc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
|
-
baidubce/services/bcc/bcc_client.py,sha256=
|
|
30
|
+
baidubce/services/bcc/bcc_client.py,sha256=MTbQR-2KLoTnILhZYG9cMd7MPGZTtZYEkOX8XGVn71s,233985
|
|
31
31
|
baidubce/services/bcc/bcc_model.py,sha256=7v5WzqDDhl7MmI3vDdOuyM5S9isxkKoaIv5RAqzzTRI,5919
|
|
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
|
|
35
|
-
baidubce/services/bcm/bcm_client.py,sha256=
|
|
35
|
+
baidubce/services/bcm/bcm_client.py,sha256=XMlto3h2u0wxwfSeQNjqbbLgFMAnIyVK6Y_8agtr9zM,209237
|
|
36
36
|
baidubce/services/bcm/bcm_handler.py,sha256=UK_wuEykhXHIFSQr-5mcIvXf356xvPnju2XiN7U7GsM,3315
|
|
37
37
|
baidubce/services/bcm/bcm_model.py,sha256=cJKyuS9c4Lf_4j0Nl8ECjoWBLN31qDiT0eKbMcxlZtA,22095
|
|
38
38
|
baidubce/services/bes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -45,7 +45,7 @@ baidubce/services/blb/user_service_client.py,sha256=bS8SKQKslvoSefVVl76A6cgvqyZn
|
|
|
45
45
|
baidubce/services/bmr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
46
46
|
baidubce/services/bmr/bmr_client.py,sha256=ntJie-R6qFxdd6znpfCj25RSoJ6gOV0o2Tn9asJThQg,20565
|
|
47
47
|
baidubce/services/bos/__init__.py,sha256=bRvJAiFjUIBF64HeoZ7bkTjGfqkKJAvxYWBSEvbUOIc,813
|
|
48
|
-
baidubce/services/bos/bos_client.py,sha256=
|
|
48
|
+
baidubce/services/bos/bos_client.py,sha256=Ch3X7c11tjI_oXGnL8vAfVH3zu-jBYI5wNfgxZr2LqY,100010
|
|
49
49
|
baidubce/services/bos/bos_handler.py,sha256=ZWVjezraJsdNy0tsX8fZkWPmSBYLSlGolKqZ1CcWE7A,1832
|
|
50
50
|
baidubce/services/bos/canned_acl.py,sha256=Y2qvU81OI_nT0uu96MyTemXyR2EnNVVYrJxfPS1rhBA,723
|
|
51
51
|
baidubce/services/bos/storage_class.py,sha256=RiwV9b6N6dHFzNG6k4LUhjLngqfC837FWUvP-mr5BZ8,729
|
|
@@ -166,7 +166,7 @@ baidubce/services/vpc/vpc_client.py,sha256=6HD-TIxmNPujzIVc37Z9OOp_JUOoITUPzTwjm
|
|
|
166
166
|
baidubce/services/vpn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
167
167
|
baidubce/services/vpn/vpn_client.py,sha256=VGmPmnl7Il_NcbGMAgASmVK_1IF9HQ8PJ-WLij-7Axc,28554
|
|
168
168
|
baidubce/services/vpn/vpn_model.py,sha256=r9V2At9ll9cZTOryGflS9tH9DlHdeelKYuGXvTNyTgg,3364
|
|
169
|
-
bce_python_sdk-0.9.
|
|
170
|
-
bce_python_sdk-0.9.
|
|
171
|
-
bce_python_sdk-0.9.
|
|
172
|
-
bce_python_sdk-0.9.
|
|
169
|
+
bce_python_sdk-0.9.6.dist-info/METADATA,sha256=d4aQYNpBTVPTUbjz8gTDAMNu4N3Dlt-7jLNgxFzm2pw,318
|
|
170
|
+
bce_python_sdk-0.9.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
171
|
+
bce_python_sdk-0.9.6.dist-info/top_level.txt,sha256=Oh6eo_-T_AuEDpIaR54biUUPThxsoQiYMVHLBTaweQs,9
|
|
172
|
+
bce_python_sdk-0.9.6.dist-info/RECORD,,
|
|
File without changes
|