# generated by https://github.com/puzl-cloud/kubesdk
#   filename:  apis__admissionregistration.k8s.io__v1alpha1_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 Loadable
from kube_models.resource import *

from ...apimachinery.pkg.apis.meta.v1 import LabelSelector, ListMeta, ObjectMeta


@dataclass(slots=True, kw_only=True, frozen=True)
class ApplyConfiguration(Loadable):
    expression: str | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class JSONPatch(Loadable):
    expression: str | None = None


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


@dataclass(slots=True, kw_only=True, frozen=True)
class Mutation(Loadable):
    patchType: str
    applyConfiguration: ApplyConfiguration | None = None
    jsonPatch: JSONPatch | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class NamedRuleWithOperations(Loadable):
    apiGroups: List[str] | None = None
    apiVersions: List[str] | None = None
    operations: List[str] | None = None
    resourceNames: List[str] | None = None
    resources: List[str] | None = None
    scope: str | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class ParamKind(Loadable):
    apiVersion: str | None = None
    kind: str | None = None


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


@dataclass(slots=True, kw_only=True, frozen=True)
class MatchResources(Loadable):
    excludeResourceRules: List[NamedRuleWithOperations] | None = None
    matchPolicy: str | None = None
    namespaceSelector: LabelSelector | None = None
    objectSelector: LabelSelector | None = None
    resourceRules: List[NamedRuleWithOperations] | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class MutatingAdmissionPolicySpec(Loadable):
    failurePolicy: str | None = None
    matchConditions: List[MatchCondition] = field(
        default_factory=list,
        metadata={
            'x-kubernetes-patch-strategy': 'merge',
            'x-kubernetes-patch-merge-key': 'name',
        },
    )
    matchConstraints: MatchResources | None = None
    mutations: List[Mutation] | None = None
    paramKind: ParamKind | None = None
    reinvocationPolicy: str | None = None
    variables: List[Variable] | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class ParamRef(Loadable):
    name: str | None = None
    namespace: str | None = None
    parameterNotFoundAction: str | None = None
    selector: LabelSelector | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class MutatingAdmissionPolicy(K8sResource):
    apiVersion: ClassVar[str] = 'admissionregistration.k8s.io/v1alpha1'
    kind: ClassVar[str] = 'MutatingAdmissionPolicy'
    metadata: ObjectMeta = field(default_factory=ObjectMeta)
    spec: MutatingAdmissionPolicySpec | None = None
    plural_: ClassVar[str] = 'mutatingadmissionpolicies'
    is_namespaced_: ClassVar[bool] = False
    group_: ClassVar[Optional[str]] = 'admissionregistration.k8s.io'
    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 MutatingAdmissionPolicyBindingSpec(Loadable):
    matchResources: MatchResources | None = None
    paramRef: ParamRef | None = None
    policyName: str | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class MutatingAdmissionPolicyList(Loadable):
    items: List[MutatingAdmissionPolicy]
    apiVersion: str = 'admissionregistration.k8s.io/v1alpha1'
    kind: str = 'MutatingAdmissionPolicyList'
    metadata: ListMeta = field(default_factory=ObjectMeta)


@dataclass(slots=True, kw_only=True, frozen=True)
class MutatingAdmissionPolicyBinding(K8sResource):
    apiVersion: ClassVar[str] = 'admissionregistration.k8s.io/v1alpha1'
    kind: ClassVar[str] = 'MutatingAdmissionPolicyBinding'
    metadata: ObjectMeta = field(default_factory=ObjectMeta)
    spec: MutatingAdmissionPolicyBindingSpec | None = None
    plural_: ClassVar[str] = 'mutatingadmissionpolicybindings'
    is_namespaced_: ClassVar[bool] = False
    group_: ClassVar[Optional[str]] = 'admissionregistration.k8s.io'
    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 MutatingAdmissionPolicyBindingList(Loadable):
    items: List[MutatingAdmissionPolicyBinding]
    apiVersion: str = 'admissionregistration.k8s.io/v1alpha1'
    kind: str = 'MutatingAdmissionPolicyBindingList'
    metadata: ListMeta = field(default_factory=ObjectMeta)
