# generated by datamodel-codegen:
#   filename:  swagger.yaml
#   timestamp: 2024-07-12T07:32:18+00:00

from __future__ import annotations

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

from pydantic import BaseModel, Field, RootModel, constr


class Acl(BaseModel):
    viewers: Optional[List[str]] = None
    owners: Optional[List[str]] = None


class Status(Enum):
    compliant = "compliant"
    incompliant = "incompliant"


class Legal(BaseModel):
    legaltags: Optional[List[str]] = Field(None)
    otherRelevantDataCountries: List[str] = Field(...)
    status: Optional[Status] = None


class RecordAncestry(BaseModel):
    parents: Optional[List[str]] = Field(None)


class AppError(BaseModel):
    code: Optional[int] = None
    reason: Optional[str] = None
    message: Optional[str] = None


class CreateUpdateRecordsResponse(BaseModel):
    recordCount: Optional[int] = None
    recordIds: Optional[List[str]] = None
    skippedRecordIds: Optional[List[str]] = None
    recordIdVersions: Optional[List[str]] = None


class RecordVersionModel(BaseModel):
    id: Optional[str] = None
    version: Optional[str] = None


class StackTraceItem(BaseModel):
    classLoaderName: Optional[str] = None
    moduleName: Optional[str] = None
    moduleVersion: Optional[str] = None
    methodName: Optional[str] = None
    fileName: Optional[str] = None
    lineNumber: Optional[int] = None
    nativeMethod: Optional[bool] = None
    className: Optional[str] = None


class Cause(BaseModel):
    stackTrace: Optional[List[StackTraceItem]] = None
    message: Optional[str] = None
    localizedMessage: Optional[str] = None


class SuppressedItem(BaseModel):
    stackTrace: Optional[List[StackTraceItem]] = None
    message: Optional[str] = None
    localizedMessage: Optional[str] = None


class PairStringString(BaseModel):
    value: Optional[str] = None
    key: Optional[str] = None
    left: Optional[str] = None
    right: Optional[str] = None


class MultiRecordIds(BaseModel):
    records: List[str] = Field(..., max_items=100, min_items=0)
    attributes: Optional[List[str]] = None


class MultiRecordRequest(BaseModel):
    records: List[str] = Field(..., max_items=20, min_items=1)


class ConversionStatus(BaseModel):
    id: Optional[str] = None
    status: Optional[str] = None
    errors: Optional[List[str]] = None


class MultiRecordResponse(BaseModel):
    records: Optional[List[str]] = None
    notFound: Optional[List[str]] = None
    conversionStatuses: Optional[List[ConversionStatus]] = None


class PatchOperation(BaseModel):
    op: Optional[str] = None
    path: Optional[str] = None
    value: List[str]


class RecordQuery(BaseModel):
    ids: List[str] = Field(..., max_items=500, min_items=1)


class BulkUpdateRecordsResponse(BaseModel):
    recordCount: Optional[int] = None
    recordIds: Optional[List[str]] = None
    notFoundRecordIds: Optional[List[str]] = None
    unAuthorizedRecordIds: Optional[List[str]] = None
    lockedRecordIds: Optional[List[str]] = None


class JsonPatch(BaseModel):
    pass


class RecordQueryPatch(BaseModel):
    ids: Optional[List[str]] = Field(
        None,
        description="List of record ids. Each record id must follow the naming convention {Data-Partition-Id}:{dataset-name}:{record-type}:{version}.",
    )


class PatchRecordsResponse(BaseModel):
    recordCount: Optional[int] = None
    recordIds: Optional[List[str]] = None
    notFoundRecordIds: Optional[List[str]] = None
    failedRecordIds: Optional[List[str]] = None
    errors: Optional[List[str]] = None


class RecordVersions(BaseModel):
    recordId: Optional[str] = None
    versions: Optional[List[int]] = None


class DatastoreQueryResult(BaseModel):
    cursor: Optional[str] = None
    results: Optional[List[str]] = None


class ConnectedOuterService(BaseModel):
    name: Optional[str] = None
    version: Optional[str] = None


class VersionInfo(BaseModel):
    groupId: Optional[str] = None
    artifactId: Optional[str] = None
    version: Optional[str] = None
    buildTime: Optional[str] = None
    branch: Optional[str] = None
    commitId: Optional[str] = None
    commitMessage: Optional[str] = None
    connectedOuterServices: Optional[List[ConnectedOuterService]] = None


class Status1(BaseModel):
    kind: Optional[str] = None
    totalRecords: Optional[int] = None
    processedRecords: Optional[int] = None
    state: Optional[str] = None
    startedAt: Optional[date] = None
    elapsedTime: Optional[str] = None
    avgProcessingTimePerMinute: Optional[int] = None


class ReplayStatus(BaseModel):
    kind: Optional[str] = None
    replayId: str
    totalRecords: int
    processedRecords: int
    overallState: str
    startedAt: Optional[date] = None
    filter: Optional[List[Dict[str, Any]]] = None
    status: Union[List[Dict[str, Any]], Status1]


class Status2(BaseModel):
    replayId: int = Field(..., example=1000)


class Kind(RootModel[List[str]]):
    root: List[str]


class Record(BaseModel):
    id: Optional[constr(pattern=r"^[\w\-\.]+:[\w\-\.]+:[\w\-\.\:\%]+$")] = None
    version: Optional[int] = None
    kind: Optional[str] = None
    acl: Acl
    legal: Optional[Legal] = None
    data: Dict[str, Dict[str, Any]]
    ancestry: Optional[RecordAncestry] = None
    meta: Optional[List[Dict[str, Dict[str, Any]]]] = None
    tags: Optional[Dict[str, str]] = None
    createUser: Optional[str] = None
    createTime: Optional[str] = None
    modifyUser: Optional[str] = None
    modifyTime: Optional[str] = None


class CopyRecordReferencesModel(BaseModel):
    target: Optional[str] = None
    records: Optional[List[RecordVersionModel]] = None


class DeleteRecordsException(BaseModel):
    cause: Optional[Cause] = None
    stackTrace: Optional[List[StackTraceItem]] = None
    notDeletedRecords: Optional[List[PairStringString]] = None
    message: Optional[str] = None
    suppressed: Optional[List[SuppressedItem]] = None
    localizedMessage: Optional[str] = None


class MultiRecordInfo(BaseModel):
    records: Optional[List[Record]] = None
    invalidRecords: Optional[List[str]] = None
    retryRecords: Optional[List[str]] = None


class RecordBulkUpdateParam(BaseModel):
    query: RecordQuery
    ops: List[PatchOperation]


class PatchRecordsRequestModel(BaseModel):
    query: RecordQueryPatch
    ops: JsonPatch


class ReplayRequest(BaseModel):
    operation: str
    filter: Optional[Kind] = None
