# 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, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from google_drive_ti.models.drive import Drive
from google_drive_ti.models.file import File
from google_drive_ti.models.team_drive import TeamDrive
from typing import Optional, Set
from typing_extensions import Self

class Change(BaseModel):
    """
    A change to a file or shared drive.
    """ # noqa: E501
    change_type: Optional[StrictStr] = Field(default=None, description="The type of the change. Possible values are `file` and `drive`.", alias="changeType")
    drive: Optional[Drive] = None
    drive_id: Optional[StrictStr] = Field(default=None, description="The ID of the shared drive associated with this change.", alias="driveId")
    file: Optional[File] = None
    file_id: Optional[StrictStr] = Field(default=None, description="The ID of the file which has changed.", alias="fileId")
    kind: Optional[StrictStr] = Field(default='drive#change', description="Identifies what kind of resource this is. Value: the fixed string `\"drive#change\"`.")
    removed: Optional[StrictBool] = Field(default=None, description="Whether the file or shared drive has been removed from this list of changes, for example by deletion or loss of access.")
    team_drive: Optional[TeamDrive] = Field(default=None, alias="teamDrive")
    team_drive_id: Optional[StrictStr] = Field(default=None, description="Deprecated: Use `driveId` instead.", alias="teamDriveId")
    time: Optional[datetime] = Field(default=None, description="The time of this change (RFC 3339 date-time).")
    type: Optional[StrictStr] = Field(default=None, description="Deprecated: Use `changeType` instead.")
    __properties: ClassVar[List[str]] = ["changeType", "drive", "driveId", "file", "fileId", "kind", "removed", "teamDrive", "teamDriveId", "time", "type"]

    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 Change 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 drive
        if self.drive:
            _dict['drive'] = self.drive.to_dict()
        # override the default output from pydantic by calling `to_dict()` of file
        if self.file:
            _dict['file'] = self.file.to_dict()
        # override the default output from pydantic by calling `to_dict()` of team_drive
        if self.team_drive:
            _dict['teamDrive'] = self.team_drive.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "changeType": obj.get("changeType"),
            "drive": Drive.from_dict(obj["drive"]) if obj.get("drive") is not None else None,
            "driveId": obj.get("driveId"),
            "file": File.from_dict(obj["file"]) if obj.get("file") is not None else None,
            "fileId": obj.get("fileId"),
            "kind": obj.get("kind") if obj.get("kind") is not None else 'drive#change',
            "removed": obj.get("removed"),
            "teamDrive": TeamDrive.from_dict(obj["teamDrive"]) if obj.get("teamDrive") is not None else None,
            "teamDriveId": obj.get("teamDriveId"),
            "time": obj.get("time"),
            "type": obj.get("type")
        })
        return _obj


