# coding: utf-8

"""
    Snowstorm

    SNOMED CT Terminology Server REST API

    The version of the OpenAPI document: 10.8.2
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class ExportConfiguration(BaseModel):
    """
    ExportConfiguration
    """ # noqa: E501
    id: Optional[StrictStr] = None
    start_date: Optional[datetime] = Field(default=None, alias="startDate")
    branch_path: StrictStr = Field(alias="branchPath")
    type: StrictStr
    filename_effective_date: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, alias="filenameEffectiveDate")
    concepts_and_relationships_only: Optional[StrictBool] = Field(default=False, alias="conceptsAndRelationshipsOnly")
    unpromoted_changes_only: Optional[StrictBool] = Field(default=False, alias="unpromotedChangesOnly")
    legacy_zip_naming: Optional[StrictBool] = Field(default=False, alias="legacyZipNaming")
    transient_effective_time: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="Format: yyyymmdd. Add a transient effectiveTime to rows of content which are not yet versioned.", alias="transientEffectiveTime")
    start_effective_time: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="Format: yyyymmdd. Can be used to produce a delta after content is versioned by filtering a SNAPSHOT export by effectiveTime.", alias="startEffectiveTime")
    module_ids: Optional[List[StrictStr]] = Field(default=None, alias="moduleIds")
    refset_ids: Optional[List[StrictStr]] = Field(default=None, description="If refsetIds are included, this indicates that the export will be a refset-only export.", alias="refsetIds")
    status: Optional[StrictStr] = 'PENDING'
    export_file_path: Optional[StrictStr] = Field(default=None, alias="exportFilePath")
    start_export: Optional[StrictBool] = Field(default=False, alias="startExport")
    __properties: ClassVar[List[str]] = ["id", "startDate", "branchPath", "type", "filenameEffectiveDate", "conceptsAndRelationshipsOnly", "unpromotedChangesOnly", "legacyZipNaming", "transientEffectiveTime", "startEffectiveTime", "moduleIds", "refsetIds", "status", "exportFilePath", "startExport"]

    @field_validator('type')
    def type_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['DELTA', 'SNAPSHOT', 'FULL']):
            raise ValueError("must be one of enum values ('DELTA', 'SNAPSHOT', 'FULL')")
        return value

    @field_validator('filename_effective_date')
    def filename_effective_date_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if value is None:
            return value

        if not re.match(r"[0-9]{8}", value):
            raise ValueError(r"must validate the regular expression /[0-9]{8}/")
        return value

    @field_validator('transient_effective_time')
    def transient_effective_time_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if value is None:
            return value

        if not re.match(r"[0-9]{8}", value):
            raise ValueError(r"must validate the regular expression /[0-9]{8}/")
        return value

    @field_validator('start_effective_time')
    def start_effective_time_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if value is None:
            return value

        if not re.match(r"[0-9]{8}", value):
            raise ValueError(r"must validate the regular expression /[0-9]{8}/")
        return value

    @field_validator('status')
    def status_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['PENDING', 'RUNNING', 'COMPLETED', 'DOWNLOADED', 'FAILED']):
            raise ValueError("must be one of enum values ('PENDING', 'RUNNING', 'COMPLETED', 'DOWNLOADED', 'FAILED')")
        return value

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of ExportConfiguration from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of ExportConfiguration from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "startDate": obj.get("startDate"),
            "branchPath": obj.get("branchPath"),
            "type": obj.get("type") if obj.get("type") is not None else 'DELTA',
            "filenameEffectiveDate": obj.get("filenameEffectiveDate"),
            "conceptsAndRelationshipsOnly": obj.get("conceptsAndRelationshipsOnly") if obj.get("conceptsAndRelationshipsOnly") is not None else False,
            "unpromotedChangesOnly": obj.get("unpromotedChangesOnly") if obj.get("unpromotedChangesOnly") is not None else False,
            "legacyZipNaming": obj.get("legacyZipNaming") if obj.get("legacyZipNaming") is not None else False,
            "transientEffectiveTime": obj.get("transientEffectiveTime"),
            "startEffectiveTime": obj.get("startEffectiveTime"),
            "moduleIds": obj.get("moduleIds"),
            "refsetIds": obj.get("refsetIds"),
            "status": obj.get("status") if obj.get("status") is not None else 'PENDING',
            "exportFilePath": obj.get("exportFilePath"),
            "startExport": obj.get("startExport") if obj.get("startExport") is not None else False
        })
        return _obj


