# generated by https://github.com/puzl-cloud/kubesdk
#   filename:  apis__policy__v1_openapi.json

from __future__ import annotations

from dataclasses import dataclass, field
from datetime import datetime, timezone
from typing import ClassVar, Dict, List, Set

from kube_models.const import *
from kube_models.loader import *
from kube_models.loader import Loadable
from kube_models.resource import *

from ...apimachinery.pkg.apis.meta.v1 import (
    Condition,
    LabelSelector,
    ListMeta,
    ObjectMeta,
    Time,
)
from ...apimachinery.pkg.util.intstr import IntOrString


@dataclass(slots=True, kw_only=True, frozen=True)
class PodDisruptionBudgetSpec(Loadable):
    maxUnavailable: IntOrString | None = None
    minAvailable: IntOrString | None = None
    selector: LabelSelector = field(
        default_factory=dict, metadata={'x-kubernetes-patch-strategy': 'replace'}
    )
    unhealthyPodEvictionPolicy: str | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class PodDisruptionBudgetStatus(Loadable):
    currentHealthy: int
    desiredHealthy: int
    disruptionsAllowed: int
    expectedPods: int
    conditions: List[Condition] = field(
        default_factory=list,
        metadata={
            'x-kubernetes-patch-strategy': 'merge',
            'x-kubernetes-patch-merge-key': 'type',
        },
    )
    disruptedPods: Dict[str, Time] | None = None
    observedGeneration: int | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class PodDisruptionBudget(K8sResource):
    apiVersion: ClassVar[str] = 'policy/v1'
    kind: ClassVar[str] = 'PodDisruptionBudget'
    metadata: ObjectMeta = field(default_factory=ObjectMeta)
    spec: PodDisruptionBudgetSpec | None = None
    status: PodDisruptionBudgetStatus | None = None
    plural_: ClassVar[str] = 'poddisruptionbudgets'
    is_namespaced_: ClassVar[bool] = True
    group_: ClassVar[Optional[str]] = 'policy'
    patch_strategies_: ClassVar[set[PatchRequestType]] = {
        'application/apply-patch+cbor',
        'application/apply-patch+yaml',
        'application/json-patch+json',
        'application/merge-patch+json',
        'application/strategic-merge-patch+json',
    }


@dataclass(slots=True, kw_only=True, frozen=True)
class PodDisruptionBudgetList(Loadable):
    items: List[PodDisruptionBudget]
    apiVersion: str = 'policy/v1'
    kind: str = 'PodDisruptionBudgetList'
    metadata: ListMeta = field(default_factory=ObjectMeta)
