# coding: utf-8

"""
    Zitadel SDK

    The Zitadel SDK is a convenience wrapper around the Zitadel APIs to assist you in integrating with your Zitadel environment. This SDK enables you to handle resources, settings, and configurations within the Zitadel platform.

    The version of the OpenAPI document: 1.0.0
    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
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from zitadel_client.models.user_service_hashed_password import UserServiceHashedPassword
from zitadel_client.models.user_service_idp_link import UserServiceIDPLink
from zitadel_client.models.user_service_organization import UserServiceOrganization
from zitadel_client.models.user_service_password import UserServicePassword
from zitadel_client.models.user_service_set_human_email import UserServiceSetHumanEmail
from zitadel_client.models.user_service_set_human_phone import UserServiceSetHumanPhone
from zitadel_client.models.user_service_set_human_profile import UserServiceSetHumanProfile
from zitadel_client.models.user_service_set_metadata_entry import UserServiceSetMetadataEntry
from typing import Optional, Set
from typing_extensions import Self

class UserServiceAddHumanUserRequest(BaseModel):
    """
    UserServiceAddHumanUserRequest
    """ # noqa: E501
    user_id: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=200)]] = Field(default=None, description="optionally set your own id unique for the user.", alias="userId")
    username: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=200)]] = Field(default=None, description="optionally set a unique username, if none is provided the email will be used.")
    organization: Optional[UserServiceOrganization] = None
    profile: UserServiceSetHumanProfile
    email: UserServiceSetHumanEmail
    phone: Optional[UserServiceSetHumanPhone] = None
    metadata: Optional[List[UserServiceSetMetadataEntry]] = None
    password: Optional[UserServicePassword] = None
    hashed_password: Optional[UserServiceHashedPassword] = Field(default=None, alias="hashedPassword")
    idp_links: Optional[List[UserServiceIDPLink]] = Field(default=None, alias="idpLinks")
    totp_secret: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=200)]] = Field(default=None, description="An Implementation of RFC 6238 is used, with HMAC-SHA-1 and time-step of 30 seconds. Currently no other options are supported, and if anything different is used the validation will fail.", alias="totpSecret")

    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 UserServiceAddHumanUserRequest 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 UserServiceAddHumanUserRequest from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "userId": obj.get("userId"),
            "username": obj.get("username"),
            "organization": UserServiceOrganization.from_dict(obj["organization"]) if obj.get("organization") is not None else None,
            "profile": UserServiceSetHumanProfile.from_dict(obj["profile"]) if obj.get("profile") is not None else None,
            "email": UserServiceSetHumanEmail.from_dict(obj["email"]) if obj.get("email") is not None else None,
            "phone": UserServiceSetHumanPhone.from_dict(obj["phone"]) if obj.get("phone") is not None else None,
            "metadata": [UserServiceSetMetadataEntry.from_dict(_item) for _item in obj["metadata"]] if obj.get("metadata") is not None else None,
            "password": UserServicePassword.from_dict(obj["password"]) if obj.get("password") is not None else None,
            "hashedPassword": UserServiceHashedPassword.from_dict(obj["hashedPassword"]) if obj.get("hashedPassword") is not None else None,
            "idpLinks": [UserServiceIDPLink.from_dict(_item) for _item in obj["idpLinks"]] if obj.get("idpLinks") is not None else None,
            "totpSecret": obj.get("totpSecret")
        })
        return _obj


