# coding: utf-8

"""
    CloudWalletEssentials

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

    The version of the OpenAPI document: 1.0.0
    Contact: info@affinidi.com
    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 typing import Optional
from pydantic import BaseModel, Field, StrictStr, constr, validator

class CreateWalletInput(BaseModel):
    """
    CreateWalletInput
    """
    name: Optional[StrictStr] = Field(default=None, description="The name of the wallet")
    description: Optional[StrictStr] = Field(default=None, description="The description of the wallet")
    did_method: Optional[StrictStr] = Field(default=None, alias="didMethod", description="Define how DID of your wallet is created and resolved")
    did_web_url: Optional[constr(strict=True, max_length=300)] = Field(default=None, alias="didWebUrl", description="URL of the DID. Required if the did method is web")
    __properties = ["name", "description", "didMethod", "didWebUrl"]

    @validator('did_method')
    def did_method_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in ('key', 'web', 'peer0',):
            raise ValueError("must be one of enum values ('key', 'web', 'peer0')")
        return value

    @validator('did_web_url')
    def did_web_url_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if value is None:
            return value

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

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_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) -> CreateWalletInput:
        """Create an instance of CreateWalletInput 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 = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> CreateWalletInput:
        """Create an instance of CreateWalletInput from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return CreateWalletInput.parse_obj(obj)

        _obj = CreateWalletInput.parse_obj({
            "name": obj.get("name"),
            "description": obj.get("description"),
            "did_method": obj.get("didMethod"),
            "did_web_url": obj.get("didWebUrl")
        })
        return _obj


