# coding: utf-8

"""
    kameleo-local-api

    You can use the following API endpoints to communicate with the local running Kameleo programmatically.

    The version of the OpenAPI document: 4.3.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 kameleo.local_api_client.models.profile_minutes_quota import ProfileMinutesQuota
from kameleo.local_api_client.models.quota_statistics import QuotaStatistics
from kameleo.local_api_client.models.running_profiles_statistics import RunningProfilesStatistics
from typing import Optional, Set
from typing_extensions import Self

class UserInfoResponse(BaseModel):
    """
    UserInfoResponse
    """ # noqa: E501
    user_id: StrictStr = Field(description="Unique identifier for the user in Guid v4 format.", alias="userId")
    display_name: StrictStr = Field(description="The display name of the user, updated on each login.", alias="displayName")
    email: StrictStr = Field(description="The email address of the user.")
    email_confirmed: StrictBool = Field(description="Indicates if the user's email address has been verified.", alias="emailConfirmed")
    subscription_end: datetime = Field(description="The subscription end date for the user. If the user is part of a team, this is the team's subscription end date.", alias="subscriptionEnd")
    plan: StrictStr = Field(description="The subscription plan associated with the user.")
    capabilities: List[StrictStr] = Field(description="List of features available to the user based on their current subscription or their team's subscription.")
    grace_period: StrictBool = Field(description="Indicates if the user's subscription is currently in a grace period and requires instant renewal.", alias="gracePeriod")
    last_app_login: datetime = Field(description="The date and time of the user's last login via the app.", alias="lastAppLogin")
    workspace_folder: StrictStr = Field(description="Path to the user's workspace folder where profiles are stored. Modifying these files outside of Kameleo is strictly prohibited.", alias="workspaceFolder")
    local_storage: QuotaStatistics = Field(description="Current usage and maximum limit for local profiles.", alias="localStorage")
    cloud_storage: QuotaStatistics = Field(description="Current usage and maximum limit for cloud profiles.", alias="cloudStorage")
    has_team_subscription: StrictBool = Field(description="Indicates if the user has a team subscription. This can also be true if the user does not have any team members yet.", alias="hasTeamSubscription")
    team_id: Optional[StrictStr] = Field(default=None, description="The team ID if the user is part of a team.", alias="teamId")
    team_role: Optional[StrictStr] = Field(default=None, description="The user's role within the team, such as 'owner' or 'member'.", alias="teamRole")
    running_user_profiles: Optional[RunningProfilesStatistics] = Field(default=None, description="Current usage and maximum limit of running manual and automated profiles for the logged-in user.", alias="runningUserProfiles")
    running_team_profiles: Optional[RunningProfilesStatistics] = Field(default=None, description="Current usage and maximum limit of running manual and automated profiles across the user's team.", alias="runningTeamProfiles")
    running_tenant_profiles: Optional[RunningProfilesStatistics] = Field(default=None, description="Current usage and maximum limit of running manual and automated profiles across the tenant.", alias="runningTenantProfiles")
    profile_minutes: Optional[ProfileMinutesQuota] = Field(default=None, description="Current usage and maximum limit of profile minutes across the tenant.", alias="profileMinutes")
    __properties: ClassVar[List[str]] = ["userId", "displayName", "email", "emailConfirmed", "subscriptionEnd", "plan", "capabilities", "gracePeriod", "lastAppLogin", "workspaceFolder", "localStorage", "cloudStorage", "hasTeamSubscription", "teamId", "teamRole", "runningUserProfiles", "runningTeamProfiles", "runningTenantProfiles", "profileMinutes"]

    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 UserInfoResponse 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 local_storage
        if self.local_storage:
            _dict['localStorage'] = self.local_storage.to_dict()
        # override the default output from pydantic by calling `to_dict()` of cloud_storage
        if self.cloud_storage:
            _dict['cloudStorage'] = self.cloud_storage.to_dict()
        # override the default output from pydantic by calling `to_dict()` of running_user_profiles
        if self.running_user_profiles:
            _dict['runningUserProfiles'] = self.running_user_profiles.to_dict()
        # override the default output from pydantic by calling `to_dict()` of running_team_profiles
        if self.running_team_profiles:
            _dict['runningTeamProfiles'] = self.running_team_profiles.to_dict()
        # override the default output from pydantic by calling `to_dict()` of running_tenant_profiles
        if self.running_tenant_profiles:
            _dict['runningTenantProfiles'] = self.running_tenant_profiles.to_dict()
        # override the default output from pydantic by calling `to_dict()` of profile_minutes
        if self.profile_minutes:
            _dict['profileMinutes'] = self.profile_minutes.to_dict()
        # set to None if team_id (nullable) is None
        # and model_fields_set contains the field
        if self.team_id is None and "team_id" in self.model_fields_set:
            _dict['teamId'] = None

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

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of UserInfoResponse 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"),
            "displayName": obj.get("displayName"),
            "email": obj.get("email"),
            "emailConfirmed": obj.get("emailConfirmed"),
            "subscriptionEnd": obj.get("subscriptionEnd"),
            "plan": obj.get("plan"),
            "capabilities": obj.get("capabilities"),
            "gracePeriod": obj.get("gracePeriod"),
            "lastAppLogin": obj.get("lastAppLogin"),
            "workspaceFolder": obj.get("workspaceFolder"),
            "localStorage": QuotaStatistics.from_dict(obj["localStorage"]) if obj.get("localStorage") is not None else None,
            "cloudStorage": QuotaStatistics.from_dict(obj["cloudStorage"]) if obj.get("cloudStorage") is not None else None,
            "hasTeamSubscription": obj.get("hasTeamSubscription"),
            "teamId": obj.get("teamId"),
            "teamRole": obj.get("teamRole"),
            "runningUserProfiles": RunningProfilesStatistics.from_dict(obj["runningUserProfiles"]) if obj.get("runningUserProfiles") is not None else None,
            "runningTeamProfiles": RunningProfilesStatistics.from_dict(obj["runningTeamProfiles"]) if obj.get("runningTeamProfiles") is not None else None,
            "runningTenantProfiles": RunningProfilesStatistics.from_dict(obj["runningTenantProfiles"]) if obj.get("runningTenantProfiles") is not None else None,
            "profileMinutes": ProfileMinutesQuota.from_dict(obj["profileMinutes"]) if obj.get("profileMinutes") is not None else None
        })
        return _obj


