# Generated by cloudcoil-model-codegen v0.1.1
# DO NOT EDIT

from __future__ import annotations

from typing import Annotated, Callable, List, Literal, Optional, Type, Union

from pydantic import Field

from cloudcoil import apimachinery
from cloudcoil.pydantic import BaseBuilder, BaseModel, ListBuilder, Self
from cloudcoil.resources import Resource, ResourceList


class GroupVersionResource(BaseModel):
    class Builder(BaseBuilder):
        def build(self) -> "GroupVersionResource":
            return GroupVersionResource(**self._attrs)

        def group(self, value: Optional[str]) -> Self:
            return self._set("group", value)

        def resource(self, value: Optional[str]) -> Self:
            return self._set("resource", value)

        def version(self, value: Optional[str]) -> Self:
            return self._set("version", value)

    @classmethod
    def builder(cls) -> Builder:
        return cls.Builder()

    @classmethod
    def list_builder(cls) -> ListBuilder[Self]:
        return ListBuilder[cls]()  # type: ignore[valid-type]

    group: Annotated[Optional[str], Field(description="The name of the group.")] = None
    resource: Annotated[Optional[str], Field(description="The name of the resource.")] = None
    version: Annotated[Optional[str], Field(description="The name of the version.")] = None


class StorageVersionMigrationSpec(BaseModel):
    class Builder(BaseBuilder):
        def build(self) -> "StorageVersionMigrationSpec":
            return StorageVersionMigrationSpec(**self._attrs)

        def continue_token(self, value: Optional[str]) -> Self:
            return self._set("continue_token", value)

        def resource(
            self,
            value_or_callback: Union[
                GroupVersionResource,
                Callable[[Type[GroupVersionResource]], GroupVersionResource],
            ],
        ) -> Self:
            value = value_or_callback
            if callable(value_or_callback):
                value = value_or_callback(GroupVersionResource)
            return self._set("resource", value)

    @classmethod
    def builder(cls) -> Builder:
        return cls.Builder()

    @classmethod
    def list_builder(cls) -> ListBuilder[Self]:
        return ListBuilder[cls]()  # type: ignore[valid-type]

    continue_token: Annotated[
        Optional[str],
        Field(
            alias="continueToken",
            description='The token used in the list options to get the next chunk of objects to migrate. When the .status.conditions indicates the migration is "Running", users can use this token to check the progress of the migration.',
        ),
    ] = None
    resource: Annotated[
        GroupVersionResource,
        Field(
            description="The resource that is being migrated. The migrator sends requests to the endpoint serving the resource. Immutable."
        ),
    ]


class MigrationCondition(BaseModel):
    class Builder(BaseBuilder):
        def build(self) -> "MigrationCondition":
            return MigrationCondition(**self._attrs)

        def last_update_time(
            self,
            value_or_callback: Union[
                Optional[apimachinery.Time],
                Callable[[Type[apimachinery.Time]], apimachinery.Time],
            ],
        ) -> Self:
            value = value_or_callback
            if callable(value_or_callback):
                value = value_or_callback(apimachinery.Time)
            return self._set("last_update_time", value)

        def message(self, value: Optional[str]) -> Self:
            return self._set("message", value)

        def reason(self, value: Optional[str]) -> Self:
            return self._set("reason", value)

        def status(self, value: str) -> Self:
            return self._set("status", value)

        def type(self, value: str) -> Self:
            return self._set("type", value)

    @classmethod
    def builder(cls) -> Builder:
        return cls.Builder()

    @classmethod
    def list_builder(cls) -> ListBuilder[Self]:
        return ListBuilder[cls]()  # type: ignore[valid-type]

    last_update_time: Annotated[
        Optional[apimachinery.Time],
        Field(
            alias="lastUpdateTime",
            description="The last time this condition was updated.",
        ),
    ] = None
    message: Annotated[
        Optional[str],
        Field(description="A human readable message indicating details about the transition."),
    ] = None
    reason: Annotated[
        Optional[str],
        Field(description="The reason for the condition's last transition."),
    ] = None
    status: Annotated[
        str, Field(description="Status of the condition, one of True, False, Unknown.")
    ]
    type: Annotated[str, Field(description="Type of the condition.")]


