From 94c60c50127d6e9a6037fed24dc307e240f9c79c Mon Sep 17 00:00:00 2001 From: Bala FA Date: Wed, 18 Dec 2024 08:20:01 +0530 Subject: [PATCH] Add NewerNoncurrentVersions in LifecycleConfig (#1469) Signed-off-by: Bala.FA --- .github/workflows/ci.yml | 2 +- minio/lifecycleconfig.py | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e913729ac..22963d982 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13.0"] os: [ubuntu-latest, windows-latest, macos-latest] steps: diff --git a/minio/lifecycleconfig.py b/minio/lifecycleconfig.py index 2c3064434..d332c4094 100644 --- a/minio/lifecycleconfig.py +++ b/minio/lifecycleconfig.py @@ -118,9 +118,11 @@ def __init__( self, noncurrent_days: int | None = None, storage_class: str | None = None, + newer_noncurrent_versions: int | None = None, ): self._noncurrent_days = noncurrent_days self._storage_class = storage_class + self._newer_noncurrent_versions = newer_noncurrent_versions @property def noncurrent_days(self) -> int | None: @@ -132,6 +134,11 @@ def storage_class(self) -> str | None: """Get storage class.""" return self._storage_class + @property + def newer_noncurrent_versions(self) -> int | None: + """Get Newer Noncurrent versions.""" + return self._newer_noncurrent_versions + @classmethod def fromxml(cls: Type[B], element: ET.Element) -> B: """Create new object with values from XML element.""" @@ -140,9 +147,11 @@ def fromxml(cls: Type[B], element: ET.Element) -> B: find(element, "NoncurrentVersionTransition", True), ) noncurrent_days = findtext(element, "NoncurrentDays") + versions = findtext(element, "NewerNoncurrentVersions") return cls( int(noncurrent_days) if noncurrent_days else None, findtext(element, "StorageClass"), + int(versions) if versions else None, ) def toxml(self, element: ET.Element | None) -> ET.Element: @@ -154,6 +163,9 @@ def toxml(self, element: ET.Element | None) -> ET.Element: SubElement(element, "NoncurrentDays", str(self._noncurrent_days)) if self._storage_class: SubElement(element, "StorageClass", self._storage_class) + if self._newer_noncurrent_versions: + SubElement(element, "NewerNoncurrentVersions", + str(self._newer_noncurrent_versions)) return element @@ -163,14 +175,21 @@ def toxml(self, element: ET.Element | None) -> ET.Element: class NoncurrentVersionExpiration: """Noncurrent version expiration.""" - def __init__(self, noncurrent_days: int | None = None): + def __init__(self, noncurrent_days: int | None = None, + newer_noncurrent_versions: int | None = None): self._noncurrent_days = noncurrent_days + self._newer_noncurrent_versions = newer_noncurrent_versions @property def noncurrent_days(self) -> int | None: """Get Noncurrent days.""" return self._noncurrent_days + @property + def newer_noncurrent_versions(self) -> int | None: + """Get Newer Noncurrent versions.""" + return self._newer_noncurrent_versions + @classmethod def fromxml(cls: Type[C], element: ET.Element) -> C: """Create new object with values from XML element.""" @@ -179,7 +198,9 @@ def fromxml(cls: Type[C], element: ET.Element) -> C: find(element, "NoncurrentVersionExpiration", True), ) noncurrent_days = findtext(element, "NoncurrentDays") - return cls(int(noncurrent_days) if noncurrent_days else None) + versions = findtext(element, "NewerNoncurrentVersions") + return cls(int(noncurrent_days) if noncurrent_days else None, + int(versions) if versions else None) def toxml(self, element: ET.Element | None) -> ET.Element: """Convert to XML.""" @@ -188,6 +209,9 @@ def toxml(self, element: ET.Element | None) -> ET.Element: element = SubElement(element, "NoncurrentVersionExpiration") if self._noncurrent_days: SubElement(element, "NoncurrentDays", str(self._noncurrent_days)) + if self._newer_noncurrent_versions: + SubElement(element, "NewerNoncurrentVersions", + str(self._newer_noncurrent_versions)) return element