# generated by https://github.com/puzl-cloud/kubesdk
#   filename:  apis__admissionregistration.k8s.io__v1_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.apis.meta.v1 import (
    Condition,
    LabelSelector,
    ListMeta,
    ObjectMeta,
)


@dataclass(slots=True, kw_only=True, frozen=True)
class AuditAnnotation(LazyLoadModel):
    key: str
    valueExpression: str


@dataclass(slots=True, kw_only=True, frozen=True)
class ExpressionWarning(LazyLoadModel):
    fieldRef: str
    warning: str


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


@dataclass(slots=True, kw_only=True, frozen=True)
class NamedRuleWithOperations(LazyLoadModel):
    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(LazyLoadModel):
    apiVersion: str | None = None
    kind: str | None = None


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


@dataclass(slots=True, kw_only=True, frozen=True)
class ServiceReference(LazyLoadModel):
    name: str
    namespace: str
    path: str | None = None
    port: int | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class TypeChecking(LazyLoadModel):
    expressionWarnings: List[ExpressionWarning] | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class Validation(LazyLoadModel):
    expression: str
    message: str | None = None
    messageExpression: str | None = None
    reason: str | None = None


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


@dataclass(slots=True, kw_only=True, frozen=True)
class WebhookClientConfig(LazyLoadModel):
    caBundle: str | None = None
    service: ServiceReference | None = None
    url: str | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class MatchResources(LazyLoadModel):
    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 MutatingWebhook(LazyLoadModel):
    admissionReviewVersions: List[str]
    clientConfig: WebhookClientConfig
    name: str
    sideEffects: str
    failurePolicy: str | None = None
    matchConditions: List[MatchCondition] = field(
        default_factory=list,
        metadata={
            'x-kubernetes-patch-strategy': 'merge',
            'x-kubernetes-patch-merge-key': 'name',
        },
    )
    matchPolicy: str | None = None
    namespaceSelector: LabelSelector | None = None
    objectSelector: LabelSelector | None = None
    reinvocationPolicy: str | None = None
    rules: List[RuleWithOperations] | None = None
    timeoutSeconds: int | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class MutatingWebhookConfiguration(K8sResource):
    apiVersion: ClassVar[str] = 'admissionregistration.k8s.io/v1'
    kind: ClassVar[str] = 'MutatingWebhookConfiguration'
    metadata: ObjectMeta = field(default_factory=ObjectMeta)
    webhooks: List[MutatingWebhook] = field(
        default_factory=list,
        metadata={
            'x-kubernetes-patch-strategy': 'merge',
            'x-kubernetes-patch-merge-key': 'name',
        },
    )
    api_path_: ClassVar[str] = (
        'apis/admissionregistration.k8s.io/v1/mutatingwebhookconfigurations'
    )
    plural_: ClassVar[str] = 'mutatingwebhookconfigurations'
    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 MutatingWebhookConfigurationList(LazyLoadModel):
    items: List[MutatingWebhookConfiguration]
    apiVersion: str = 'admissionregistration.k8s.io/v1'
    kind: str = 'MutatingWebhookConfigurationList'
    metadata: ListMeta = field(default_factory=ObjectMeta)


@dataclass(slots=True, kw_only=True, frozen=True)
class ParamRef(LazyLoadModel):
    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 ValidatingAdmissionPolicyBindingSpec(LazyLoadModel):
    matchResources: MatchResources | None = None
    paramRef: ParamRef | None = None
    policyName: str | None = None
    validationActions: List[str] | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class ValidatingAdmissionPolicySpec(LazyLoadModel):
    auditAnnotations: List[AuditAnnotation] | None = None
    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
    paramKind: ParamKind | None = None
    validations: List[Validation] | None = None
    variables: List[Variable] = field(
        default_factory=list,
        metadata={
            'x-kubernetes-patch-strategy': 'merge',
            'x-kubernetes-patch-merge-key': 'name',
        },
    )


