Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions alibabacloud_oss_v2/models/object_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ def __init__(
request_payer: Optional[str] = None,
body: Optional[BodyType] = None,
progress_fn: Optional[Any] = None,
object_acl: Optional[str] = None,
**kwargs: Any
) -> None:
"""
Args:
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.
Expand All @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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:
"""
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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:
"""
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -1368,22 +1383,27 @@ def __init__(
acl: Optional[str] = None,
version_id: Optional[str] = None,
request_payer: Optional[str] = None,
object_acl: Optional[str] = None,
**kwargs: Any
) -> None:
"""
Args:
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
self.key = key
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):
Expand Down Expand Up @@ -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:
"""
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -2388,19 +2413,25 @@ 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:
"""
Args:
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
Expand All @@ -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):
Expand Down Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion sample/put_object_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},'
Expand Down
96 changes: 96 additions & 0 deletions tests/unit/models/test_object_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
Loading