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

class Channel(BaseModel):
    """
    A notification channel used to watch for resource changes.
    """ # noqa: E501
    address: Optional[StrictStr] = Field(default=None, description="The address where notifications are delivered for this channel.")
    expiration: Optional[StrictStr] = Field(default=None, description="Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional.")
    id: Optional[StrictStr] = Field(default=None, description="A UUID or similar unique string that identifies this channel.")
    kind: Optional[StrictStr] = Field(default='api#channel', description="Identifies this as a notification channel used to watch for changes to a resource, which is `api#channel`.")
    params: Optional[Dict[str, Any]] = Field(default=None, description="Additional parameters controlling delivery channel behavior. Optional.")
    payload: Optional[StrictBool] = Field(default=None, description="A Boolean value to indicate whether payload is wanted. Optional.")
    resource_id: Optional[StrictStr] = Field(default=None, description="An opaque ID that identifies the resource being watched on this channel. Stable across different API versions.", alias="resourceId")
    resource_uri: Optional[StrictStr] = Field(default=None, description="A version-specific identifier for the watched resource.", alias="resourceUri")
    token: Optional[StrictStr] = Field(default=None, description="An arbitrary string delivered to the target address with each notification delivered over this channel. Optional.")
    type: Optional[StrictStr] = Field(default=None, description="The type of delivery mechanism used for this channel. Valid values are \"web_hook\" or \"webhook\".")
    __properties: ClassVar[List[str]] = ["address", "expiration", "id", "kind", "params", "payload", "resourceId", "resourceUri", "token", "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 Channel 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "address": obj.get("address"),
            "expiration": obj.get("expiration"),
            "id": obj.get("id"),
            "kind": obj.get("kind") if obj.get("kind") is not None else 'api#channel',
            "params": obj.get("params"),
            "payload": obj.get("payload"),
            "resourceId": obj.get("resourceId"),
            "resourceUri": obj.get("resourceUri"),
            "token": obj.get("token"),
            "type": obj.get("type")
        })
        return _obj


