From fd88f0bf51027e4c12eaf9625bb0d313b904f83e Mon Sep 17 00:00:00 2001 From: zhuxiaolong37 Date: Thu, 6 Nov 2025 18:21:42 +0800 Subject: [PATCH] Modify the parameters objectAcl and symlinkTarget --- alibabacloud_oss_v2/models/object_basic.py | 40 +++++++++ sample/put_object_acl.py | 2 +- tests/unit/models/test_object_basic.py | 96 ++++++++++++++++++++++ 3 files changed, 137 insertions(+), 1 deletion(-) diff --git a/alibabacloud_oss_v2/models/object_basic.py b/alibabacloud_oss_v2/models/object_basic.py index 3ad5e94..5f1fc86 100644 --- a/alibabacloud_oss_v2/models/object_basic.py +++ b/alibabacloud_oss_v2/models/object_basic.py @@ -63,6 +63,7 @@ def __init__( request_payer: Optional[str] = None, body: Optional[BodyType] = None, progress_fn: Optional[Any] = None, + object_acl: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -70,6 +71,7 @@ def __init__( bucket (str, required): The name of the bucket. key (str, required): The name of the object. acl (str, optional): The access control list (ACL) of the object. + This parameter is deprecated. Use 'object_acl' parameter instead storage_class (str, optional): The storage class of the object. metadata (MutableMapping,The metadata of the object that you want to upload. cache_control (str, optional): The caching behavior of the web page when the object is downloaded. @@ -96,6 +98,7 @@ def __init__( request_payer (str, optional): To indicate that the requester is aware that the request and data download will incur costs. body (BodyType,optional): Object data. progress_fn (Any,optional): Progress callback function. + object_acl (str, optional): The access control list (ACL) of the object. """ super().__init__(**kwargs) self.bucket = bucket @@ -121,6 +124,8 @@ def __init__( self.request_payer = request_payer self.body = body self.progress_fn = progress_fn + if object_acl is not None: + self.acl = object_acl class PutObjectResult(serde.ResultModel): @@ -650,6 +655,7 @@ def __init__( request_payer: Optional[str] = None, body: Optional[BodyType] = None, progress_fn: Optional[Any] = None, + object_acl: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -660,6 +666,7 @@ def __init__( Each time an AppendObject operation succeeds, the x-oss-next-append-position header is included in the response to specify the position from which the next AppendObject operation starts. acl (str, optional): The access control list (ACL) of the object. + This parameter is deprecated. Use 'object_acl' parameter instead storage_class (str, optional): The storage class of the object. metadata (MutableMapping,The metadata of the object that you want to upload. cache_control (str, optional): The caching behavior of the web page when the object is downloaded. @@ -686,6 +693,7 @@ def __init__( request_payer (str, optional): To indicate that the requester is aware that the request and data download will incur costs. body (BodyType,optional): Object data. progress_fn (Any,optional): Progress callback function. + object_acl (str, optional): The access control list (ACL) of the object. """ super().__init__(**kwargs) self.bucket = bucket @@ -710,6 +718,8 @@ def __init__( self.request_payer = request_payer self.body = body self.progress_fn = progress_fn + if object_acl is not None: + self.acl = object_acl class AppendObjectResult(serde.ResultModel): @@ -823,6 +833,7 @@ def __init__( traffic_limit: Optional[int] = None, request_payer: Optional[str] = None, progress_fn: Optional[Any] = None, + object_acl: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -844,6 +855,7 @@ def __init__( the object modified time, the object and 200 OK are returned. Otherwise, 412 Precondition Failed is returned. The time must be in GMT. Example: Fri, 13 Nov 2015 14:47:53 GMT. acl (str, optional): The access control list (ACL) of the object. + This parameter is deprecated. Use 'object_acl' parameter instead storage_class (str, optional): The storage class of the object. metadata (MutableMapping,The metadata of the object that you want to upload. cache_control (str, optional): The caching behavior of the web page when the object is downloaded. @@ -877,6 +889,7 @@ def __init__( The speed limit value ranges from 245760 to 838860800, with a unit of bit/s. request_payer (str, optional): To indicate that the requester is aware that the request and data download will incur costs. progress_fn (Any,optional): Progress callback function, it works in Copier.copy only. + object_acl (str, optional): The access control list (ACL) of the object. """ super().__init__(**kwargs) self.bucket = bucket @@ -908,6 +921,8 @@ def __init__( self.traffic_limit = traffic_limit self.request_payer = request_payer self.progress_fn = progress_fn + if object_acl is not None: + self.acl = object_acl class CopyObjectResult(serde.ResultModel): @@ -1368,6 +1383,7 @@ def __init__( acl: Optional[str] = None, version_id: Optional[str] = None, request_payer: Optional[str] = None, + object_acl: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -1375,8 +1391,10 @@ def __init__( bucket (str, required): The name of the bucket. key (str, required): The name of the object. acl (str, required): The access control list (ACL) of the object. + This parameter is deprecated. Use 'object_acl' parameter instead version_id (str, optional): The version ID of the source object. request_payer (str, optional): To indicate that the requester is aware that the request and data download will incur costs + object_acl (str, optional): The access control list (ACL) of the object. """ super().__init__(**kwargs) self.bucket = bucket @@ -1384,6 +1402,8 @@ def __init__( self.acl = acl self.version_id = version_id self.request_payer = request_payer + if object_acl is not None: + self.acl = object_acl class PutObjectAclResult(serde.ResultModel): @@ -1900,6 +1920,7 @@ def __init__( forbid_overwrite: Optional[bool] = None, encoding_type: Optional[str] = None, request_payer: Optional[str] = None, + object_acl: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -1908,6 +1929,7 @@ def __init__( key (str, required): The name of the object. upload_id (str, optional): The ID of the multipart upload task. acl (str, optional): The access control list (ACL) of the object. + This parameter is deprecated. Use 'object_acl' parameter instead complete_multipart_upload (CompleteMultipartUpload, optional): The container that stores the content of the CompleteMultipartUpload complete_all (str, optional): Specifies whether to list all parts that are uploaded by using the current upload ID. Valid value: yes @@ -1917,6 +1939,7 @@ def __init__( overwrites an existing object that has the same name. encoding_type (str, optional): The encoding type of the object names in the response. Valid value: url. request_payer (str, optional): To indicate that the requester is aware that the request and data download will incur costs. + object_acl (str, optional): The access control list (ACL) of the object. """ super().__init__(**kwargs) self.bucket = bucket @@ -1930,6 +1953,8 @@ def __init__( self.forbid_overwrite = forbid_overwrite self.encoding_type = encoding_type self.request_payer = request_payer + if object_acl is not None: + self.acl = object_acl class CompleteMultipartUploadResult(serde.ResultModel): @@ -2388,6 +2413,8 @@ def __init__( metadata: Optional[MutableMapping] = None, forbid_overwrite: Optional[bool] = None, request_payer: Optional[str] = None, + object_acl: Optional[str] = None, + symlink_target: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -2395,12 +2422,16 @@ def __init__( bucket (str, required): The name of the bucket. key (str, required): The name of the object. target (str, required): The destination object to which the symbolic link points. + This parameter is deprecated. Use 'symlink_target' parameter instead acl (str, optional): The access control list (ACL) of the object. + This parameter is deprecated. Use 'object_acl' parameter instead storage_class (str, optional): The storage class of the object. metadata (MutableMapping,The metadata of the object that you want to upload. forbid_overwrite (bool, optional): Specifies whether the object that is uploaded by calling the PutObject operation overwrites an existing object that has the same name. request_payer (str, optional): To indicate that the requester is aware that the request and data download will incur costs. + object_acl (str, optional): The access control list (ACL) of the object. + symlink_target (str, optional): The destination object to which the symbolic link points. """ super().__init__(**kwargs) self.bucket = bucket @@ -2411,6 +2442,10 @@ def __init__( self.metadata = metadata self.forbid_overwrite = forbid_overwrite self.request_payer = request_payer + if object_acl is not None: + self.acl = object_acl + if symlink_target is not None: + self.target = symlink_target class PutSymlinkResult(serde.ResultModel): @@ -2480,21 +2515,26 @@ def __init__( target: Optional[str] = None, etag: Optional[str] = None, metadata: Optional[MutableMapping] = None, + symlink_target: Optional[str] = None, **kwargs: Any ) -> None: """ Args: version_id (str, optional): Version of the object. target (str, optional): Indicates the target object that the symbol link directs to. + This parameter is deprecated. Use 'symlink_target' parameter instead etag (str, optional): The entity tag (ETag). An ETag is created when an object is created to identify the content of the object. metadata (MutableMapping, optional): A map of metadata to store with the object. + symlink_target (str, optional): The destination object to which the symbolic link points. """ super().__init__(**kwargs) self.version_id = version_id self.target = target self.etag = etag self.metadata = metadata + if symlink_target is not None: + self.target = symlink_target class Tag(serde.Model): """The inforamtion about the tag.""" diff --git a/sample/put_object_acl.py b/sample/put_object_acl.py index d85749d..1470ecf 100644 --- a/sample/put_object_acl.py +++ b/sample/put_object_acl.py @@ -28,7 +28,7 @@ def main(): result = client.put_object_acl(oss.PutObjectAclRequest( bucket=args.bucket, key=args.key, - acl=args.acl, + object_acl=args.acl, )) print(f'status code: {result.status_code},' diff --git a/tests/unit/models/test_object_basic.py b/tests/unit/models/test_object_basic.py index 8c05cb9..20356d0 100644 --- a/tests/unit/models/test_object_basic.py +++ b/tests/unit/models/test_object_basic.py @@ -110,6 +110,16 @@ def test_constructor_request(self): self.assertEqual('key-test', request.key) self.assertFalse(hasattr(request, 'invalid_field')) + # Test deprecated parameter + request = model.PutObjectRequest( + bucket='bucket-test', + key='key-test', + object_acl='public-read', + ) + self.assertEqual('bucket-test', request.bucket) + self.assertEqual('key-test', request.key) + self.assertEqual('public-read', request.acl) + request = model.PutObjectRequest( bucket='bucket-test', key='key-test', @@ -841,6 +851,18 @@ def test_constructor_request(self): self.assertEqual(0, request.position) self.assertFalse(hasattr(request, 'invalid_field')) + # Test deprecated parameter + request = model.AppendObjectRequest( + bucket='bucket_name', + key='example-object-2.jpg', + position=0, + object_acl='public-read', + ) + self.assertEqual('bucket_name', request.bucket) + self.assertEqual('example-object-2.jpg', request.key) + self.assertEqual(0, request.position) + self.assertEqual('public-read', request.acl) + request = model.AppendObjectRequest( bucket='bucket_name', key='example-object-2.jpg', @@ -1075,6 +1097,18 @@ def test_constructor_request(self): self.assertEqual('source-invalid-key', request.source_key) self.assertFalse(hasattr(request, 'invalid_field')) + # Test deprecated parameter + request = model.CopyObjectRequest( + bucket='bucket_name', + key='example-object-2.jpg', + source_key='source-invalid-key', + object_acl='public-read', + ) + self.assertEqual('bucket_name', request.bucket) + self.assertEqual('example-object-2.jpg', request.key) + self.assertEqual('source-invalid-key', request.source_key) + self.assertEqual('public-read', request.acl) + request = model.CopyObjectRequest( bucket='bucket_name', key='example-object-2.jpg', @@ -1844,6 +1878,26 @@ def test_constructor_request(self): self.assertEqual('private', request.acl) self.assertFalse(hasattr(request, 'invalid_field')) + # Test deprecated parameter + request = model.PutObjectAclRequest( + bucket='bucket_name', + key='example-object-2.jpg', + object_acl='public-read', + ) + self.assertEqual('bucket_name', request.bucket) + self.assertEqual('example-object-2.jpg', request.key) + self.assertEqual('public-read', request.acl) + + # Test deprecated parameter + request = model.PutObjectAclRequest( + bucket='bucket_name', + key='example-object-2.jpg', + object_acl='public-read', + ) + self.assertEqual('bucket_name', request.bucket) + self.assertEqual('example-object-2.jpg', request.key) + self.assertEqual('public-read', request.acl) + request = model.PutObjectAclRequest( bucket='bucket_name', key='example-object-2.jpg', @@ -2654,6 +2708,18 @@ def test_constructor_request(self): self.assertEqual('0004B9894A22E5B1888A1E29F823****', request.upload_id) self.assertFalse(hasattr(request, 'invalid_field')) + # Test deprecated parameter + request = model.CompleteMultipartUploadRequest( + bucket='bucket_name', + key='example-object-2.jpg', + upload_id='0004B9894A22E5B1888A1E29F823****', + object_acl='public-read', + ) + self.assertEqual('bucket_name', request.bucket) + self.assertEqual('example-object-2.jpg', request.key) + self.assertEqual('0004B9894A22E5B1888A1E29F823****', request.upload_id) + self.assertEqual('public-read', request.acl) + request = model.CompleteMultipartUploadRequest( bucket='bucket_name', key='example-object-2.jpg', @@ -3378,6 +3444,30 @@ def test_constructor_request(self): self.assertEqual('KbGMxddWss', request.target) self.assertFalse(hasattr(request, 'invalid_field')) + # Test deprecated parameters + request = model.PutSymlinkRequest( + bucket='bucket_name', + key='example-object-2.jpg', + symlink_target='target-object', + object_acl='private', + ) + self.assertEqual('bucket_name', request.bucket) + self.assertEqual('example-object-2.jpg', request.key) + self.assertEqual('target-object', request.target) + self.assertEqual('private', request.acl) + + # Test deprecated parameters + request = model.PutSymlinkRequest( + bucket='bucket_name', + key='example-object-2.jpg', + symlink_target='target-object', + object_acl='private', + ) + self.assertEqual('bucket_name', request.bucket) + self.assertEqual('example-object-2.jpg', request.key) + self.assertEqual('target-object', request.target) + self.assertEqual('private', request.acl) + request = model.PutSymlinkRequest( bucket='bucket_name', key='example-object-2.jpg', @@ -3569,6 +3659,12 @@ def test_constructor_result(self): self.assertEqual("AES/CTR/NoPadding", result.metadata.get("client-side-encryption-cek-alg")) self.assertEqual("RSA/NONE/PKCS1Padding", result.metadata.get("client-side-encryption-wrap-alg")) + # Test deprecated parameter + result = model.GetSymlinkResult( + symlink_target='target-object', + ) + self.assertEqual('target-object', result.target) + result = model.GetSymlinkResult( version_id='CAEQNhiBgMDJgZCA0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY0****', invalid_field='invalid_field',