Skip to content

Commit

Permalink
Add NewerNoncurrentVersions in LifecycleConfig (#1469)
Browse files Browse the repository at this point in the history
Signed-off-by: Bala.FA <[email protected]>
  • Loading branch information
balamurugana authored Dec 18, 2024
1 parent a7b443d commit 94c60c5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 26 additions & 2 deletions minio/lifecycleconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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."""
Expand All @@ -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:
Expand All @@ -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


Expand All @@ -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."""
Expand All @@ -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."""
Expand All @@ -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


Expand Down

0 comments on commit 94c60c5

Please sign in to comment.