@@ -835,6 +835,23 @@ def delete_bucket(self, bucket: str, **params) -> None:
835835 _logger .debug (f"Delete bucket: s3://{ bucket } " )
836836 self .call (self ._client .delete_bucket , Bucket = bucket , ** params )
837837
838+ def get_bucket_versioning (self , bucket : str , ** params ) -> str | None :
839+ """Get the versioning state of a bucket with GetBucketVersioning.
840+
841+ Args:
842+ bucket: The name of the bucket.
843+ **params: Additional request parameters, sent as given.
844+
845+ Returns:
846+ ``Enabled`` or ``Suspended``, or None if versioning has never
847+ been enabled on the bucket.
848+
849+ Raises:
850+ FileNotFoundError: If the bucket does not exist.
851+ """
852+ response = self .call (self ._client .get_bucket_versioning , Bucket = bucket , ** params )
853+ return cast (str | None , response .get ("Status" ))
854+
838855 def delete_object (self , path : S3Path , ** params ) -> None :
839856 """Delete an object, or a version of it, with DeleteObject.
840857
@@ -1266,7 +1283,7 @@ def plan_multipart_copy(
12661283 request .pop ("Tagging" , None )
12671284 # Directory buckets do not support GetObjectTagging, and their
12681285 # objects have no tags.
1269- if not self . _is_directory_bucket ( source .bucket ) :
1286+ if not source .is_directory_bucket :
12701287 tags = self .get_object_tagging (
12711288 source , ** self .operation_params ("get_object_tagging" , source_params )
12721289 )
@@ -1290,7 +1307,7 @@ def plan_multipart_copy(
12901307 )
12911308 if annotation_directive == "COPY"
12921309 and "CopySourceSSECustomerAlgorithm" not in params
1293- and not self . _is_directory_bucket ( source .bucket )
1310+ and not source .is_directory_bucket
12941311 else ()
12951312 )
12961313 return S3MultipartCopyPlan (
@@ -1604,20 +1621,6 @@ def generate_presigned_url(
16041621 ),
16051622 )
16061623
1607- @staticmethod
1608- def _is_directory_bucket (bucket : str ) -> bool :
1609- """Return whether the bucket is a directory bucket (S3 Express One Zone).
1610-
1611- Directory bucket names end with ``--x-s3``.
1612-
1613- Args:
1614- bucket: S3 bucket name.
1615-
1616- Returns:
1617- True if the bucket is a directory bucket.
1618- """
1619- return bucket .endswith ("--x-s3" )
1620-
16211624 @staticmethod
16221625 def _copy_source_params (params : Mapping [str , Any ]) -> dict [str , Any ]:
16231626 """Map the parameters of a copy to those of the requests that read its source.
0 commit comments