bce-python-sdk 0.9.71__py3-none-any.whl → 0.9.76__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 -0
- baidubce/http/http_headers.py +2 -0
- baidubce/services/aihc/modules/job/job_client.py +24 -9
- baidubce/services/bcc/bcc_client.py +53 -8
- baidubce/services/bos/bos_client.py +33 -7
- baidubce/services/bos/bos_handler.py +4 -0
- baidubce/services/bos/common.py +2 -0
- baidubce/services/csn/csn_api.py +1 -0
- baidubce/services/csn/csn_client.py +6 -1
- baidubce/services/dumemory/__init__.py +14 -0
- baidubce/services/dumemory/dumemory_client.py +610 -0
- baidubce/services/dumemory/dumemory_model.py +313 -0
- baidubce/services/dumemory/test_dumemory_client.py +931 -0
- baidubce/services/et/et_client.py +196 -31
- baidubce/services/etGateway/et_gateway_client.py +24 -4
- baidubce/services/vpc/nat_client.py +28 -26
- {bce_python_sdk-0.9.71.dist-info → bce_python_sdk-0.9.76.dist-info}/METADATA +4 -1
- {bce_python_sdk-0.9.71.dist-info → bce_python_sdk-0.9.76.dist-info}/RECORD +21 -17
- {bce_python_sdk-0.9.71.dist-info → bce_python_sdk-0.9.76.dist-info}/WHEEL +1 -1
- {bce_python_sdk-0.9.71.dist-info → bce_python_sdk-0.9.76.dist-info}/top_level.txt +0 -0
baidubce/__init__.py
CHANGED
|
@@ -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
|
"""
|
baidubce/http/http_headers.py
CHANGED
|
@@ -126,6 +126,8 @@ BOS_TAG_LIST = b"x-bce-tag-list"
|
|
|
126
126
|
|
|
127
127
|
BOS_PROCESS = b"x-bce-process"
|
|
128
128
|
|
|
129
|
+
BOS_REQUEST_PAYER = b"x-bce-request-payer"
|
|
130
|
+
|
|
129
131
|
BOS_BASE_ALLOW_HEADERS = set([BOS_TRAFFIC_LIMIT, BOS_VERSIONING, BOS_TAGGING, BOS_PROCESS, BOS_OBJECT_EXPIRES])
|
|
130
132
|
|
|
131
133
|
BOS_IF_MATCH = b"If-Match"
|
|
@@ -25,7 +25,6 @@ class JobClient(AIHCBaseClient):
|
|
|
25
25
|
def DescribeJobs(
|
|
26
26
|
self,
|
|
27
27
|
resourcePoolId,
|
|
28
|
-
queueID=None,
|
|
29
28
|
queue=None,
|
|
30
29
|
status=None,
|
|
31
30
|
keywordType=None,
|
|
@@ -42,7 +41,6 @@ class JobClient(AIHCBaseClient):
|
|
|
42
41
|
|
|
43
42
|
Args:
|
|
44
43
|
resourcePoolId: 注意区分资源池类型,自运维资源池传递资源池唯一标识(示例:cce-1uji3ib5),托管资源池固定传递 aihc-serverless(必填)
|
|
45
|
-
queueID: 托管资源池需传入该参数,为队列Id(可选,Query参数)
|
|
46
44
|
queue: 训练任务所属队列,通用资源池须填入队列名称,不填时返回所有。托管资源池须填入队列Id(可选,Body参数)
|
|
47
45
|
status: 基于状态筛选任务(可选,Body参数)
|
|
48
46
|
keywordType: 筛选关键字类型(可选,Body参数)
|
|
@@ -64,8 +62,6 @@ class JobClient(AIHCBaseClient):
|
|
|
64
62
|
'action': 'DescribeJobs',
|
|
65
63
|
'resourcePoolId': resourcePoolId,
|
|
66
64
|
}
|
|
67
|
-
if queueID:
|
|
68
|
-
params['queueID'] = queueID
|
|
69
65
|
|
|
70
66
|
body = {}
|
|
71
67
|
if queue is not None:
|
|
@@ -130,7 +126,7 @@ class JobClient(AIHCBaseClient):
|
|
|
130
126
|
body['needDetail'] = needDetail
|
|
131
127
|
return self._send_job_request(http_methods.POST, path, body=json.dumps(body), params=params)
|
|
132
128
|
|
|
133
|
-
def DeleteJob(self, resourcePoolId, jobId):
|
|
129
|
+
def DeleteJob(self, resourcePoolId, queueID, jobId):
|
|
134
130
|
"""
|
|
135
131
|
删除训练任务。
|
|
136
132
|
|
|
@@ -138,8 +134,8 @@ class JobClient(AIHCBaseClient):
|
|
|
138
134
|
|
|
139
135
|
Args:
|
|
140
136
|
resourcePoolId: 注意区分资源池类型,自运维资源池传递资源池唯一标识(示例:cce-1uji3ib5),托管资源池固定传递 aihc-serverless(必填)
|
|
137
|
+
queueID: 训练任务所属队列,自运维资源池须填入队列名称,托管资源池须填入队列Id(必填,Query参数)
|
|
141
138
|
jobId: 训练任务ID(必填,Body参数)
|
|
142
|
-
jobId: string
|
|
143
139
|
|
|
144
140
|
Returns:
|
|
145
141
|
baidubce.bce_response.BceResponse: 删除任务结果
|
|
@@ -152,13 +148,14 @@ class JobClient(AIHCBaseClient):
|
|
|
152
148
|
params = {
|
|
153
149
|
'action': 'DeleteJob',
|
|
154
150
|
'resourcePoolId': resourcePoolId,
|
|
151
|
+
'queueID': queueID,
|
|
155
152
|
}
|
|
156
153
|
body = {
|
|
157
154
|
'jobId': jobId,
|
|
158
155
|
}
|
|
159
156
|
return self._send_job_request(http_methods.POST, path, body=json.dumps(body), params=params)
|
|
160
157
|
|
|
161
|
-
def ModifyJob(self, resourcePoolId, jobId, priority):
|
|
158
|
+
def ModifyJob(self, resourcePoolId, queueID, jobId, priority):
|
|
162
159
|
"""
|
|
163
160
|
更新训练任务。
|
|
164
161
|
|
|
@@ -166,6 +163,7 @@ class JobClient(AIHCBaseClient):
|
|
|
166
163
|
|
|
167
164
|
Args:
|
|
168
165
|
resourcePoolId: 注意区分资源池类型,自运维资源池传递资源池唯一标识(示例:cce-1uji3ib5),托管资源池固定传递 aihc-serverless(必填)
|
|
166
|
+
queueID: 训练任务所属队列,自运维资源池须填入队列名称,托管资源池须填入队列Id(必填,Query参数)
|
|
169
167
|
jobId: 训练任务ID(必填,Body参数)
|
|
170
168
|
priority: 优先级(必填,Body参数),如 "normal"
|
|
171
169
|
|
|
@@ -180,6 +178,7 @@ class JobClient(AIHCBaseClient):
|
|
|
180
178
|
params = {
|
|
181
179
|
'action': 'ModifyJob',
|
|
182
180
|
'resourcePoolId': resourcePoolId,
|
|
181
|
+
'queueID': queueID,
|
|
183
182
|
}
|
|
184
183
|
body = {
|
|
185
184
|
'jobId': jobId,
|
|
@@ -190,6 +189,7 @@ class JobClient(AIHCBaseClient):
|
|
|
190
189
|
def DescribeJobEvents(
|
|
191
190
|
self,
|
|
192
191
|
resourcePoolId,
|
|
192
|
+
queueID,
|
|
193
193
|
jobId,
|
|
194
194
|
startTime=None,
|
|
195
195
|
endTime=None
|
|
@@ -201,6 +201,7 @@ class JobClient(AIHCBaseClient):
|
|
|
201
201
|
|
|
202
202
|
Args:
|
|
203
203
|
resourcePoolId: 注意区分资源池类型,自运维资源池传递资源池唯一标识(示例:cce-1uji3ib5),托管资源池固定传递 aihc-serverless(必填)
|
|
204
|
+
queueID: 训练任务所属队列,自运维资源池须填入队列名称,托管资源池须填入队列Id(必填,Query参数)
|
|
204
205
|
jobId: 训练任务ID(必填,Body参数)
|
|
205
206
|
startTime: 获取任务事件的起始时间(可选,Body参数)
|
|
206
207
|
endTime: 获取任务事件的结束时间(可选,Body参数)
|
|
@@ -216,6 +217,7 @@ class JobClient(AIHCBaseClient):
|
|
|
216
217
|
params = {
|
|
217
218
|
'action': 'DescribeJobEvents',
|
|
218
219
|
'resourcePoolId': resourcePoolId,
|
|
220
|
+
'queueID': queueID,
|
|
219
221
|
}
|
|
220
222
|
body = {
|
|
221
223
|
'jobId': jobId,
|
|
@@ -229,6 +231,7 @@ class JobClient(AIHCBaseClient):
|
|
|
229
231
|
def DescribeJobLogs(
|
|
230
232
|
self,
|
|
231
233
|
resourcePoolId,
|
|
234
|
+
queueID,
|
|
232
235
|
jobId,
|
|
233
236
|
podName,
|
|
234
237
|
keywords=None,
|
|
@@ -245,6 +248,7 @@ class JobClient(AIHCBaseClient):
|
|
|
245
248
|
|
|
246
249
|
Args:
|
|
247
250
|
resourcePoolId: 注意区分资源池类型,自运维资源池传递资源池唯一标识(示例:cce-1uji3ib5),托管资源池固定传递 aihc-serverless(必填)
|
|
251
|
+
queueID: 训练任务所属队列,自运维资源池须填入队列名称,托管资源池须填入队列Id(必填,Query参数)
|
|
248
252
|
jobId: 训练任务ID(必填,Body参数)
|
|
249
253
|
podName: Pod名称(必填,Body参数)
|
|
250
254
|
keywords: 日志查询关键字(可选,Body参数)
|
|
@@ -265,6 +269,7 @@ class JobClient(AIHCBaseClient):
|
|
|
265
269
|
params = {
|
|
266
270
|
'action': 'DescribeJobLogs',
|
|
267
271
|
'resourcePoolId': resourcePoolId,
|
|
272
|
+
'queueID': queueID,
|
|
268
273
|
}
|
|
269
274
|
body = {
|
|
270
275
|
'jobId': jobId,
|
|
@@ -294,6 +299,7 @@ class JobClient(AIHCBaseClient):
|
|
|
294
299
|
def DescribeJobPodEvents(
|
|
295
300
|
self,
|
|
296
301
|
resourcePoolId,
|
|
302
|
+
queueID,
|
|
297
303
|
jobId,
|
|
298
304
|
podName,
|
|
299
305
|
startTime=None,
|
|
@@ -306,6 +312,7 @@ class JobClient(AIHCBaseClient):
|
|
|
306
312
|
|
|
307
313
|
Args:
|
|
308
314
|
resourcePoolId: 注意区分资源池类型,自运维资源池传递资源池唯一标识(示例:cce-1uji3ib5),托管资源池固定传递 aihc-serverless(必填)
|
|
315
|
+
queueID: 训练任务所属队列,自运维资源池须填入队列名称,托管资源池须填入队列Id(必填,Query参数)
|
|
309
316
|
jobId: 训练任务ID(必填,Body参数)
|
|
310
317
|
podName: 训练任务节点名称(必填,Body参数)
|
|
311
318
|
startTime: 事件起始时间,Unix时间格式(可选,Body参数)
|
|
@@ -322,6 +329,7 @@ class JobClient(AIHCBaseClient):
|
|
|
322
329
|
params = {
|
|
323
330
|
'action': 'DescribePodEvents',
|
|
324
331
|
'resourcePoolId': resourcePoolId,
|
|
332
|
+
'queueID': queueID,
|
|
325
333
|
}
|
|
326
334
|
body = {
|
|
327
335
|
'jobId': jobId,
|
|
@@ -339,7 +347,7 @@ class JobClient(AIHCBaseClient):
|
|
|
339
347
|
params=params
|
|
340
348
|
)
|
|
341
349
|
|
|
342
|
-
def StopJob(self, resourcePoolId, jobId):
|
|
350
|
+
def StopJob(self, resourcePoolId, queueID, jobId):
|
|
343
351
|
"""
|
|
344
352
|
停止训练任务。
|
|
345
353
|
|
|
@@ -347,6 +355,7 @@ class JobClient(AIHCBaseClient):
|
|
|
347
355
|
|
|
348
356
|
Args:
|
|
349
357
|
resourcePoolId: 注意区分资源池类型,自运维资源池传递资源池唯一标识(示例:cce-1uji3ib5),托管资源池固定传递 aihc-serverless(必填)
|
|
358
|
+
queueID: 训练任务所属队列,自运维资源池须填入队列名称,托管资源池须填入队列Id(必填,Query参数)
|
|
350
359
|
jobId: 训练任务ID(必填,Body参数)
|
|
351
360
|
|
|
352
361
|
Returns:
|
|
@@ -360,6 +369,7 @@ class JobClient(AIHCBaseClient):
|
|
|
360
369
|
params = {
|
|
361
370
|
'action': 'StopJob',
|
|
362
371
|
'resourcePoolId': resourcePoolId,
|
|
372
|
+
'queueID': queueID,
|
|
363
373
|
}
|
|
364
374
|
body = {
|
|
365
375
|
'jobId': jobId,
|
|
@@ -371,7 +381,7 @@ class JobClient(AIHCBaseClient):
|
|
|
371
381
|
params=params
|
|
372
382
|
)
|
|
373
383
|
|
|
374
|
-
def DescribeJobNodes(self, resourcePoolId, jobId):
|
|
384
|
+
def DescribeJobNodes(self, resourcePoolId, queueID, jobId):
|
|
375
385
|
"""
|
|
376
386
|
查询训练任务所在节点列表。
|
|
377
387
|
|
|
@@ -379,6 +389,7 @@ class JobClient(AIHCBaseClient):
|
|
|
379
389
|
|
|
380
390
|
Args:
|
|
381
391
|
resourcePoolId: 注意区分资源池类型,自运维资源池传递资源池唯一标识(示例:cce-1uji3ib5),托管资源池固定传递 aihc-serverless(必填)
|
|
392
|
+
queueID: 训练任务所属队列,自运维资源池须填入队列名称,托管资源池须填入队列Id(必填,Query参数)
|
|
382
393
|
jobId: 训练任务ID(必填,Body参数)
|
|
383
394
|
|
|
384
395
|
Returns:
|
|
@@ -392,6 +403,7 @@ class JobClient(AIHCBaseClient):
|
|
|
392
403
|
params = {
|
|
393
404
|
'action': 'DescribeJobNodes',
|
|
394
405
|
'resourcePoolId': resourcePoolId,
|
|
406
|
+
'queueID': queueID,
|
|
395
407
|
}
|
|
396
408
|
body = {
|
|
397
409
|
'jobId': jobId,
|
|
@@ -406,6 +418,7 @@ class JobClient(AIHCBaseClient):
|
|
|
406
418
|
def DescribeJobWebterminal(
|
|
407
419
|
self,
|
|
408
420
|
resourcePoolId,
|
|
421
|
+
queueID,
|
|
409
422
|
jobId,
|
|
410
423
|
podName,
|
|
411
424
|
handshakeTimeoutSecond=None,
|
|
@@ -418,6 +431,7 @@ class JobClient(AIHCBaseClient):
|
|
|
418
431
|
|
|
419
432
|
Args:
|
|
420
433
|
resourcePoolId: 注意区分资源池类型,自运维资源池传递资源池唯一标识(示例:cce-1uji3ib5),托管资源池固定传递 aihc-serverless(必填)
|
|
434
|
+
queueID: 训练任务所属队列,自运维资源池须填入队列名称,托管资源池须填入队列Id(必填,Query参数)
|
|
421
435
|
jobId: 训练任务ID(必填,Body参数)
|
|
422
436
|
podName: 训练任务节点名称(必填,Body参数)
|
|
423
437
|
handshakeTimeoutSecond: 连接超时参数,单位秒(可选,Body参数)
|
|
@@ -434,6 +448,7 @@ class JobClient(AIHCBaseClient):
|
|
|
434
448
|
params = {
|
|
435
449
|
'action': 'DescribeJobWebterminal',
|
|
436
450
|
'resourcePoolId': resourcePoolId,
|
|
451
|
+
'queueID': queueID,
|
|
437
452
|
}
|
|
438
453
|
body = {
|
|
439
454
|
'jobId': jobId,
|
|
@@ -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:
|
|
@@ -1908,7 +1915,7 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
1908
1915
|
|
|
1909
1916
|
@required(instance_id=(bytes, str),
|
|
1910
1917
|
tags=list)
|
|
1911
|
-
def bind_instance_to_tags(self, instance_id, tags, attachRelatedResourceTag, config=None):
|
|
1918
|
+
def bind_instance_to_tags(self, instance_id, tags, attachRelatedResourceTag=None, config=None):
|
|
1912
1919
|
"""
|
|
1913
1920
|
:param instance_id:
|
|
1914
1921
|
:param tags:
|
|
@@ -1920,9 +1927,10 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
1920
1927
|
path = b'/instance/%s/tag' % instance_id
|
|
1921
1928
|
tag_list = [tag.__dict__ for tag in tags]
|
|
1922
1929
|
body = {
|
|
1923
|
-
'changeTags': tag_list
|
|
1924
|
-
'attachRelatedResourceTag': attachRelatedResourceTag
|
|
1930
|
+
'changeTags': tag_list
|
|
1925
1931
|
}
|
|
1932
|
+
if attachRelatedResourceTag is not None:
|
|
1933
|
+
body['attachRelatedResourceTag'] = attachRelatedResourceTag
|
|
1926
1934
|
params = {
|
|
1927
1935
|
'bind': None
|
|
1928
1936
|
}
|
|
@@ -1931,7 +1939,7 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
1931
1939
|
|
|
1932
1940
|
@required(instance_id=(bytes, str),
|
|
1933
1941
|
tags=list)
|
|
1934
|
-
def unbind_instance_from_tags(self, instance_id, tags, attachRelatedResourceTag, config=None):
|
|
1942
|
+
def unbind_instance_from_tags(self, instance_id, tags, attachRelatedResourceTag=None, config=None):
|
|
1935
1943
|
"""
|
|
1936
1944
|
:param instance_id:
|
|
1937
1945
|
:param tags:
|
|
@@ -1943,9 +1951,10 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
1943
1951
|
path = b'/instance/%s/tag' % instance_id
|
|
1944
1952
|
tag_list = [tag.__dict__ for tag in tags]
|
|
1945
1953
|
body = {
|
|
1946
|
-
'changeTags': tag_list
|
|
1947
|
-
'attachRelatedResourceTag': attachRelatedResourceTag
|
|
1954
|
+
'changeTags': tag_list
|
|
1948
1955
|
}
|
|
1956
|
+
if attachRelatedResourceTag is not None:
|
|
1957
|
+
body['attachRelatedResourceTag'] = attachRelatedResourceTag
|
|
1949
1958
|
params = {
|
|
1950
1959
|
'unbind': None
|
|
1951
1960
|
}
|
|
@@ -2059,7 +2068,7 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
2059
2068
|
description=None, renew_time_unit=None, renew_time=None,
|
|
2060
2069
|
cluster_id=None, relation_tag=False,
|
|
2061
2070
|
tags=None, auto_snapshot_policy=None,
|
|
2062
|
-
client_token=None, config=None, charge_type=None):
|
|
2071
|
+
client_token=None, config=None, charge_type=None, enable_delete_protection=None):
|
|
2063
2072
|
"""
|
|
2064
2073
|
Create a volume with the specified options.
|
|
2065
2074
|
You can use this method to create a new empty volume by specified options
|
|
@@ -2145,6 +2154,10 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
2145
2154
|
If the instance is post paid, create a post paid CDS
|
|
2146
2155
|
:type charge_type: menu{'Prepaid', 'Postpaid'}
|
|
2147
2156
|
|
|
2157
|
+
:param enable_delete_protection:
|
|
2158
|
+
The optional parameter to specify whether to enable delete protection.
|
|
2159
|
+
:type enable_delete_protection: boolean
|
|
2160
|
+
|
|
2148
2161
|
:return:
|
|
2149
2162
|
:rtype baidubce.bce_response.BceResponse
|
|
2150
2163
|
"""
|
|
@@ -2189,6 +2202,8 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
2189
2202
|
body['instanceId'] = instance_id
|
|
2190
2203
|
if charge_type is not None:
|
|
2191
2204
|
body['chargeType'] = charge_type
|
|
2205
|
+
if enable_delete_protection is not None:
|
|
2206
|
+
body['enableDeleteProtection'] = enable_delete_protection
|
|
2192
2207
|
return self._send_request(http_methods.POST, path, json.dumps(body),
|
|
2193
2208
|
params=params, config=config)
|
|
2194
2209
|
|
|
@@ -4151,7 +4166,7 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
4151
4166
|
hosteye_type=None, res_group_id=None, enable_ht=None, data_partition_type=None,
|
|
4152
4167
|
root_partition_type=None, file_systems=None, disable_root_disk_serial=None,
|
|
4153
4168
|
internal_ips=None, network_purchase_type=None, is_keep_image_login=None,
|
|
4154
|
-
reserved_instance=None, is_eip_auto_related_delete=None):
|
|
4169
|
+
reserved_instance=None, is_eip_auto_related_delete=None, enable_delete_protection=None):
|
|
4155
4170
|
"""
|
|
4156
4171
|
Create a bcc Instance with the specified options.
|
|
4157
4172
|
You must fill the field of clientToken,which is especially for keeping idempotent.
|
|
@@ -4419,6 +4434,10 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
4419
4434
|
The default value is False.
|
|
4420
4435
|
:type is_eip_auto_related_delete: boolean
|
|
4421
4436
|
|
|
4437
|
+
:param enable_delete_protection:
|
|
4438
|
+
The optional parameter to specify whether to enable delete protection.
|
|
4439
|
+
:type enable_delete_protection: boolean
|
|
4440
|
+
|
|
4422
4441
|
:return:
|
|
4423
4442
|
:rtype baidubce.bce_response.BceResponse
|
|
4424
4443
|
"""
|
|
@@ -4546,6 +4565,8 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
4546
4565
|
body['keepImageLogin'] = is_keep_image_login
|
|
4547
4566
|
if reserved_instance is not None:
|
|
4548
4567
|
body['reservedInstance'] = reserved_instance
|
|
4568
|
+
if enable_delete_protection is not None:
|
|
4569
|
+
body['enableDeleteProtection'] = enable_delete_protection
|
|
4549
4570
|
return self._send_request(http_methods.POST, path, json.dumps(body),
|
|
4550
4571
|
params=params, config=config)
|
|
4551
4572
|
|
|
@@ -7235,6 +7256,30 @@ class BccClient(bce_base_client.BceBaseClient):
|
|
|
7235
7256
|
return self._send_request(http_methods.POST, path, json.dumps(body),
|
|
7236
7257
|
params=params, config=config)
|
|
7237
7258
|
|
|
7259
|
+
def modify_volume_delete_protection(self, volume_ids, enable_delete_protection, client_token=None, config=None):
|
|
7260
|
+
"""
|
|
7261
|
+
modify_volume_delete_protection
|
|
7262
|
+
|
|
7263
|
+
:param volume_ids:
|
|
7264
|
+
A list of volume ids.
|
|
7265
|
+
:type volume_ids: list<bcc_model.VolumeIdModel>
|
|
7266
|
+
|
|
7267
|
+
:param enable_delete_protection:
|
|
7268
|
+
enable_delete_protection
|
|
7269
|
+
:type enable_delete_protection: bool
|
|
7270
|
+
"""
|
|
7271
|
+
path = b'/volume/modifyDeleteProtection'
|
|
7272
|
+
params = {}
|
|
7273
|
+
if client_token is None:
|
|
7274
|
+
params['clientToken'] = generate_client_token()
|
|
7275
|
+
else:
|
|
7276
|
+
params['clientToken'] = client_token
|
|
7277
|
+
body = {
|
|
7278
|
+
'volumeIds': volume_ids,
|
|
7279
|
+
'enableDeleteProtection': enable_delete_protection
|
|
7280
|
+
}
|
|
7281
|
+
return self._send_request(http_methods.POST, path, json.dumps(body), params=params, config=config)
|
|
7282
|
+
|
|
7238
7283
|
def create_snapshot_share(self, snapshot_id, account_ids, client_token=None, config=None):
|
|
7239
7284
|
"""
|
|
7240
7285
|
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
|
|
@@ -732,8 +734,10 @@ class BosClient(BceBaseClient):
|
|
|
732
734
|
raise ValueError('generate url the key param error!')
|
|
733
735
|
|
|
734
736
|
config = self._merge_config(config, bucket_name)
|
|
735
|
-
headers = headers
|
|
736
|
-
params = params
|
|
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)
|
|
737
741
|
|
|
738
742
|
# specified protocol in endpoint > protocal > default protocol in config
|
|
739
743
|
if protocol is not None:
|
|
@@ -755,6 +759,9 @@ class BosClient(BceBaseClient):
|
|
|
755
759
|
full_host += b':' + compat.convert_to_bytes(endpoint_port)
|
|
756
760
|
headers[http_headers.HOST] = full_host
|
|
757
761
|
|
|
762
|
+
if config.request_payer is True:
|
|
763
|
+
params[http_headers.BOS_REQUEST_PAYER] = common.REQUEST_PAYER_REQUESTER
|
|
764
|
+
|
|
758
765
|
path = self._get_path(config, bucket_name, key)
|
|
759
766
|
if httpmethod != http_methods.GET and httpmethod != http_methods.HEAD:
|
|
760
767
|
headers_to_sign = set([b'host'])
|
|
@@ -1623,6 +1630,7 @@ class BosClient(BceBaseClient):
|
|
|
1623
1630
|
"""
|
|
1624
1631
|
source_key = compat.convert_to_bytes(source_key)
|
|
1625
1632
|
target_key = compat.convert_to_bytes(target_key)
|
|
1633
|
+
bos_handler.validate_object_key(source_key)
|
|
1626
1634
|
headers = self._prepare_object_headers(
|
|
1627
1635
|
content_type=content_type,
|
|
1628
1636
|
user_metadata=user_metadata,
|
|
@@ -1942,6 +1950,7 @@ class BosClient(BceBaseClient):
|
|
|
1942
1950
|
"""
|
|
1943
1951
|
source_key = compat.convert_to_bytes(source_key)
|
|
1944
1952
|
target_key = compat.convert_to_bytes(target_key)
|
|
1953
|
+
bos_handler.validate_object_key(source_key)
|
|
1945
1954
|
headers = self._prepare_object_headers(
|
|
1946
1955
|
content_type=content_type,
|
|
1947
1956
|
user_metadata=user_metadata,
|
|
@@ -2219,7 +2228,7 @@ class BosClient(BceBaseClient):
|
|
|
2219
2228
|
raise e
|
|
2220
2229
|
|
|
2221
2230
|
@required(bucket_name=(bytes, str), key=(bytes, str), file_name=(bytes, str))
|
|
2222
|
-
def put_super_object_from_file(self, bucket_name, key, file_name, chunk_size=
|
|
2231
|
+
def put_super_object_from_file(self, bucket_name, key, file_name, chunk_size=None,
|
|
2223
2232
|
thread_num=None,
|
|
2224
2233
|
uploadTaskHandle=None,
|
|
2225
2234
|
content_type=None,
|
|
@@ -2236,15 +2245,26 @@ class BosClient(BceBaseClient):
|
|
|
2236
2245
|
"""
|
|
2237
2246
|
Multipart Upload file to bos
|
|
2238
2247
|
|
|
2239
|
-
param chunk_size: part size , default
|
|
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.
|
|
2240
2251
|
"""
|
|
2241
|
-
# check params
|
|
2242
|
-
if chunk_size > 5 * 1024 or chunk_size <= 0:
|
|
2243
|
-
raise BceClientError("chunk size is valid, it should be more than 0 and not nore than 5120!")
|
|
2244
2252
|
left_size = os.path.getsize(file_name)
|
|
2245
2253
|
# if file size more than 48.8TB, reject
|
|
2246
2254
|
if left_size > 50000 * 1024 * 1024 * 1024:
|
|
2247
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!")
|
|
2248
2268
|
if thread_num is None or thread_num <= 1:
|
|
2249
2269
|
thread_num = multiprocessing.cpu_count()
|
|
2250
2270
|
part_size = chunk_size * 1024 * 1024
|
|
@@ -3342,6 +3362,8 @@ class BosClient(BceBaseClient):
|
|
|
3342
3362
|
body=None, headers=None, params=None,
|
|
3343
3363
|
config=None, body_parser=None):
|
|
3344
3364
|
bos_handler.validate_bucket_name(bucket_name)
|
|
3365
|
+
if key is not None:
|
|
3366
|
+
bos_handler.validate_object_key(key)
|
|
3345
3367
|
config = self._merge_config(config, bucket_name)
|
|
3346
3368
|
|
|
3347
3369
|
path = BosClient._get_path(config, bucket_name, key)
|
|
@@ -3352,6 +3374,10 @@ class BosClient(BceBaseClient):
|
|
|
3352
3374
|
headers = headers or {}
|
|
3353
3375
|
headers[http_headers.STS_SECURITY_TOKEN] = config.security_token
|
|
3354
3376
|
|
|
3377
|
+
if config.request_payer is True:
|
|
3378
|
+
headers = headers or {}
|
|
3379
|
+
headers[http_headers.BOS_REQUEST_PAYER] = common.REQUEST_PAYER_REQUESTER
|
|
3380
|
+
|
|
3355
3381
|
last_exception = None
|
|
3356
3382
|
e = None
|
|
3357
3383
|
# record the initial position of fp body before any request attempt,
|
|
@@ -99,6 +99,10 @@ def validate_object_key(key):
|
|
|
99
99
|
raise ValueError("Invalid object key: key is not valid UTF-8: %s" % e)
|
|
100
100
|
if not key:
|
|
101
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
|
+
|
|
102
106
|
for segment in key.split('/'):
|
|
103
107
|
if segment == '..':
|
|
104
108
|
raise ValueError(
|
baidubce/services/bos/common.py
CHANGED
baidubce/services/csn/csn_api.py
CHANGED
|
@@ -1065,7 +1065,7 @@ class CsnClient(bce_base_client.BceBaseClient):
|
|
|
1065
1065
|
return self._send_request(api_config["method"], quote(api_config["path"]).encode("utf8"), api_config["headers"],
|
|
1066
1066
|
api_config["queries"], json.dumps(body))
|
|
1067
1067
|
|
|
1068
|
-
def update_tgw(self, csn_id=None, tgw_id=None, update_tgw_request=None):
|
|
1068
|
+
def update_tgw(self, csn_id=None, tgw_id=None, update_tgw_request=None, client_token=None):
|
|
1069
1069
|
"""
|
|
1070
1070
|
更新TGW的名称、描述。
|
|
1071
1071
|
|
|
@@ -1081,6 +1081,10 @@ class CsnClient(bce_base_client.BceBaseClient):
|
|
|
1081
1081
|
:desc
|
|
1082
1082
|
:type update_tgw_request: json
|
|
1083
1083
|
|
|
1084
|
+
:param client_token:
|
|
1085
|
+
:desc 幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性
|
|
1086
|
+
:type client_token: str
|
|
1087
|
+
|
|
1084
1088
|
:return:
|
|
1085
1089
|
:rtype baidubce.bce_response.BceResponse
|
|
1086
1090
|
"""
|
|
@@ -1088,6 +1092,7 @@ class CsnClient(bce_base_client.BceBaseClient):
|
|
|
1088
1092
|
api_config = self._get_config(csn_apis, "update_tgw")
|
|
1089
1093
|
self._add_path_param(api_config, "csnId", csn_id)
|
|
1090
1094
|
self._add_path_param(api_config, "tgwId", tgw_id)
|
|
1095
|
+
self._add_query(api_config, "clientToken", client_token)
|
|
1091
1096
|
|
|
1092
1097
|
return self._send_request(api_config["method"], quote(api_config["path"]).encode("utf8"), api_config["headers"],
|
|
1093
1098
|
api_config["queries"], json.dumps(update_tgw_request))
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Copyright 2026 Baidu, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
|
4
|
+
# except in compliance with the License. You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# Unless required by applicable law or agreed to in writing, software distributed under the
|
|
9
|
+
# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
10
|
+
# either express or implied. See the License for the specific language governing permissions
|
|
11
|
+
# and limitations under the License.
|
|
12
|
+
"""
|
|
13
|
+
DuMemory (Cloud Memory) service package.
|
|
14
|
+
"""
|