# generated by https://github.com/puzl-cloud/kubesdk
#   filename:  apis__policy__v1beta1_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
from ..core.v1 import SELinuxOptions


@dataclass(slots=True, kw_only=True, frozen=True)
class AllowedCSIDriver(Loadable):
    name: str


@dataclass(slots=True, kw_only=True, frozen=True)
class AllowedFlexVolume(Loadable):
    driver: str


@dataclass(slots=True, kw_only=True, frozen=True)
class AllowedHostPath(Loadable):
    pathPrefix: str | None = None
    readOnly: bool | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class HostPortRange(Loadable):
    max: int
    min: int


@dataclass(slots=True, kw_only=True, frozen=True)
class IDRange(Loadable):
    max: int
    min: int


@dataclass(slots=True, kw_only=True, frozen=True)
class RunAsGroupStrategyOptions(Loadable):
    rule: str
    ranges: List[IDRange] | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class RunAsUserStrategyOptions(Loadable):
    rule: str
    ranges: List[IDRange] | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class RuntimeClassStrategyOptions(Loadable):
    allowedRuntimeClassNames: List[str]
    defaultRuntimeClassName: str | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class SELinuxStrategyOptions(Loadable):
    rule: str
    seLinuxOptions: SELinuxOptions | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class SupplementalGroupsStrategyOptions(Loadable):
    ranges: List[IDRange] | None = None
    rule: str | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class FSGroupStrategyOptions(Loadable):
    ranges: List[IDRange] | None = None
    rule: str | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class PodSecurityPolicySpec(Loadable):
    fsGroup: FSGroupStrategyOptions
    runAsUser: RunAsUserStrategyOptions
    seLinux: SELinuxStrategyOptions
    supplementalGroups: SupplementalGroupsStrategyOptions
    allowPrivilegeEscalation: bool | None = None
    allowedCSIDrivers: List[AllowedCSIDriver] | None = None
    allowedCapabilities: List[str] | None = None
    allowedFlexVolumes: List[AllowedFlexVolume] | None = None
    allowedHostPaths: List[AllowedHostPath] | None = None
    allowedProcMountTypes: List[str] | None = None
    allowedUnsafeSysctls: List[str] | None = None
    defaultAddCapabilities: List[str] | None = None
    defaultAllowPrivilegeEscalation: bool | None = None
    forbiddenSysctls: List[str] | None = None
    hostIPC: bool | None = None
    hostNetwork: bool | None = None
    hostPID: bool | None = None
    hostPorts: List[HostPortRange] | None = None
    privileged: bool | None = None
    readOnlyRootFilesystem: bool | None = None
    requiredDropCapabilities: List[str] | None = None
    runAsGroup: RunAsGroupStrategyOptions | None = None
    runtimeClass: RuntimeClassStrategyOptions | None = None
    volumes: List[str] | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class PodDisruptionBudgetSpec(Loadable):
    maxUnavailable: IntOrString | None = None
    minAvailable: IntOrString | None = None
    selector: LabelSelector | 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 PodSecurityPolicy(K8sResource):
    apiVersion: ClassVar[str] = 'policy/v1beta1'
    kind: ClassVar[str] = 'PodSecurityPolicy'
    metadata: ObjectMeta = field(default_factory=ObjectMeta)
    spec: PodSecurityPolicySpec | None = None
    plural_: ClassVar[str] = 'podsecuritypolicies'
    is_namespaced_: ClassVar[bool] = False
    group_: ClassVar[Optional[str]] = 'policy'
    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 PodSecurityPolicyList(Loadable):
    items: List[PodSecurityPolicy]
    apiVersion: str = 'policy/v1beta1'
    kind: str = 'PodSecurityPolicyList'
    metadata: ListMeta = field(default_factory=ObjectMeta)


@dataclass(slots=True, kw_only=True, frozen=True)
class PodDisruptionBudget(K8sResource):
    apiVersion: ClassVar[str] = 'policy/v1beta1'
    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+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/v1beta1'
    kind: str = 'PodDisruptionBudgetList'
    metadata: ListMeta = field(default_factory=ObjectMeta)
