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

from __future__ import annotations

from enum import Enum
from typing import Any, Dict, List, Optional

from pydantic import BaseModel, Field, constr


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


class DdmsInterface(BaseModel):
    entityType: Optional[constr(pattern=r"^[A-Za-z0-9-]{2,50}")] = None
    schema_: Dict[str, Any] = Field(..., alias="schema")


class TestActionResult(BaseModel):
    url: Optional[str] = None
    errors: Optional[str] = None


class CreatedOnEpoch(BaseModel):
    seconds: Optional[int] = None
    nanos: Optional[int] = None


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


class Data(BaseModel):
    msg: Optional[str] = Field(None, example="Hello")
    uri: Optional[str] = Field(None, example="https://myproj.com/abc123")


class Legal(BaseModel):
    legaltags: Optional[List[str]] = None
    otherRelevantDataCountries: Optional[List[str]] = None


class Filter(BaseModel):
    entityType: Optional[List[constr(pattern=r"^[a-z0-9-]{0,50}")]] = None
    source: Optional[List[constr(pattern=r"^[a-z0-9-]{0,50}")]] = None
    version: Optional[List[constr(pattern=r"^[0-9.]{0,10}")]] = None


class GetSubscriptionResult(BaseModel):
    id: Optional[str] = Field(None, example="dGVzdC1uYW1l")
    name: Optional[str] = Field(None, example="test-subscription")
    description: Optional[str] = Field(None, example="test description")
    topic: Optional[str] = Field(None, example="data-changed-v1")
    pushEndpoint: Optional[str] = Field(None, example="https://myListener.com")
    createdBy: Optional[str] = Field(None, example="test@myapp.com")
    notificationId: Optional[str] = Field(
        None, example="de-6ee609b9-620e-477b-86f9-3b8907643a12"
    )


class SecretType(Enum):
    HMAC = "HMAC"
    GSA = "GSA"


class Secret(BaseModel):
    secretType: Optional[SecretType] = None
    value: Optional[Dict[str, Any]] = Field(None, example="hmacsecret")


class CreatedOnEpochModel(BaseModel):
    seconds: Optional[int] = Field(None, example=1572275081)
    nanos: Optional[int] = Field(None, example=51000000)


class TopicExample(BaseModel):
    id: Optional[str] = Field(None, example="common:test:123")
    kind: Optional[str] = Field(None, example="common:source:type:1.0.0")
    op: Optional[str] = Field(None, example="deleted")


class ConnectedOuterService(BaseModel):
    name: Optional[str] = Field(None, description="Connected outer service name.")
    version: Optional[str] = Field(None, description="Connected outer service version.")


class Ddms(BaseModel):
    id: Optional[constr(pattern=r"^[A-Za-z0-9-]{2,50}")] = None
    name: Optional[constr(pattern=r"^[A-Za-z0-9- ]{2,50}")] = None
    description: Optional[constr(pattern=r"^[A-Za-z0-9. ]{0,255}")] = None
    contactEmail: Optional[str] = None
    interfaces: Optional[List[DdmsInterface]] = None


class CreateAction(BaseModel):
    id: Optional[constr(pattern=r"^[A-Za-z0-9-]{2,50}")] = None
    name: Optional[constr(pattern=r"^[A-Za-z0-9- ]{2,50}")] = None
    description: Optional[constr(pattern=r"^[A-Za-z0-9. ]{0,255}")] = None
    contactEmail: Optional[str] = None
    img: Optional[constr(pattern=r"http[s]*\S+")] = Field(
        None,
        description="Reference link to an image file that can be usd in an UI to represent the action.",
    )
    url: Optional[constr(pattern=r"http[s]*\S+")] = Field(
        None, example="https://myapp.osdu.com/action/{type}/{id}"
    )
    filter: Optional[Filter] = None


class TestAction(BaseModel):
    action: Optional[CreateAction] = None
    testPayload: Optional[Dict[str, Any]] = None


class Action(BaseModel):
    id: Optional[str] = None
    name: Optional[str] = None
    description: Optional[str] = None
    contactEmail: Optional[str] = None
    img: Optional[str] = None
    url: Optional[str] = Field(
        None, example="https://myapp.osdu.com/action/{type}/{id}"
    )
    filter: Optional[Filter] = None
    createdOnEpoch: Optional[CreatedOnEpoch] = None


class Record(BaseModel):
    id: Optional[str] = None
    kind: Optional[str] = None
    acl: Optional[Acl] = None
    legal: Optional[Legal] = None
    data: Optional[Data] = None


class Subscription(BaseModel):
    name: Optional[constr(pattern=r"^[A-Za-z0-9- ]{2,50}")] = Field(
        None, example="test-subscription"
    )
    description: Optional[constr(pattern=r"^[A-Za-z0-9. ]{0,255}")] = Field(
        None, example="test description"
    )
    topic: Optional[str] = Field(None, example="data-changed-v1")
    pushEndpoint: Optional[str] = Field(None, example="https://myListener.com")
    secret: Optional[Secret] = None


class SubscriptionCreateResult(BaseModel):
    id: Optional[str] = Field(None, example="dGVzdC1uYW1l")
    name: Optional[constr(pattern=r"^[A-Za-z0-9- ]{2,50}")] = Field(
        None, example="test-subscription"
    )
    description: Optional[constr(pattern=r"^[A-Za-z0-9. ]{0,255}")] = Field(
        None, example="test description"
    )
    topic: Optional[str] = Field(None, example="data-changed-v1")
    pushEndpoint: Optional[str] = Field(None, example="https://myListener.com")
    createdBy: Optional[str] = Field(None, example="test@myapp.com")
    notificationId: Optional[str] = Field(
        None, example="de-6ee609b9-620e-477b-86f9-3b8907643a12"
    )
    createdOnEpoch: Optional[CreatedOnEpochModel] = None
    secret: Optional[Secret] = None


class Topic(BaseModel):
    name: Optional[str] = Field(None, example="records-changed")
    description: Optional[str] = Field(
        None,
        example="This notification is sent whenever a record is created, updated or deleted.",
    )
    state: Optional[str] = Field(None, example="ACTIVE")
    example: Optional[List[TopicExample]] = None


class VersionInfo(BaseModel):
    groupId: Optional[str] = Field(None, description="Maven artifact group ID.")
    actifactId: Optional[str] = Field(None, description="Maven artifact ID.")
    version: Optional[str] = Field(None, description="Maven artifact version")
    buildTime: Optional[str] = Field(None, description="Maven artifact build time")
    branch: Optional[str] = Field(None, description="Current git branch")
    commitId: Optional[str] = Field(None, description="Latest commit hash")
    commitMessage: Optional[str] = Field(None, description="Latest commit message")
    connectedOuterServices: Optional[List[ConnectedOuterService]] = Field(
        None, description="Connected outer services information"
    )
