# coding: utf-8

"""
    Synthetic Users

     **Description**: Synthetic Users provides AI-powered, human-like participants for user and market research, streamlining data collection and insight generation. With multi-agent architecture, it simulates realistic, scalable interactions, enabling efficient research through synthetic interviews and surveys.  **Features**: - **In-depth Interviews**: Interactive, AI-driven interviews with customizable follow-up options. - **Global Surveys**: Fast, quantitative data collection at scale. - **Customizable Synthetic Users**: Integrate proprietary data for tailored research. - **Multi-agent Framework**: Mimics real human interactions for accurate insights.  **Use Cases**: - **Product Testing**: Identify needs and refine concepts. - **Market Analysis**: Expand reach and enhance user satisfaction.    For more information, visit [Synthetic Users](https://www.syntheticusers.com).

    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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from syntheticusers.models.project import Project
from typing import Optional, Set
from typing_extensions import Self

class Workspace(BaseModel):
    """
    Schema for the output of a workspace containing all the workspace's data
    """ # noqa: E501
    id: StrictStr
    name: Optional[StrictStr] = None
    description: Optional[StrictStr] = None
    owner_id: Optional[StrictStr] = Field(default=None, alias="ownerId")
    owners: Optional[List[StrictStr]] = None
    owners_emails: Optional[List[StrictStr]] = Field(default=None, alias="ownersEmails")
    created_at: datetime = Field(alias="createdAt")
    projects: Optional[List[Project]] = None
    subscription_id: Optional[StrictStr] = Field(default=None, alias="subscriptionId")
    active_subscription: Optional[StrictBool] = Field(default=None, alias="activeSubscription")
    subscription_email: Optional[StrictStr] = Field(default=None, alias="subscriptionEmail")
    __properties: ClassVar[List[str]] = ["id", "name", "description", "ownerId", "owners", "ownersEmails", "createdAt", "projects", "subscriptionId", "activeSubscription", "subscriptionEmail"]

    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 Workspace 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,
        )
        # override the default output from pydantic by calling `to_dict()` of each item in projects (list)
        _items = []
        if self.projects:
            for _item_projects in self.projects:
                if _item_projects:
                    _items.append(_item_projects.to_dict())
            _dict['projects'] = _items
        # set to None if name (nullable) is None
        # and model_fields_set contains the field
        if self.name is None and "name" in self.model_fields_set:
            _dict['name'] = None

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

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

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

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

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Workspace 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"),
            "name": obj.get("name"),
            "description": obj.get("description"),
            "ownerId": obj.get("ownerId"),
            "owners": obj.get("owners"),
            "ownersEmails": obj.get("ownersEmails"),
            "createdAt": obj.get("createdAt"),
            "projects": [Project.from_dict(_item) for _item in obj["projects"]] if obj.get("projects") is not None else None,
            "subscriptionId": obj.get("subscriptionId"),
            "activeSubscription": obj.get("activeSubscription"),
            "subscriptionEmail": obj.get("subscriptionEmail")
        })
        return _obj


