# 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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from google_drive_ti.models.team_drive_background_image_file import TeamDriveBackgroundImageFile
from google_drive_ti.models.team_drive_capabilities import TeamDriveCapabilities
from google_drive_ti.models.team_drive_restrictions import TeamDriveRestrictions
from typing import Optional, Set
from typing_extensions import Self

class TeamDrive(BaseModel):
    """
    Deprecated: use the drive collection instead.
    """ # noqa: E501
    background_image_file: Optional[TeamDriveBackgroundImageFile] = Field(default=None, alias="backgroundImageFile")
    background_image_link: Optional[StrictStr] = Field(default=None, description="A short-lived link to this Team Drive's background image.", alias="backgroundImageLink")
    capabilities: Optional[TeamDriveCapabilities] = None
    color_rgb: Optional[StrictStr] = Field(default=None, description="The color of this Team Drive as an RGB hex string. It can only be set on a `drive.teamdrives.update` request that does not set `themeId`.", alias="colorRgb")
    created_time: Optional[datetime] = Field(default=None, description="The time at which the Team Drive was created (RFC 3339 date-time).", alias="createdTime")
    id: Optional[StrictStr] = Field(default=None, description="The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.")
    kind: Optional[StrictStr] = Field(default='drive#teamDrive', description="Identifies what kind of resource this is. Value: the fixed string `\"drive#teamDrive\"`.")
    name: Optional[StrictStr] = Field(default=None, description="The name of this Team Drive.")
    org_unit_id: Optional[StrictStr] = Field(default=None, description="The organizational unit of this shared drive. This field is only populated on `drives.list` responses when the `useDomainAdminAccess` parameter is set to `true`.", alias="orgUnitId")
    restrictions: Optional[TeamDriveRestrictions] = None
    theme_id: Optional[StrictStr] = Field(default=None, description="The ID of the theme from which the background image and color will be set. The set of possible `teamDriveThemes` can be retrieved from a `drive.about.get` response. When not specified on a `drive.teamdrives.create` request, a random theme is chosen from which the background image and color are set. This is a write-only field; it can only be set on requests that don't set `colorRgb` or `backgroundImageFile`.", alias="themeId")
    __properties: ClassVar[List[str]] = ["backgroundImageFile", "backgroundImageLink", "capabilities", "colorRgb", "createdTime", "id", "kind", "name", "orgUnitId", "restrictions", "themeId"]

    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 TeamDrive 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 background_image_file
        if self.background_image_file:
            _dict['backgroundImageFile'] = self.background_image_file.to_dict()
        # override the default output from pydantic by calling `to_dict()` of capabilities
        if self.capabilities:
            _dict['capabilities'] = self.capabilities.to_dict()
        # override the default output from pydantic by calling `to_dict()` of restrictions
        if self.restrictions:
            _dict['restrictions'] = self.restrictions.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "backgroundImageFile": TeamDriveBackgroundImageFile.from_dict(obj["backgroundImageFile"]) if obj.get("backgroundImageFile") is not None else None,
            "backgroundImageLink": obj.get("backgroundImageLink"),
            "capabilities": TeamDriveCapabilities.from_dict(obj["capabilities"]) if obj.get("capabilities") is not None else None,
            "colorRgb": obj.get("colorRgb"),
            "createdTime": obj.get("createdTime"),
            "id": obj.get("id"),
            "kind": obj.get("kind") if obj.get("kind") is not None else 'drive#teamDrive',
            "name": obj.get("name"),
            "orgUnitId": obj.get("orgUnitId"),
            "restrictions": TeamDriveRestrictions.from_dict(obj["restrictions"]) if obj.get("restrictions") is not None else None,
            "themeId": obj.get("themeId")
        })
        return _obj


