# coding: utf-8

"""
    Acre Platform User API

    # CORS CORS is implemented by all Acre API endpoints and only certain hostnames are allowed for each deployment of the API. If your use case requires calling the Acre User API from a browser, please contact Acre to arrange the appropriate configuration. # API Authentication The primary method of authentication for users of the Acre API is with the use of JSON Web Tokens (JWTs), which are suplemented by an application specific API Key. The API key must be provided through the `X-API-KEY` HTTP header and will be provided by your Acre Customer Success Manager. The JWT must be provided through a cookie with key of `authorization`. The JWT must be generated and signed as per the following section. # Generating JWTs JWT must either be generated by a third-party such as Azure ADB2C that has been configured for the appropriate service and/or user account, or alternatively can be generated locally and signed by an private key for which the public key has been made available to Acre via a JWKS URL. In addition to being signed by your private key, the JWT will also need to contain at a minimum:  * An issuer `iss`, which must be a valid URI previously agreed with Acre.  * A subject `sub`, which must be a unique identifier for the user and/or service account previously agreed with Acre.  * An expiry time `exp` which must not be more than four hours in the future.  * A not before time `nbf` which must be in the past, but not greater than six hours in the past.  The JWT should be signed using RS256.

    The version of the OpenAPI document: 1.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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from acre_api.models.source_name import SourceName
from typing import Optional, Set
from typing_extensions import Self

class CdmGetClientRequest(BaseModel):
    """
    Get clients with their latest version. By default, the request is a wildcard. Wildcard without filters is disabled. Wildcards must specify exactly 1 filter.
    """ # noqa: E501
    client_details: Optional[StrictBool] = Field(default=None, description="Return the entire client details. By default this value is false and ClientDetails is returned with the same fields as when show_summary is true.")
    show_protected: Optional[List[StrictStr]] = Field(default=None, description="The protected fields, specified using elpspath expression, to unobfuscate when sending client data back to the caller. If not set, all protected fields stay obfuscated.")
    show_summary: Optional[StrictBool] = Field(default=None, description="Show only summary of the client when sending client data back to the caller (default false). Requires the same permissions as client_details=true and show_protected=true.")
    client_ids: Optional[List[StrictStr]] = Field(default=None, description="Return clients by IDs. If set, then the request is not a wildcard. Incompatible with \"filter_organisation_id\", \"filter_email_address\", \"filter_client_ext_ids\", \"filter_ext_ids\" and \"filter_ext_source\".")
    filter_organisation_id: Optional[StrictStr] = Field(default=None, description="Return all clients by organisation. If set, then the request is not a wildcard. Incompatible with \"client_ids\", \"filter_email_address\", \"filter_client_ext_ids\", \"filter_ext_ids and \"filter_ext_source\".")
    filter_email_address: Optional[StrictStr] = Field(default=None, description="Return all clients with a matching contact_details_email field. If set, then the request is not a wildcard. Incompatible with \"client_ids\", \"filter_organisation_id\", \"filter_client_ext_ids\", \"filter_ext_ids\" and \"filter_ext_source\".")
    filter_client_ext_ids: Optional[List[StrictStr]] = Field(default=None, description="Return clients by their IDs, as registered in external systems. To be deprecated and replaced by filter_ext_ids. Does not support \"bookmark\". Incompatible with \"client_ids\", \"filter_email_address\", \"filter_organisation_id\", \"filter_ext_ids\" and \"filter_ext_source\".")
    filter_ext_ids: Optional[List[StrictStr]] = Field(default=None, description="Returns clients with the specified client external IDs. This filter must be used in conjunction with filter_ext_source. This will replace filter_client_ext_ids.")
    filter_ext_source: Optional[SourceName] = SourceName.INVALID_SOURCE_NAME
    filter_order_reverse: Optional[StrictBool] = Field(default=None, description="Reverse the order of the filtered results. Incompatible with \"client_ids\", \"filter_organisation_id\", \"filter_client_ext_ids\" and \"filter_ext_ids\". Defaults to false and results are returned in reverse creation order (newest to oldest).")
    bookmark: Optional[StrictStr] = Field(default=None, description="Opaque pagination bookmark. Set to the empty string (or omit) to begin.")
    page_size: Optional[StrictInt] = Field(default=None, description="Specify a limit on the number of items returned in a page. Values that are too large will be rejected. All requests are subject to the page size, which is 100 if not specified and can be specified up to 200.")
    show_history: Optional[StrictInt] = Field(default=None, description="Specify the number of previous versions to show change details for, 0 will show all versions.")
    __properties: ClassVar[List[str]] = ["client_details", "show_protected", "show_summary", "client_ids", "filter_organisation_id", "filter_email_address", "filter_client_ext_ids", "filter_ext_ids", "filter_ext_source", "filter_order_reverse", "bookmark", "page_size", "show_history"]

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

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

        _obj = cls.model_validate({
            "client_details": obj.get("client_details"),
            "show_protected": obj.get("show_protected"),
            "show_summary": obj.get("show_summary"),
            "client_ids": obj.get("client_ids"),
            "filter_organisation_id": obj.get("filter_organisation_id"),
            "filter_email_address": obj.get("filter_email_address"),
            "filter_client_ext_ids": obj.get("filter_client_ext_ids"),
            "filter_ext_ids": obj.get("filter_ext_ids"),
            "filter_ext_source": obj.get("filter_ext_source") if obj.get("filter_ext_source") is not None else SourceName.INVALID_SOURCE_NAME,
            "filter_order_reverse": obj.get("filter_order_reverse"),
            "bookmark": obj.get("bookmark"),
            "page_size": obj.get("page_size"),
            "show_history": obj.get("show_history")
        })
        return _obj


