# 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 zitadel_client.models.user_service_display_name_query import UserServiceDisplayNameQuery
from zitadel_client.models.user_service_email_query import UserServiceEmailQuery
from zitadel_client.models.user_service_first_name_query import UserServiceFirstNameQuery
from zitadel_client.models.user_service_in_user_emails_query import UserServiceInUserEmailsQuery
from zitadel_client.models.user_service_in_user_id_query import UserServiceInUserIDQuery
from zitadel_client.models.user_service_last_name_query import UserServiceLastNameQuery
from zitadel_client.models.user_service_login_name_query import UserServiceLoginNameQuery
from zitadel_client.models.user_service_nick_name_query import UserServiceNickNameQuery
from zitadel_client.models.user_service_organization_id_query import UserServiceOrganizationIdQuery
from zitadel_client.models.user_service_phone_query import UserServicePhoneQuery
from zitadel_client.models.user_service_state_query import UserServiceStateQuery
from zitadel_client.models.user_service_type_query import UserServiceTypeQuery
from zitadel_client.models.user_service_user_name_query import UserServiceUserNameQuery
from typing import Optional, Set
from typing_extensions import Self

class UserServiceSearchQuery(BaseModel):
    """
    UserServiceSearchQuery
    """ # noqa: E501
    user_name_query: Optional[UserServiceUserNameQuery] = Field(default=None, alias="userNameQuery")
    first_name_query: Optional[UserServiceFirstNameQuery] = Field(default=None, alias="firstNameQuery")
    last_name_query: Optional[UserServiceLastNameQuery] = Field(default=None, alias="lastNameQuery")
    nick_name_query: Optional[UserServiceNickNameQuery] = Field(default=None, alias="nickNameQuery")
    display_name_query: Optional[UserServiceDisplayNameQuery] = Field(default=None, alias="displayNameQuery")
    email_query: Optional[UserServiceEmailQuery] = Field(default=None, alias="emailQuery")
    state_query: Optional[UserServiceStateQuery] = Field(default=None, alias="stateQuery")
    type_query: Optional[UserServiceTypeQuery] = Field(default=None, alias="typeQuery")
    login_name_query: Optional[UserServiceLoginNameQuery] = Field(default=None, alias="loginNameQuery")
    in_user_ids_query: Optional[UserServiceInUserIDQuery] = Field(default=None, alias="inUserIdsQuery")
    or_query: Optional[UserServiceOrQuery] = Field(default=None, alias="orQuery")
    and_query: Optional[UserServiceAndQuery] = Field(default=None, alias="andQuery")
    not_query: Optional[UserServiceNotQuery] = Field(default=None, alias="notQuery")
    in_user_emails_query: Optional[UserServiceInUserEmailsQuery] = Field(default=None, alias="inUserEmailsQuery")
    organization_id_query: Optional[UserServiceOrganizationIdQuery] = Field(default=None, alias="organizationIdQuery")
    phone_query: Optional[UserServicePhoneQuery] = Field(default=None, alias="phoneQuery")

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

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

        _obj = cls.model_validate({
            "userNameQuery": UserServiceUserNameQuery.from_dict(obj["userNameQuery"]) if obj.get("userNameQuery") is not None else None,
            "firstNameQuery": UserServiceFirstNameQuery.from_dict(obj["firstNameQuery"]) if obj.get("firstNameQuery") is not None else None,
            "lastNameQuery": UserServiceLastNameQuery.from_dict(obj["lastNameQuery"]) if obj.get("lastNameQuery") is not None else None,
            "nickNameQuery": UserServiceNickNameQuery.from_dict(obj["nickNameQuery"]) if obj.get("nickNameQuery") is not None else None,
            "displayNameQuery": UserServiceDisplayNameQuery.from_dict(obj["displayNameQuery"]) if obj.get("displayNameQuery") is not None else None,
            "emailQuery": UserServiceEmailQuery.from_dict(obj["emailQuery"]) if obj.get("emailQuery") is not None else None,
            "stateQuery": UserServiceStateQuery.from_dict(obj["stateQuery"]) if obj.get("stateQuery") is not None else None,
            "typeQuery": UserServiceTypeQuery.from_dict(obj["typeQuery"]) if obj.get("typeQuery") is not None else None,
            "loginNameQuery": UserServiceLoginNameQuery.from_dict(obj["loginNameQuery"]) if obj.get("loginNameQuery") is not None else None,
            "inUserIdsQuery": UserServiceInUserIDQuery.from_dict(obj["inUserIdsQuery"]) if obj.get("inUserIdsQuery") is not None else None,
            "orQuery": UserServiceOrQuery.from_dict(obj["orQuery"]) if obj.get("orQuery") is not None else None,
            "andQuery": UserServiceAndQuery.from_dict(obj["andQuery"]) if obj.get("andQuery") is not None else None,
            "notQuery": UserServiceNotQuery.from_dict(obj["notQuery"]) if obj.get("notQuery") is not None else None,
            "inUserEmailsQuery": UserServiceInUserEmailsQuery.from_dict(obj["inUserEmailsQuery"]) if obj.get("inUserEmailsQuery") is not None else None,
            "organizationIdQuery": UserServiceOrganizationIdQuery.from_dict(obj["organizationIdQuery"]) if obj.get("organizationIdQuery") is not None else None,
            "phoneQuery": UserServicePhoneQuery.from_dict(obj["phoneQuery"]) if obj.get("phoneQuery") is not None else None
        })
        return _obj

from zitadel_client.models.user_service_and_query import UserServiceAndQuery
from zitadel_client.models.user_service_not_query import UserServiceNotQuery
from zitadel_client.models.user_service_or_query import UserServiceOrQuery
# TODO: Rewrite to not use raise_errors
UserServiceSearchQuery.model_rebuild(raise_errors=False)