class StorageVersionMigrationStatus(BaseModel):
    class Builder(BaseBuilder):
        def build(self) -> "StorageVersionMigrationStatus":
            return StorageVersionMigrationStatus(**self._attrs)

        def conditions(
            self,
            value_or_callback: Union[
                Optional[List[MigrationCondition]],
                Callable[[Type[MigrationCondition]], List[MigrationCondition]],
            ],
        ) -> Self:
            value = value_or_callback
            if callable(value_or_callback):
                value = value_or_callback(MigrationCondition)
            return self._set("conditions", value)

        def resource_version(self, value: Optional[str]) -> Self:
            return self._set("resource_version", value)

    @classmethod
    def builder(cls) -> Builder:
        return cls.Builder()

    @classmethod
    def list_builder(cls) -> ListBuilder[Self]:
        return ListBuilder[cls]()  # type: ignore[valid-type]

    conditions: Annotated[
        Optional[List[MigrationCondition]],
        Field(description="The latest available observations of the migration's current state."),
    ] = None
    resource_version: Annotated[
        Optional[str],
        Field(
            alias="resourceVersion",
            description="ResourceVersion to compare with the GC cache for performing the migration. This is the current resource version of given group, version and resource when kube-controller-manager first observes this StorageVersionMigration resource.",
        ),
    ] = None


class StorageVersionMigration(Resource):
    class Builder(BaseBuilder):
        def build(self) -> "StorageVersionMigration":
            return StorageVersionMigration(**self._attrs)

        def api_version(self, value: Optional[Literal["storagemigration.k8s.io/v1alpha1"]]) -> Self:
            return self._set("api_version", value)

        def kind(self, value: Optional[Literal["StorageVersionMigration"]]) -> Self:
            return self._set("kind", value)

        def metadata(
            self,
            value_or_callback: Union[
                Optional[apimachinery.ObjectMeta],
                Callable[[Type[apimachinery.ObjectMeta]], apimachinery.ObjectMeta],
            ],
        ) -> Self:
            value = value_or_callback
            if callable(value_or_callback):
                value = value_or_callback(apimachinery.ObjectMeta)
            return self._set("metadata", value)

        def spec(
            self,
            value_or_callback: Union[
                Optional[StorageVersionMigrationSpec],
                Callable[[Type[StorageVersionMigrationSpec]], StorageVersionMigrationSpec],
            ],
        ) -> Self:
            value = value_or_callback
            if callable(value_or_callback):
                value = value_or_callback(StorageVersionMigrationSpec)
            return self._set("spec", value)

        def status(
            self,
            value_or_callback: Union[
                Optional[StorageVersionMigrationStatus],
                Callable[[Type[StorageVersionMigrationStatus]], StorageVersionMigrationStatus],
            ],
        ) -> Self:
            value = value_or_callback
            if callable(value_or_callback):
                value = value_or_callback(StorageVersionMigrationStatus)
            return self._set("status", value)

    @classmethod
    def builder(cls) -> Builder:
        return cls.Builder()

    @classmethod
    def list_builder(cls) -> ListBuilder[Self]:
        return ListBuilder[cls]()  # type: ignore[valid-type]

    api_version: Annotated[
        Optional[Literal["storagemigration.k8s.io/v1alpha1"]],
        Field(
            alias="apiVersion",
            description="APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
        ),
    ] = "storagemigration.k8s.io/v1alpha1"
    kind: Annotated[
        Optional[Literal["StorageVersionMigration"]],
        Field(
            description="Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"
        ),
    ] = "StorageVersionMigration"
    metadata: Annotated[
        Optional[apimachinery.ObjectMeta],
        Field(
            description="Standard object metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata"
        ),
    ] = None
    spec: Annotated[
        Optional[StorageVersionMigrationSpec],
        Field(description="Specification of the migration."),
    ] = None
    status: Annotated[
        Optional[StorageVersionMigrationStatus],
        Field(description="Status of the migration."),
    ] = None


StorageVersionMigrationList = ResourceList["StorageVersionMigration"]
