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

from __future__ import annotations

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

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

from ...apimachinery.pkg.api.resource import Quantity
from ...apimachinery.pkg.apis.meta.v1 import LabelSelector, ListMeta, ObjectMeta, Time


@dataclass(slots=True, kw_only=True, frozen=True)
class CrossVersionObjectReference(LazyLoadModel):
    kind: str
    name: str
    apiVersion: str | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class HPAScalingPolicy(LazyLoadModel):
    periodSeconds: int
    type: str
    value: int


@dataclass(slots=True, kw_only=True, frozen=True)
class HPAScalingRules(LazyLoadModel):
    policies: List[HPAScalingPolicy] | None = None
    selectPolicy: str | None = None
    stabilizationWindowSeconds: int | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class HorizontalPodAutoscalerBehavior(LazyLoadModel):
    scaleDown: HPAScalingRules | None = None
    scaleUp: HPAScalingRules | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class HorizontalPodAutoscalerCondition(LazyLoadModel):
    status: str
    type: str
    lastTransitionTime: Time | None = None
    message: str | None = None
    reason: str | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class MetricTarget(LazyLoadModel):
    type: str
    averageUtilization: int | None = None
    averageValue: Quantity | None = None
    value: Quantity | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class MetricValueStatus(LazyLoadModel):
    averageUtilization: int | None = None
    averageValue: Quantity | None = None
    value: Quantity | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class ResourceMetricSource(LazyLoadModel):
    name: str
    target: MetricTarget


@dataclass(slots=True, kw_only=True, frozen=True)
class ResourceMetricStatus(LazyLoadModel):
    current: MetricValueStatus
    name: str


@dataclass(slots=True, kw_only=True, frozen=True)
class ContainerResourceMetricSource(LazyLoadModel):
    container: str
    name: str
    target: MetricTarget


@dataclass(slots=True, kw_only=True, frozen=True)
class ContainerResourceMetricStatus(LazyLoadModel):
    container: str
    current: MetricValueStatus
    name: str


@dataclass(slots=True, kw_only=True, frozen=True)
class MetricIdentifier(LazyLoadModel):
    name: str
    selector: LabelSelector | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class ObjectMetricSource(LazyLoadModel):
    describedObject: CrossVersionObjectReference
    metric: MetricIdentifier
    target: MetricTarget


@dataclass(slots=True, kw_only=True, frozen=True)
class ObjectMetricStatus(LazyLoadModel):
    current: MetricValueStatus
    describedObject: CrossVersionObjectReference
    metric: MetricIdentifier


@dataclass(slots=True, kw_only=True, frozen=True)
class PodsMetricSource(LazyLoadModel):
    metric: MetricIdentifier
    target: MetricTarget


@dataclass(slots=True, kw_only=True, frozen=True)
class PodsMetricStatus(LazyLoadModel):
    current: MetricValueStatus
    metric: MetricIdentifier


@dataclass(slots=True, kw_only=True, frozen=True)
class ExternalMetricSource(LazyLoadModel):
    metric: MetricIdentifier
    target: MetricTarget


@dataclass(slots=True, kw_only=True, frozen=True)
class ExternalMetricStatus(LazyLoadModel):
    current: MetricValueStatus
    metric: MetricIdentifier


@dataclass(slots=True, kw_only=True, frozen=True)
class MetricSpec(LazyLoadModel):
    type: str
    containerResource: ContainerResourceMetricSource | None = None
    external: ExternalMetricSource | None = None
    object: ObjectMetricSource | None = None
    pods: PodsMetricSource | None = None
    resource: ResourceMetricSource | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class MetricStatus(LazyLoadModel):
    type: str
    containerResource: ContainerResourceMetricStatus | None = None
    external: ExternalMetricStatus | None = None
    object: ObjectMetricStatus | None = None
    pods: PodsMetricStatus | None = None
    resource: ResourceMetricStatus | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class HorizontalPodAutoscalerSpec(LazyLoadModel):
    maxReplicas: int
    scaleTargetRef: CrossVersionObjectReference
    behavior: HorizontalPodAutoscalerBehavior | None = None
    metrics: List[MetricSpec] | None = None
    minReplicas: int | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class HorizontalPodAutoscalerStatus(LazyLoadModel):
    currentReplicas: int
    desiredReplicas: int
    conditions: List[HorizontalPodAutoscalerCondition] | None = None
    currentMetrics: List[MetricStatus] | None = None
    lastScaleTime: Time | None = None
    observedGeneration: int | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class HorizontalPodAutoscaler(K8sResource):
    apiVersion: ClassVar[str] = 'autoscaling/v2beta2'
    kind: ClassVar[str] = 'HorizontalPodAutoscaler'
    metadata: ObjectMeta = field(default_factory=ObjectMeta)
    spec: HorizontalPodAutoscalerSpec | None = None
    status: HorizontalPodAutoscalerStatus | None = None
    api_path_: ClassVar[str] = (
        'apis/autoscaling/v2beta2/namespaces/{namespace}/horizontalpodautoscalers'
    )
    plural_: ClassVar[str] = 'horizontalpodautoscalers'
    is_namespaced_: ClassVar[bool] = False
    group_: ClassVar[Optional[str]] = 'autoscaling'
    patch_strategies_: ClassVar[set[PatchRequestType]] = {
        '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 HorizontalPodAutoscalerList(LazyLoadModel):
    items: List[HorizontalPodAutoscaler]
    apiVersion: str = 'autoscaling/v2beta2'
    kind: str = 'HorizontalPodAutoscalerList'
    metadata: ListMeta = field(default_factory=ObjectMeta)
