# coding: utf-8
"""
    Snowflake Image Repository API

    The Snowflake Image Repository API is a REST API that you can use to access, update, and perform common actions on Image Repository resource in Snowflake.  # noqa: E501

    The version of the OpenAPI document: 0.0.1
    Contact: support@snowflake.com
    Generated by: https://openapi-generator.tech

    Do not edit this file manually.
"""

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

from typing import Union

from datetime import datetime

from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator

from typing import Any, ClassVar, Dict, List, Optional

from typing_extensions import Annotated


class ImageRepository(BaseModel):

    name: Annotated[str, Field(strict=True)]

    database_name: Optional[Annotated[str, Field(strict=True)]] = None

    schema_name: Optional[Annotated[str, Field(strict=True)]] = None

    created_on: Optional[datetime] = None

    repository_url: Optional[StrictStr] = None

    owner: Optional[StrictStr] = None

    owner_role_type: Optional[StrictStr] = None

    __properties = [
        "name", "database_name", "schema_name", "created_on", "repository_url",
        "owner", "owner_role_type"
    ]

    @field_validator('name')
    def name_validate_regular_expression(cls, v):

        if not re.match(r"""^\"([^\"]|\"\")+\"|[a-zA-Z_][a-zA-Z0-9_$]*$""", v):
            raise ValueError(
                r"""must validate the regular expression /^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$/"""
            )
        return v

    @field_validator('database_name')
    def database_name_validate_regular_expression(cls, v):

        if v is None:
            return v
        if not re.match(r"""^\"([^\"]|\"\")+\"|[a-zA-Z_][a-zA-Z0-9_$]*$""", v):
            raise ValueError(
                r"""must validate the regular expression /^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$/"""
            )
        return v

    @field_validator('schema_name')
    def schema_name_validate_regular_expression(cls, v):

        if v is None:
            return v
        if not re.match(r"""^\"([^\"]|\"\")+\"|[a-zA-Z_][a-zA-Z0-9_$]*$""", v):
            raise ValueError(
                r"""must validate the regular expression /^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$/"""
            )
        return v

    class Config:
        populate_by_name = True
        validate_assignment = True

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

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

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

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = dict(
            self._iter(to_dict=True,
                       by_alias=True,
                       exclude={
                           "created_on",
                           "repository_url",
                           "owner",
                           "owner_role_type",
                       },
                       exclude_none=True))

        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> ImageRepository:
        """Create an instance of ImageRepository from a dict"""

        if obj is None:
            return None

        if type(obj) is not dict:
            return ImageRepository.parse_obj(obj)

        _obj = ImageRepository.parse_obj({
            "name":
            obj.get("name"),
            "database_name":
            obj.get("database_name"),
            "schema_name":
            obj.get("schema_name"),
            "created_on":
            obj.get("created_on"),
            "repository_url":
            obj.get("repository_url"),
            "owner":
            obj.get("owner"),
            "owner_role_type":
            obj.get("owner_role_type"),
        })

        return _obj


from typing import Optional, List, Dict


class ImageRepositoryModel():

    def __init__(
        self,
        name: str,
        # optional properties
        database_name: Optional[str] = None,
        schema_name: Optional[str] = None,
        created_on: Optional[datetime] = None,
        repository_url: Optional[str] = None,
        owner: Optional[str] = None,
        owner_role_type: Optional[str] = None,
    ):

        self.name = name
        self.database_name = database_name
        self.schema_name = schema_name
        self.created_on = created_on
        self.repository_url = repository_url
        self.owner = owner
        self.owner_role_type = owner_role_type

    __properties = [
        "name", "database_name", "schema_name", "created_on", "repository_url",
        "owner", "owner_role_type"
    ]

    def _to_model(self):
        return ImageRepository(
            name=self.name,
            database_name=self.database_name,
            schema_name=self.schema_name,
            created_on=self.created_on,
            repository_url=self.repository_url,
            owner=self.owner,
            owner_role_type=self.owner_role_type,
        )

    @classmethod
    def _from_model(cls, model) -> ImageRepositoryModel:
        return ImageRepositoryModel(
            name=model.name,
            database_name=model.database_name,
            schema_name=model.schema_name,
            created_on=model.created_on,
            repository_url=model.repository_url,
            owner=model.owner,
            owner_role_type=model.owner_role_type,
        )

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        return self._to_model().to_dict()

    @classmethod
    def from_dict(cls, obj: dict) -> ImageRepositoryModel:
        """Create an instance of ImageRepository from a dict"""
        return cls._from_model(ImageRepository.from_dict(obj))


ImageRepository._model_class = ImageRepositoryModel