@dataclass(slots=True, kw_only=True, frozen=True)
class ValidatingAdmissionPolicyStatus(LazyLoadModel):
    conditions: List[Condition] | None = None
    observedGeneration: int | None = None
    typeChecking: TypeChecking | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class ValidatingWebhook(LazyLoadModel):
    admissionReviewVersions: List[str]
    clientConfig: WebhookClientConfig
    name: str
    sideEffects: str
    failurePolicy: str | None = None
    matchConditions: List[MatchCondition] = field(
        default_factory=list,
        metadata={
            'x-kubernetes-patch-strategy': 'merge',
            'x-kubernetes-patch-merge-key': 'name',
        },
    )
    matchPolicy: str | None = None
    namespaceSelector: LabelSelector | None = None
    objectSelector: LabelSelector | None = None
    rules: List[RuleWithOperations] | None = None
    timeoutSeconds: int | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class ValidatingWebhookConfiguration(K8sResource):
    apiVersion: ClassVar[str] = 'admissionregistration.k8s.io/v1'
    kind: ClassVar[str] = 'ValidatingWebhookConfiguration'
    metadata: ObjectMeta = field(default_factory=ObjectMeta)
    webhooks: List[ValidatingWebhook] = field(
        default_factory=list,
        metadata={
            'x-kubernetes-patch-strategy': 'merge',
            'x-kubernetes-patch-merge-key': 'name',
        },
    )
    api_path_: ClassVar[str] = (
        'apis/admissionregistration.k8s.io/v1/validatingwebhookconfigurations'
    )
    plural_: ClassVar[str] = 'validatingwebhookconfigurations'
    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 ValidatingWebhookConfigurationList(LazyLoadModel):
    items: List[ValidatingWebhookConfiguration]
    apiVersion: str = 'admissionregistration.k8s.io/v1'
    kind: str = 'ValidatingWebhookConfigurationList'
    metadata: ListMeta = field(default_factory=ObjectMeta)


@dataclass(slots=True, kw_only=True, frozen=True)
class ValidatingAdmissionPolicy(K8sResource):
    apiVersion: ClassVar[str] = 'admissionregistration.k8s.io/v1'
    kind: ClassVar[str] = 'ValidatingAdmissionPolicy'
    metadata: ObjectMeta = field(default_factory=ObjectMeta)
    spec: ValidatingAdmissionPolicySpec | None = None
    status: ValidatingAdmissionPolicyStatus | None = None
    api_path_: ClassVar[str] = (
        'apis/admissionregistration.k8s.io/v1/validatingadmissionpolicies'
    )
    plural_: ClassVar[str] = 'validatingadmissionpolicies'
    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 ValidatingAdmissionPolicyBinding(K8sResource):
    apiVersion: ClassVar[str] = 'admissionregistration.k8s.io/v1'
    kind: ClassVar[str] = 'ValidatingAdmissionPolicyBinding'
    metadata: ObjectMeta = field(default_factory=ObjectMeta)
    spec: ValidatingAdmissionPolicyBindingSpec | None = None
    api_path_: ClassVar[str] = (
        'apis/admissionregistration.k8s.io/v1/validatingadmissionpolicybindings'
    )
    plural_: ClassVar[str] = 'validatingadmissionpolicybindings'
    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 ValidatingAdmissionPolicyBindingList(LazyLoadModel):
    items: List[ValidatingAdmissionPolicyBinding]
    apiVersion: str = 'admissionregistration.k8s.io/v1'
    kind: str = 'ValidatingAdmissionPolicyBindingList'
    metadata: ListMeta = field(default_factory=ObjectMeta)


@dataclass(slots=True, kw_only=True, frozen=True)
class ValidatingAdmissionPolicyList(LazyLoadModel):
    items: List[ValidatingAdmissionPolicy]
    apiVersion: str = 'admissionregistration.k8s.io/v1'
    kind: str = 'ValidatingAdmissionPolicyList'
    metadata: ListMeta = field(default_factory=ObjectMeta)
