# coding: utf-8

"""
    Google Drive API

    The Google Drive API allows clients to access resources from Google Drive.

    The version of the OpenAPI document: v3
    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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from google_drive_ti.models.about_drive_themes_inner import AboutDriveThemesInner
from google_drive_ti.models.about_storage_quota import AboutStorageQuota
from google_drive_ti.models.about_team_drive_themes_inner import AboutTeamDriveThemesInner
from google_drive_ti.models.user import User
from typing import Optional, Set
from typing_extensions import Self

class About(BaseModel):
    """
    Information about the user, the user's Drive, and system capabilities.
    """ # noqa: E501
    app_installed: Optional[StrictBool] = Field(default=None, description="Whether the user has installed the requesting app.", alias="appInstalled")
    can_create_drives: Optional[StrictBool] = Field(default=None, description="Whether the user can create shared drives.", alias="canCreateDrives")
    can_create_team_drives: Optional[StrictBool] = Field(default=None, description="Deprecated: Use `canCreateDrives` instead.", alias="canCreateTeamDrives")
    drive_themes: Optional[List[AboutDriveThemesInner]] = Field(default=None, description="A list of themes that are supported for shared drives.", alias="driveThemes")
    export_formats: Optional[Dict[str, Any]] = Field(default=None, description="A map of source MIME type to possible targets for all supported exports.", alias="exportFormats")
    folder_color_palette: Optional[List[StrictStr]] = Field(default=None, description="The currently supported folder colors as RGB hex strings.", alias="folderColorPalette")
    import_formats: Optional[Dict[str, Any]] = Field(default=None, description="A map of source MIME type to possible targets for all supported imports.", alias="importFormats")
    kind: Optional[StrictStr] = Field(default='drive#about', description="Identifies what kind of resource this is. Value: the fixed string `\"drive#about\"`.")
    max_import_sizes: Optional[Dict[str, Any]] = Field(default=None, description="A map of maximum import sizes by MIME type, in bytes.", alias="maxImportSizes")
    max_upload_size: Optional[StrictStr] = Field(default=None, description="The maximum upload size in bytes.", alias="maxUploadSize")
    storage_quota: Optional[AboutStorageQuota] = Field(default=None, alias="storageQuota")
    team_drive_themes: Optional[List[AboutTeamDriveThemesInner]] = Field(default=None, description="Deprecated: Use `driveThemes` instead.", alias="teamDriveThemes")
    user: Optional[User] = None
    __properties: ClassVar[List[str]] = ["appInstalled", "canCreateDrives", "canCreateTeamDrives", "driveThemes", "exportFormats", "folderColorPalette", "importFormats", "kind", "maxImportSizes", "maxUploadSize", "storageQuota", "teamDriveThemes", "user"]

    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 About 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 drive_themes (list)
        _items = []
        if self.drive_themes:
            for _item_drive_themes in self.drive_themes:
                if _item_drive_themes:
                    _items.append(_item_drive_themes.to_dict())
            _dict['driveThemes'] = _items
        # override the default output from pydantic by calling `to_dict()` of storage_quota
        if self.storage_quota:
            _dict['storageQuota'] = self.storage_quota.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in team_drive_themes (list)
        _items = []
        if self.team_drive_themes:
            for _item_team_drive_themes in self.team_drive_themes:
                if _item_team_drive_themes:
                    _items.append(_item_team_drive_themes.to_dict())
            _dict['teamDriveThemes'] = _items
        # override the default output from pydantic by calling `to_dict()` of user
        if self.user:
            _dict['user'] = self.user.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "appInstalled": obj.get("appInstalled"),
            "canCreateDrives": obj.get("canCreateDrives"),
            "canCreateTeamDrives": obj.get("canCreateTeamDrives"),
            "driveThemes": [AboutDriveThemesInner.from_dict(_item) for _item in obj["driveThemes"]] if obj.get("driveThemes") is not None else None,
            "exportFormats": obj.get("exportFormats"),
            "folderColorPalette": obj.get("folderColorPalette"),
            "importFormats": obj.get("importFormats"),
            "kind": obj.get("kind") if obj.get("kind") is not None else 'drive#about',
            "maxImportSizes": obj.get("maxImportSizes"),
            "maxUploadSize": obj.get("maxUploadSize"),
            "storageQuota": AboutStorageQuota.from_dict(obj["storageQuota"]) if obj.get("storageQuota") is not None else None,
            "teamDriveThemes": [AboutTeamDriveThemesInner.from_dict(_item) for _item in obj["teamDriveThemes"]] if obj.get("teamDriveThemes") is not None else None,
            "user": User.from_dict(obj["user"]) if obj.get("user") is not None else None
        })
        return _obj


