# generated by datamodel-codegen:
#   filename:  http://localhost:3001/openapi.json
#   timestamp: 2024-09-11T17:38:42+00:00

from __future__ import annotations

from datetime import datetime
from enum import Enum
from typing import Annotated, Any, Dict, List, Optional, Union

from airadar.utils.base_model import RadarBaseModel
from pydantic import AnyUrl, ConfigDict, Field, RootModel


class ExternalUrlItem(RootModel[AnyUrl]):
    root: AnyUrl


class DescriptionItem(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class ApplicationCreateRequestSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    name: Annotated[str, Field(max_length=128, title="Name")]
    external_url: Annotated[Optional[ExternalUrlItem], Field(title="External Url")] = (
        None
    )
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None


class ApplicationStatsSchema(RadarBaseModel):
    total_applications: Annotated[int, Field(title="Total Applications")]
    applications_with_models_failing_model_scan: Annotated[
        str, Field(max_length=128, title="Applications With Models Failing Model Scan")
    ]
    applications_with_models_missing_model_scan: Annotated[
        str, Field(max_length=128, title="Applications With Models Missing Model Scan")
    ]


class NameItem(RootModel[str]):
    root: Annotated[str, Field(max_length=128)]


class ApplicationUpdateRequestSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    name: Annotated[Optional[NameItem], Field(title="Name")] = None
    external_url: Annotated[Optional[ExternalUrlItem], Field(title="External Url")] = (
        None
    )
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None


class ArtifactDirection(Enum):
    input = "INPUT"
    output = "OUTPUT"


class CVESeverity(RadarBaseModel):
    rating: Annotated[str, Field(max_length=256, title="Rating")]
    score: Annotated[float, Field(title="Score")]
    vector: Annotated[str, Field(max_length=256, title="Vector")]


class DatasetBaseSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    name: Annotated[str, Field(max_length=128, title="Name")]
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None


class DatasetStatsSchema(RadarBaseModel):
    total_datasets: Annotated[int, Field(title="Total Datasets")]
    total_related_models: Annotated[int, Field(title="Total Related Models")]
    total_related_model_versions: Annotated[
        int, Field(title="Total Related Model Versions")
    ]


class DatasetUpdateRequestSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    name: Annotated[Optional[NameItem], Field(title="Name")] = None
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None


class VersionItem(RootModel[str]):
    root: Annotated[str, Field(max_length=64)]


class DatasetVersionWithDatasetSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    dataset: DatasetBaseSchema
    version: Annotated[str, Field(max_length=64, title="Version")]
    external_uri: Annotated[str, Field(max_length=256, title="External Uri")]
    file_count: Annotated[int, Field(title="File Count")]


class VersionItem1(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class AuthorItem(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class PurlItem(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class ApplicationUrlItem(RootModel[AnyUrl]):
    root: AnyUrl


class BuildUrlItem(RootModel[AnyUrl]):
    root: AnyUrl


class RadarUri(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class DeploymentCreateRequestSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    application_version: Annotated[
        str, Field(max_length=256, title="Application Version")
    ]
    environment: Annotated[str, Field(max_length=256, title="Environment")]
    application_url: Annotated[
        Optional[ApplicationUrlItem], Field(title="Application Url")
    ] = None
    build_url: Annotated[Optional[BuildUrlItem], Field(title="Build Url")] = None
    build_time: Annotated[datetime, Field(title="Build Time")]
    radar_uris: Annotated[List[RadarUri], Field(title="Radar Uris")]


class ApplicationVersionItem(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class EntityType(Enum):
    pipeline = "PIPELINE"
    application = "APPLICATION"
    model = "MODEL"
    dataset = "DATASET"


class StorageTypeItem(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class ResourceNameItem(RootModel[str]):
    root: Annotated[str, Field(max_length=128)]


class ShaItem(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class RepoTypeItem(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class RepoNameItem(RootModel[str]):
    root: Annotated[str, Field(max_length=128)]


class RepoUrlItem(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class GitInfo(RadarBaseModel):
    sha: Annotated[Optional[ShaItem], Field(title="Sha")] = None
    repo_type: Annotated[Optional[RepoTypeItem], Field(title="Repo Type")] = None
    repo_name: Annotated[Optional[RepoNameItem], Field(title="Repo Name")] = None
    repo_url: Annotated[Optional[RepoUrlItem], Field(title="Repo Url")] = None
    dirty: Annotated[Optional[bool], Field(title="Dirty")] = None


class License(RadarBaseModel):
    name: Annotated[str, Field(max_length=128, title="Name")]


class LicenseWrapper(RadarBaseModel):
    license: License


class ModelBaseSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    name: Annotated[str, Field(max_length=128, title="Name")]
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None


class ModelScanIssue(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    description: Annotated[str, Field(title="Description")]
    operator: Annotated[str, Field(title="Operator")]
    module: Annotated[str, Field(title="Module")]
    source: Annotated[str, Field(title="Source")]
    scanner: Annotated[str, Field(title="Scanner")]


class ModelStatsSchema(RadarBaseModel):
    total_models: Annotated[int, Field(title="Total Models")]
    total_models_without_pipelines: Annotated[
        int, Field(title="Total Models Without Pipelines")
    ]
    models_without_pipelines: Annotated[
        str, Field(max_length=64, title="Models Without Pipelines")
    ]
    total_models_with_policy_failures: Annotated[
        int, Field(title="Total Models With Policy Failures")
    ]
    total_scanned_models: Annotated[int, Field(title="Total Scanned Models")]
    scanned_models_with_issues: Annotated[
        str, Field(max_length=64, title="Scanned Models With Issues")
    ]
    total_unscanned_models: Annotated[int, Field(title="Total Unscanned Models")]


class ModelUpdateRequestSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    name: Annotated[Optional[NameItem], Field(title="Name")] = None
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None


class VersionItem3(RootModel[str]):
    root: Annotated[str, Field(max_length=64)]


class PaginationSchema(RadarBaseModel):
    total_items: Annotated[Optional[int], Field(title="Total Items")] = None


class OwnerItem(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class PipelineCreateRequestSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    name: Annotated[str, Field(max_length=128, title="Name")]
    owner: Annotated[Optional[OwnerItem], Field(title="Owner")] = None
    external_url: Annotated[Optional[ExternalUrlItem], Field(title="External Url")] = (
        None
    )
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None


class ExternalRunUrlItem(RootModel[AnyUrl]):
    root: AnyUrl


class ExternalRunIdItem(RootModel[str]):
    root: Annotated[str, Field(max_length=512)]


class PlatformItem(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class PipelineRunState(Enum):
    active = "ACTIVE"
    closed = "CLOSED"
    failed = "FAILED"


class AdjacentRun(RootModel[List[Any]]):
    root: Annotated[List[Any], Field(max_length=2, min_length=2)]


class PipelineStatsSchema(RadarBaseModel):
    total_pipeline_runs: Annotated[int, Field(title="Total Pipeline Runs")]
    total_pipelines: Annotated[int, Field(title="Total Pipelines")]


class PipelineUpdateRequestSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    name: Annotated[Optional[NameItem], Field(title="Name")] = None
    owner: Annotated[Optional[OwnerItem], Field(title="Owner")] = None
    external_url: Annotated[Optional[ExternalUrlItem], Field(title="External Url")] = (
        None
    )
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None


class RemediationTitleItem(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class RemediationUrlItem(RootModel[AnyUrl]):
    root: AnyUrl


class PolicyEvaluationRequestSchema(RadarBaseModel):
    policy_definition: Annotated[str, Field(title="Policy Definition")]
    policy_input: Annotated[str, Field(title="Policy Input")]


class Error(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class PolicyEvaluationResponseSchema(RadarBaseModel):
    policy_definition: Annotated[str, Field(title="Policy Definition")]
    opa_output: Annotated[Optional[str], Field(title="Opa Output")] = None
    opa_error_code: Annotated[Optional[int], Field(title="Opa Error Code")] = None
    errors: Annotated[Optional[List[Error]], Field(title="Errors")] = None


class PolicyEvaluationResult(Enum):
    success = "SUCCESS"
    failed = "FAILED"
    skipped = "SKIPPED"
    invalid = "INVALID"


class ErrorMessageItem(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class PolicyEvaluationSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    result: PolicyEvaluationResult
    rule_name: Annotated[str, Field(max_length=128, title="Rule Name")]
    entity_uuid: Annotated[str, Field(max_length=256, title="Entity Uuid")]
    base_entity_uuid: Annotated[str, Field(max_length=256, title="Base Entity Uuid")]
    policy_snapshot: Annotated[str, Field(title="Policy Snapshot")]
    error_message: Annotated[
        Optional[ErrorMessageItem], Field(title="Error Message")
    ] = None


class PolicyEvaluationWithPayloadSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    result: PolicyEvaluationResult
    rule_name: Annotated[str, Field(max_length=128, title="Rule Name")]
    entity_uuid: Annotated[str, Field(max_length=256, title="Entity Uuid")]
    base_entity_uuid: Annotated[str, Field(max_length=256, title="Base Entity Uuid")]
    policy_snapshot: Annotated[str, Field(title="Policy Snapshot")]
    error_message: Annotated[
        Optional[ErrorMessageItem], Field(title="Error Message")
    ] = None
    opa_payload: Annotated[str, Field(title="Opa Payload")]
    opa_output: Annotated[Optional[str], Field(title="Opa Output")] = None


class PolicyStatsSchema(RadarBaseModel):
    total_policies: Annotated[int, Field(title="Total Policies")]
    total_policy_violations: Annotated[int, Field(title="Total Policy Violations")]
    total_failed_evaluations_with_critical_severity: Annotated[
        int, Field(title="Total Failed Evaluations With Critical Severity")
    ]
    total_evaluations_with_critical_severity: Annotated[
        int, Field(title="Total Evaluations With Critical Severity")
    ]


class PolicyStatus(Enum):
    enabled = "ENABLED"
    evaluate = "EVALUATE"
    disabled = "DISABLED"


class RadarEntityAttributes(RadarBaseModel):
    radar_uri: Annotated[str, Field(max_length=256, title="Radar Uri")]


class SearchResultSchema(RadarBaseModel):
    name: Annotated[str, Field(max_length=128, title="Name")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    entity: EntityType
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None


class SeverityLevel(Enum):
    low = "LOW"
    medium = "MEDIUM"
    high = "HIGH"
    critical = "CRITICAL"


class SkippedSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    total_skipped: Annotated[int, Field(title="Total Skipped")]
    skipped_files: Annotated[List[str], Field(title="Skipped Files")]


class TotalIssuesBySeveritySchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    low: Annotated[int, Field(alias="LOW", title="Low")]
    medium: Annotated[int, Field(alias="MEDIUM", title="Medium")]
    high: Annotated[int, Field(alias="HIGH", title="High")]
    critical: Annotated[int, Field(alias="CRITICAL", title="Critical")]


class TotalIssuesSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    total_issues_by_severity: TotalIssuesBySeveritySchema


class ValidationError(RadarBaseModel):
    loc: Annotated[List[Union[str, int]], Field(title="Location")]
    msg: Annotated[str, Field(title="Message")]
    type: Annotated[str, Field(title="Error Type")]


class VersionStrategy(Enum):
    s3 = "S3"
    custom = "CUSTOM"


class CveIdItem(RootModel[str]):
    root: Annotated[str, Field(max_length=256)]


class Vulnerability(RadarBaseModel):
    summary: Annotated[str, Field(max_length=256, title="Summary")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    severity: CVESeverity
    cve_id: Annotated[Optional[CveIdItem], Field(title="Cve Id")] = None


class DatasetSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    name: Annotated[str, Field(max_length=128, title="Name")]
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None
    version_count: Annotated[Optional[int], Field(title="Version Count")] = 0
    latest_version: Optional[DatasetVersionWithDatasetSchema] = None


class DatasetVersionListSchema(RadarBaseModel):
    pagination: PaginationSchema
    versions: Annotated[List[DatasetVersionWithDatasetSchema], Field(title="Versions")]


class Dependency(RadarBaseModel):
    name: Annotated[str, Field(max_length=128, title="Name")]
    version: Annotated[Optional[VersionItem1], Field(title="Version")] = None
    author: Annotated[Optional[AuthorItem], Field(title="Author")] = None
    purl: Annotated[Optional[PurlItem], Field(title="Purl")] = None
    licenses: Annotated[Optional[List[LicenseWrapper]], Field(title="Licenses")] = None
    sightline: Annotated[Optional[List[Vulnerability]], Field(title="Sightline")] = None


class File(RadarBaseModel):
    uri: Annotated[str, Field(max_length=256, title="Uri")]
    storage_type: Annotated[Optional[StorageTypeItem], Field(title="Storage Type")] = (
        None
    )
    resource_name: Annotated[
        Optional[ResourceNameItem], Field(title="Resource Name")
    ] = None
    size: Annotated[Optional[int], Field(title="Size")] = None
    version: Annotated[Optional[VersionItem1], Field(title="Version")] = None
    version_strategy: Optional[VersionStrategy] = None


class FileListSchema(RadarBaseModel):
    pagination: PaginationSchema
    files: Annotated[Optional[List[File]], Field(title="Files")] = None


class HTTPValidationError(RadarBaseModel):
    detail: Annotated[Optional[List[ValidationError]], Field(title="Detail")] = None


class IssuesBySeveritySchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    low: Annotated[Optional[List[ModelScanIssue]], Field(alias="LOW", title="Low")] = []
    medium: Annotated[
        Optional[List[ModelScanIssue]], Field(alias="MEDIUM", title="Medium")
    ] = []
    high: Annotated[
        Optional[List[ModelScanIssue]], Field(alias="HIGH", title="High")
    ] = []
    critical: Annotated[
        Optional[List[ModelScanIssue]], Field(alias="CRITICAL", title="Critical")
    ] = []


class ModelScanResultSchemaInput(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    modelscan_version: Annotated[str, Field(title="Modelscan Version")]
    timestamp: Annotated[datetime, Field(title="Timestamp")]
    input_path: Annotated[str, Field(title="Input Path")]
    total_issues: Annotated[int, Field(title="Total Issues")]
    summary: TotalIssuesSchema
    issues_by_severity: IssuesBySeveritySchema
    errors: Annotated[List[str], Field(title="Errors")]
    skipped: SkippedSchema


class ModelScanResultSchemaOutput(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    modelscan_version: Annotated[str, Field(title="Modelscan Version")]
    timestamp: Annotated[datetime, Field(title="Timestamp")]
    input_path: Annotated[str, Field(title="Input Path")]
    total_issues: Annotated[int, Field(title="Total Issues")]
    summary: TotalIssuesSchema
    issues_by_severity: IssuesBySeveritySchema
    errors: Annotated[List[str], Field(title="Errors")]
    skipped: SkippedSchema


class ModelVersionCreateRequestSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    name: Annotated[str, Field(max_length=128, title="Name")]
    external_uri: Annotated[str, Field(max_length=256, title="External Uri")]
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None
    version: Annotated[Optional[VersionItem3], Field(title="Version")] = None
    files: Annotated[Optional[List[File]], Field(title="Files")] = None
    properties: Annotated[Optional[Dict[str, str]], Field(title="Properties")] = None
    model_scan_result: Optional[ModelScanResultSchemaInput] = None


class PipelineRunCreateRequestSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    external_run_url: Annotated[
        Optional[ExternalRunUrlItem], Field(title="External Run Url")
    ] = None
    external_run_id: Annotated[
        Optional[ExternalRunIdItem], Field(title="External Run Id")
    ] = None
    platform: Annotated[Optional[PlatformItem], Field(title="Platform")] = None
    dependencies: Annotated[Optional[List[Dependency]], Field(title="Dependencies")] = (
        None
    )
    git_info: Optional[GitInfo] = None
    run_at: Annotated[datetime, Field(title="Run At")]


class PipelineRunSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    external_run_url: Annotated[
        Optional[ExternalRunUrlItem], Field(title="External Run Url")
    ] = None
    external_run_id: Annotated[
        Optional[ExternalRunIdItem], Field(title="External Run Id")
    ] = None
    platform: Annotated[Optional[PlatformItem], Field(title="Platform")] = None
    model_count: Annotated[Optional[int], Field(title="Model Count")] = 0
    run_at: Annotated[datetime, Field(title="Run At")]
    completed_at: Annotated[Optional[datetime], Field(title="Completed At")] = None
    status: PipelineRunState
    git_info: Optional[GitInfo] = None


class PipelineRunUpdateRequestSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    dependencies: Annotated[Optional[List[Dependency]], Field(title="Dependencies")] = (
        None
    )
    status: Optional[PipelineRunState] = None
    completed_at: Annotated[Optional[datetime], Field(title="Completed At")] = None


class PipelineSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    name: Annotated[str, Field(max_length=128, title="Name")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    owner: Annotated[Optional[OwnerItem], Field(title="Owner")] = None
    external_url: Annotated[Optional[ExternalUrlItem], Field(title="External Url")] = (
        None
    )
    run_count: Annotated[Optional[int], Field(title="Run Count")] = 0
    latest_run: Optional[PipelineRunSchema] = None
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None


class PolicyCreateRequestSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    name: Annotated[str, Field(max_length=128, title="Name")]
    status: PolicyStatus
    definition: Annotated[str, Field(title="Definition")]
    scope: EntityType
    severity: SeverityLevel
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None
    remediation_title: Annotated[
        Optional[RemediationTitleItem], Field(title="Remediation Title")
    ] = None
    remediation_url: Annotated[
        Optional[RemediationUrlItem], Field(title="Remediation Url")
    ] = None


class PolicyEvaluationListSchema(RadarBaseModel):
    pagination: PaginationSchema
    evaluations: Annotated[List[PolicyEvaluationSchema], Field(title="Evaluations")]


class PolicySchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    name: Annotated[str, Field(max_length=128, title="Name")]
    status: PolicyStatus
    definition: Annotated[str, Field(title="Definition")]
    scope: EntityType
    severity: SeverityLevel
    total_violations: Annotated[int, Field(title="Total Violations")]
    total_evaluations: Annotated[int, Field(title="Total Evaluations")]
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None
    latest_evaluation: Optional[PolicyEvaluationSchema] = None
    remediation_title: Annotated[
        Optional[RemediationTitleItem], Field(title="Remediation Title")
    ] = None
    remediation_url: Annotated[
        Optional[RemediationUrlItem], Field(title="Remediation Url")
    ] = None


class PolicyUpdateRequestSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    name: Annotated[Optional[NameItem], Field(title="Name")] = None
    status: Optional[PolicyStatus] = None
    definition: Annotated[Optional[str], Field(title="Definition")] = None
    severity: Optional[SeverityLevel] = None
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None
    remediation_title: Annotated[
        Optional[RemediationTitleItem], Field(title="Remediation Title")
    ] = None
    remediation_url: Annotated[
        Optional[RemediationUrlItem], Field(title="Remediation Url")
    ] = None


class SearchListSchema(RadarBaseModel):
    pagination: PaginationSchema
    results: Annotated[Optional[List[SearchResultSchema]], Field(title="Results")] = []


class DatasetListSchema(RadarBaseModel):
    pagination: PaginationSchema
    datasets: Annotated[List[DatasetSchema], Field(title="Datasets")]


class DatasetVersionCreateRequestSchema(RadarBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    name: Annotated[str, Field(max_length=128, title="Name")]
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None
    external_uri: Annotated[str, Field(max_length=256, title="External Uri")]
    version: Annotated[Optional[VersionItem], Field(title="Version")] = None
    files: Annotated[Optional[List[File]], Field(title="Files")] = None


class PipelineListSchema(RadarBaseModel):
    pagination: PaginationSchema
    pipelines: Annotated[List[PipelineSchema], Field(title="Pipelines")]


class PipelineRunListSchema(RadarBaseModel):
    pagination: PaginationSchema
    pipeline_runs: Annotated[List[PipelineRunSchema], Field(title="Pipeline Runs")]


class PipelineRunWithPipelineSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    external_run_url: Annotated[
        Optional[ExternalRunUrlItem], Field(title="External Run Url")
    ] = None
    external_run_id: Annotated[
        Optional[ExternalRunIdItem], Field(title="External Run Id")
    ] = None
    platform: Annotated[Optional[PlatformItem], Field(title="Platform")] = None
    model_count: Annotated[Optional[int], Field(title="Model Count")] = 0
    run_at: Annotated[datetime, Field(title="Run At")]
    completed_at: Annotated[Optional[datetime], Field(title="Completed At")] = None
    status: PipelineRunState
    git_info: Optional[GitInfo] = None
    pipeline: PipelineSchema
    adjacent_runs: Annotated[
        Optional[List[AdjacentRun]], Field(title="Adjacent Runs")
    ] = None


class PolicyListSchema(RadarBaseModel):
    pagination: PaginationSchema
    policies: Annotated[List[PolicySchema], Field(title="Policies")]


class ArtifactPipelineRunsSchema(RadarBaseModel):
    primary_run: Optional[PipelineRunWithPipelineSchema] = None
    secondary_runs: Annotated[
        Optional[List[PipelineRunWithPipelineSchema]], Field(title="Secondary Runs")
    ] = []


class PipelineRunAssocation(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    pipeline_run: PipelineRunWithPipelineSchema


class ModelVersionDatasetListSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    file_count: Annotated[int, Field(title="File Count")]
    version: Annotated[str, Field(max_length=64, title="Version")]
    external_uri: Annotated[str, Field(max_length=256, title="External Uri")]
    properties: Annotated[Optional[Dict[str, str]], Field(title="Properties")] = None
    evaluation_status: Optional[PolicyEvaluationResult] = None
    primary_pipeline_run_association: Optional[PipelineRunAssocation] = None
    model_scan_result: Optional[ModelScanResultSchemaOutput] = None
    model: ModelBaseSchema
    bom_available: Annotated[bool, Field(title="Bom Available")]


class ModelVersionSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    file_count: Annotated[int, Field(title="File Count")]
    version: Annotated[str, Field(max_length=64, title="Version")]
    external_uri: Annotated[str, Field(max_length=256, title="External Uri")]
    properties: Annotated[Optional[Dict[str, str]], Field(title="Properties")] = None
    evaluation_status: Optional[PolicyEvaluationResult] = None
    primary_pipeline_run_association: Optional[PipelineRunAssocation] = None
    model_scan_result: Optional[ModelScanResultSchemaOutput] = None


class ModelVersionWithModelSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    file_count: Annotated[int, Field(title="File Count")]
    version: Annotated[str, Field(max_length=64, title="Version")]
    external_uri: Annotated[str, Field(max_length=256, title="External Uri")]
    properties: Annotated[Optional[Dict[str, str]], Field(title="Properties")] = None
    evaluation_status: Optional[PolicyEvaluationResult] = None
    primary_pipeline_run_association: Optional[PipelineRunAssocation] = None
    model_scan_result: Optional[ModelScanResultSchemaOutput] = None
    model: ModelBaseSchema
    bom_available: Annotated[bool, Field(title="Bom Available")]
    direction: Optional[ArtifactDirection] = None
    files: Annotated[Optional[List[File]], Field(title="Files")] = None


class DeploymentSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    environment: Annotated[str, Field(max_length=256, title="Environment")]
    build_time: Annotated[datetime, Field(title="Build Time")]
    application_url: Annotated[
        Optional[ApplicationUrlItem], Field(title="Application Url")
    ] = None
    build_url: Annotated[Optional[BuildUrlItem], Field(title="Build Url")] = None
    model_versions: Annotated[
        Optional[List[ModelVersionWithModelSchema]], Field(title="Model Versions")
    ] = None
    application_version: Annotated[
        Optional[ApplicationVersionItem], Field(title="Application Version")
    ] = None


class ModelSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    name: Annotated[str, Field(max_length=128, title="Name")]
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None
    version_count: Annotated[int, Field(title="Version Count")]
    latest_version: Optional[ModelVersionSchema] = None


class ModelVersionListSchema(RadarBaseModel):
    pagination: PaginationSchema
    versions: Annotated[List[ModelVersionWithModelSchema], Field(title="Versions")]


class ApplicationSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    name: Annotated[str, Field(max_length=128, title="Name")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    external_url: Annotated[Optional[ExternalUrlItem], Field(title="External Url")] = (
        None
    )
    total_deployment_count: Annotated[
        Optional[int], Field(title="Total Deployment Count")
    ] = 0
    latest_deployment: Optional[DeploymentSchema] = None
    description: Annotated[Optional[DescriptionItem], Field(title="Description")] = None


class DeploymentWithApplicationSchema(RadarBaseModel):
    created_at: Annotated[datetime, Field(title="Created At")]
    updated_at: Annotated[datetime, Field(title="Updated At")]
    uuid: Annotated[str, Field(max_length=256, title="Uuid")]
    environment: Annotated[str, Field(max_length=256, title="Environment")]
    build_time: Annotated[datetime, Field(title="Build Time")]
    application_url: Annotated[
        Optional[ApplicationUrlItem], Field(title="Application Url")
    ] = None
    build_url: Annotated[Optional[BuildUrlItem], Field(title="Build Url")] = None
    model_versions: Annotated[
        Optional[List[ModelVersionWithModelSchema]], Field(title="Model Versions")
    ] = None
    application: ApplicationSchema


class DeploymentsListSchema(RadarBaseModel):
    pagination: PaginationSchema
    deployments: Annotated[
        List[DeploymentWithApplicationSchema], Field(title="Deployments")
    ]


class ModelListSchema(RadarBaseModel):
    pagination: PaginationSchema
    models: Annotated[List[ModelSchema], Field(title="Models")]


class ApplicationListSchema(RadarBaseModel):
    pagination: PaginationSchema
    applications: Annotated[List[ApplicationSchema], Field(title="Applications")]
