# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel


class LifecycleRule(UniversalBaseModel):
    """
    Lifecycle rule for a storage bucket
    """

    action: str = pydantic.Field()
    """
    Action type (Delete, SetStorageClass)
    """

    action_storage_class: typing.Optional[str] = pydantic.Field(default=None)
    """
    Target storage class for SetStorageClass action
    """

    age_days: typing.Optional[int] = pydantic.Field(default=None)
    """
    Age in days to trigger rule
    """

    created_before: typing.Optional[str] = pydantic.Field(default=None)
    """
    Created before date
    """

    is_live: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Apply to live versions only
    """

    num_newer_versions: typing.Optional[int] = pydantic.Field(default=None)
    """
    Number of newer versions to keep
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
