# coding: utf-8

"""
    File Service API v2 - Token and Tenant Management

    File Service API v2 - Token and tenant management endpoints

    The version of the OpenAPI document: 0.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 datetime import datetime
from pydantic import BaseModel, ConfigDict, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class Tenant(BaseModel):
    """
    Class representing a tenant object.  This class is used to store information about tenants, combining what's stored in the registry and what's stored in the authn provider.  Attributes ---------- provider_tenant_id (str): The provider's tenant id. provider_name (str): The provider's name/type (e.g. Zitadel or Okta). name (str): The tenant name (comes from ProviderTenant object). state (str): The tenant state (comes from ProviderTenant object). primary_domain (str): The primary domain used by the tenant (comes from ProviderTenant object). object_store_id (UUID): The object store id associated with the tenant. If None the default object store is used.
    """ # noqa: E501
    id: StrictStr
    created: datetime
    provider_tenant_id: StrictStr
    provider_name: StrictStr
    state: Optional[StrictStr] = None
    primary_domain: Optional[StrictStr] = None
    object_store_id: Optional[StrictStr] = None
    name: Optional[StrictStr] = None
    label: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["id", "created", "provider_tenant_id", "provider_name", "state", "primary_domain", "object_store_id", "name", "label"]

    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 Tenant 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,
        )
        # set to None if state (nullable) is None
        # and model_fields_set contains the field
        if self.state is None and "state" in self.model_fields_set:
            _dict['state'] = None

        # set to None if primary_domain (nullable) is None
        # and model_fields_set contains the field
        if self.primary_domain is None and "primary_domain" in self.model_fields_set:
            _dict['primary_domain'] = None

        # set to None if object_store_id (nullable) is None
        # and model_fields_set contains the field
        if self.object_store_id is None and "object_store_id" in self.model_fields_set:
            _dict['object_store_id'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Tenant from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "created": obj.get("created"),
            "provider_tenant_id": obj.get("provider_tenant_id"),
            "provider_name": obj.get("provider_name"),
            "state": obj.get("state"),
            "primary_domain": obj.get("primary_domain"),
            "object_store_id": obj.get("object_store_id"),
            "name": obj.get("name"),
            "label": obj.get("label")
        })
        return _obj
