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

from ...apimachinery.pkg.apis.meta.v1 import LabelSelector, ListMeta, ObjectMeta, Time
from ..core.v1 import ObjectReference, PodTemplateSpec


@dataclass(slots=True, kw_only=True, frozen=True)
class PodFailurePolicyOnExitCodesRequirement(Loadable):
    operator: str
    values: List[int]
    containerName: str | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class PodFailurePolicyOnPodConditionsPattern(Loadable):
    status: str
    type: str


@dataclass(slots=True, kw_only=True, frozen=True)
class PodFailurePolicyRule(Loadable):
    action: str
    onExitCodes: PodFailurePolicyOnExitCodesRequirement | None = None
    onPodConditions: List[PodFailurePolicyOnPodConditionsPattern] | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class SuccessPolicyRule(Loadable):
    succeededCount: int | None = None
    succeededIndexes: str | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class UncountedTerminatedPods(Loadable):
    failed: List[str] | None = None
    succeeded: List[str] | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class CronJobStatus(Loadable):
    active: List[ObjectReference] | None = None
    lastScheduleTime: Time | None = None
    lastSuccessfulTime: Time | None = None


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


@dataclass(slots=True, kw_only=True, frozen=True)
class JobStatus(Loadable):
    active: int | None = None
    completedIndexes: str | None = None
    completionTime: Time | None = None
    conditions: List[JobCondition] = field(
        default_factory=list,
        metadata={
            'x-kubernetes-patch-strategy': 'merge',
            'x-kubernetes-patch-merge-key': 'type',
        },
    )
    failed: int | None = None
    failedIndexes: str | None = None
    ready: int | None = None
    startTime: Time | None = None
    succeeded: int | None = None
    terminating: int | None = None
    uncountedTerminatedPods: UncountedTerminatedPods | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class PodFailurePolicy(Loadable):
    rules: List[PodFailurePolicyRule]


@dataclass(slots=True, kw_only=True, frozen=True)
class SuccessPolicy(Loadable):
    rules: List[SuccessPolicyRule]


@dataclass(slots=True, kw_only=True, frozen=True)
class JobSpec(Loadable):
    template: PodTemplateSpec
    activeDeadlineSeconds: int | None = None
    backoffLimit: int | None = None
    backoffLimitPerIndex: int | None = None
    completionMode: str | None = None
    completions: int | None = None
    managedBy: str | None = None
    manualSelector: bool | None = None
    maxFailedIndexes: int | None = None
    parallelism: int | None = None
    podFailurePolicy: PodFailurePolicy | None = None
    podReplacementPolicy: str | None = None
    selector: LabelSelector | None = None
    successPolicy: SuccessPolicy | None = None
    suspend: bool | None = None
    ttlSecondsAfterFinished: int | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class JobTemplateSpec(Loadable):
    metadata: ObjectMeta | None = None
    spec: JobSpec | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class CronJobSpec(Loadable):
    jobTemplate: JobTemplateSpec
    schedule: str
    concurrencyPolicy: str | None = None
    failedJobsHistoryLimit: int | None = None
    startingDeadlineSeconds: int | None = None
    successfulJobsHistoryLimit: int | None = None
    suspend: bool | None = None
    timeZone: str | None = None


@dataclass(slots=True, kw_only=True, frozen=True)
class Job(K8sResource):
    apiVersion: ClassVar[str] = 'batch/v1'
    kind: ClassVar[str] = 'Job'
    metadata: ObjectMeta = field(default_factory=ObjectMeta)
    spec: JobSpec | None = None
    status: JobStatus | None = None
    plural_: ClassVar[str] = 'jobs'
    is_namespaced_: ClassVar[bool] = True
    group_: ClassVar[Optional[str]] = 'batch'
    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 JobList(Loadable):
    items: List[Job]
    apiVersion: str = 'batch/v1'
    kind: str = 'JobList'
    metadata: ListMeta = field(default_factory=ObjectMeta)


@dataclass(slots=True, kw_only=True, frozen=True)
class CronJob(K8sResource):
    apiVersion: ClassVar[str] = 'batch/v1'
    kind: ClassVar[str] = 'CronJob'
    metadata: ObjectMeta = field(default_factory=ObjectMeta)
    spec: CronJobSpec | None = None
    status: CronJobStatus | None = None
    plural_: ClassVar[str] = 'cronjobs'
    is_namespaced_: ClassVar[bool] = True
    group_: ClassVar[Optional[str]] = 'batch'
    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 CronJobList(Loadable):
    items: List[CronJob]
    apiVersion: str = 'batch/v1'
    kind: str = 'CronJobList'
    metadata: ListMeta = field(default_factory=ObjectMeta)
