# 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.user import User
from typing import Optional, Set
from typing_extensions import Self

class Reply(BaseModel):
    """
    A reply to a comment on a file. Some resource methods (such as `replies.update`) require a `replyId`. Use the `replies.list` method to retrieve the ID for a reply.
    """ # noqa: E501
    action: Optional[StrictStr] = Field(default=None, description="The action the reply performed to the parent comment. Valid values are: * `resolve` * `reopen`")
    author: Optional[User] = None
    content: Optional[StrictStr] = Field(default=None, description="The plain text content of the reply. This field is used for setting the content, while `htmlContent` should be displayed. This is required on creates if no `action` is specified.")
    created_time: Optional[datetime] = Field(default=None, description="The time at which the reply was created (RFC 3339 date-time).", alias="createdTime")
    deleted: Optional[StrictBool] = Field(default=None, description="Output only. Whether the reply has been deleted. A deleted reply has no content.")
    html_content: Optional[StrictStr] = Field(default=None, description="Output only. The content of the reply with HTML formatting.", alias="htmlContent")
    id: Optional[StrictStr] = Field(default=None, description="Output only. The ID of the reply.")
    kind: Optional[StrictStr] = Field(default='drive#reply', description="Output only. Identifies what kind of resource this is. Value: the fixed string `\"drive#reply\"`.")
    modified_time: Optional[datetime] = Field(default=None, description="The last time the reply was modified (RFC 3339 date-time).", alias="modifiedTime")
    __properties: ClassVar[List[str]] = ["action", "author", "content", "createdTime", "deleted", "htmlContent", "id", "kind", "modifiedTime"]

    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 Reply 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 author
        if self.author:
            _dict['author'] = self.author.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "action": obj.get("action"),
            "author": User.from_dict(obj["author"]) if obj.get("author") is not None else None,
            "content": obj.get("content"),
            "createdTime": obj.get("createdTime"),
            "deleted": obj.get("deleted"),
            "htmlContent": obj.get("htmlContent"),
            "id": obj.get("id"),
            "kind": obj.get("kind") if obj.get("kind") is not None else 'drive#reply',
            "modifiedTime": obj.get("modifiedTime")
        })
        return _obj


