# coding: utf-8

"""
    IGVF Project API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 108.0.1
    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 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 InstitutionalCertificate(BaseModel):
    """
    An institutional certificate defining the data sharing limitations for data authorized for submission to the IGVF portal.
    """ # noqa: E501
    preview_timestamp: Optional[StrictStr] = Field(default=None, description="The date the object was previewed.")
    release_timestamp: Optional[StrictStr] = Field(default=None, description="The date the object was released.")
    status: Optional[StrictStr] = Field(default=None, description="The status of the metadata object.")
    lab: Optional[StrictStr] = Field(default=None, description="Lab associated with the submission.")
    award: Optional[StrictStr] = Field(default=None, description="Grant associated with the submission.")
    schema_version: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="The version of the JSON schema that the server uses to validate the object.")
    uuid: Optional[StrictStr] = Field(default=None, description="The unique identifier associated with every object.")
    notes: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="DACC internal notes.")
    aliases: Optional[List[Annotated[str, Field(strict=True)]]] = Field(default=None, description="Lab specific identifiers to reference an object.")
    creation_timestamp: Optional[StrictStr] = Field(default=None, description="The date the object was created.")
    submitted_by: Optional[StrictStr] = Field(default=None, description="The user who submitted the object.")
    submitter_comment: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="Additional information specified by the submitter to be displayed as a comment on the portal.")
    description: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="A plain text description of the object.")
    certificate_identifier: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="A unique identifier for the certificate.")
    controlled_access: Optional[StrictBool] = Field(default=None, description="Indicator of whether the samples are under controlled access.")
    data_use_limitation: Optional[StrictStr] = Field(default=None, description="Code indicating the limitations on data use for data generated from the applicable samples.")
    data_use_limitation_modifiers: Optional[List[StrictStr]] = Field(default=None, description="Code indicating a modifier on the limitations on data use for data generated from the applicable samples.")
    samples: Optional[List[StrictStr]] = Field(default=None, description="Samples covered by this institutional certificate.")
    urls: Optional[List[StrictStr]] = Field(default=None, description="Link to the institutional certification form.")
    partner_labs: Optional[List[StrictStr]] = Field(default=None, description="Labs which belong to same institution as the signing PI and can share this institutional certificate.")
    partner_awards: Optional[List[StrictStr]] = Field(default=None, description="Awards granted to at least one lab that belongs to same institution as the signing PI and can share this institutional certificate.")
    id: Optional[StrictStr] = Field(default=None, alias="@id")
    type: Optional[List[StrictStr]] = Field(default=None, alias="@type")
    summary: Optional[StrictStr] = Field(default=None, description="A summary of the institutional certificate.")
    data_use_limitation_summary: Optional[StrictStr] = Field(default=None, description="A combination of the data use limitation and its modifiers")
    __properties: ClassVar[List[str]] = ["preview_timestamp", "release_timestamp", "status", "lab", "award", "schema_version", "uuid", "notes", "aliases", "creation_timestamp", "submitted_by", "submitter_comment", "description", "certificate_identifier", "controlled_access", "data_use_limitation", "data_use_limitation_modifiers", "samples", "urls", "partner_labs", "partner_awards", "@id", "@type", "summary", "data_use_limitation_summary"]

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

        if value not in set(['archived', 'deleted', 'in progress', 'preview', 'released']):
            raise ValueError("must be one of enum values ('archived', 'deleted', 'in progress', 'preview', 'released')")
        return value

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

        if not re.match(r"^\d+(\.\d+)*$", value):
            raise ValueError(r"must validate the regular expression /^\d+(\.\d+)*$/")
        return value

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

        if not re.match(r"^(\S+(\s|\S)*\S+|\S)$", value):
            raise ValueError(r"must validate the regular expression /^(\S+(\s|\S)*\S+|\S)$/")
        return value

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

        if not re.match(r"^(\S+(\s|\S)*\S+|\S)$", value):
            raise ValueError(r"must validate the regular expression /^(\S+(\s|\S)*\S+|\S)$/")
        return value

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

        if not re.match(r"^(\S+(\s|\S)*\S+|\S)$", value):
            raise ValueError(r"must validate the regular expression /^(\S+(\s|\S)*\S+|\S)$/")
        return value

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

        if not re.match(r"^IP\d{3}-\d{2}$", value):
            raise ValueError(r"must validate the regular expression /^IP\d{3}-\d{2}$/")
        return value

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

        if value not in set(['DS', 'GRU', 'HMB', 'other']):
            raise ValueError("must be one of enum values ('DS', 'GRU', 'HMB', 'other')")
        return value

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

        for i in value:
            if i not in set(['COL', 'GSO', 'IRB', 'MDS', 'NPU', 'PUB']):
                raise ValueError("each list item must be one of ('COL', 'GSO', 'IRB', 'MDS', 'NPU', 'PUB')")
        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 InstitutionalCertificate 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 InstitutionalCertificate from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "preview_timestamp": obj.get("preview_timestamp"),
            "release_timestamp": obj.get("release_timestamp"),
            "status": obj.get("status"),
            "lab": obj.get("lab"),
            "award": obj.get("award"),
            "schema_version": obj.get("schema_version"),
            "uuid": obj.get("uuid"),
            "notes": obj.get("notes"),
            "aliases": obj.get("aliases"),
            "creation_timestamp": obj.get("creation_timestamp"),
            "submitted_by": obj.get("submitted_by"),
            "submitter_comment": obj.get("submitter_comment"),
            "description": obj.get("description"),
            "certificate_identifier": obj.get("certificate_identifier"),
            "controlled_access": obj.get("controlled_access"),
            "data_use_limitation": obj.get("data_use_limitation"),
            "data_use_limitation_modifiers": obj.get("data_use_limitation_modifiers"),
            "samples": obj.get("samples"),
            "urls": obj.get("urls"),
            "partner_labs": obj.get("partner_labs"),
            "partner_awards": obj.get("partner_awards"),
            "@id": obj.get("@id"),
            "@type": obj.get("@type"),
            "summary": obj.get("summary"),
            "data_use_limitation_summary": obj.get("data_use_limitation_summary")
        })
        return _obj


