Skip to content

Commit

Permalink
Merge branch 'master' into fix-issue-1459
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana authored Dec 18, 2024
2 parents 15d7fa0 + 94c60c5 commit b21c693
Showing 1 changed file with 26 additions and 2 deletions.
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 b21c693

Please sign in to comment.