# coding: utf-8

"""
    Mixpeek API

    This is the Mixpeek API, providing access to various endpoints for data processing and retrieval.

    The version of the OpenAPI document: 1.3.0
    Contact: info@mixpeek.com
    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, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class GoogleDriveOAuthCredentials(BaseModel):
    """
    Credentials for Google Drive OAuth2 user authentication.  OAuth2 credentials provide access to Google Drive on behalf of a specific user. This authentication method is suitable when accessing personal Drive files or when service account delegation is not available.  Prerequisites:     - Create OAuth 2.0 credentials in Google Cloud Console     - Configure authorized redirect URIs     - Complete OAuth consent flow to obtain refresh token     - Ensure appropriate OAuth scopes are granted (drive.readonly or drive)  Security:     - client_secret and refresh_token are encrypted at rest     - Access tokens are automatically refreshed and cached temporarily     - Credentials are scoped to the user who granted consent  Use Cases:     - Personal Drive file access for individual users     - Prototyping and development without service account setup     - Environments where service account delegation is not feasible  Limitations:     - Requires user interaction during initial setup     - Access is limited to files the consenting user can access     - Refresh tokens can be revoked by the user
    """ # noqa: E501
    type: Optional[StrictStr] = 'oauth'
    client_id: StrictStr = Field(description="REQUIRED. OAuth 2.0 client ID from Google Cloud Console. Found in the API credentials section. Format: {id}.apps.googleusercontent.com")
    client_secret: StrictStr = Field(description="REQUIRED. OAuth 2.0 client secret from Google Cloud Console. SECURITY: This field is encrypted at rest. Never log or expose this value. Format: Alphanumeric string from Google Cloud Console.")
    refresh_token: StrictStr = Field(description="REQUIRED. Long-lived refresh token obtained during OAuth consent flow. Used to automatically obtain new access tokens without user interaction. SECURITY: Encrypted at rest. Can be revoked by user at any time. Obtain via: Complete OAuth flow with drive.readonly or drive scope.")
    __properties: ClassVar[List[str]] = ["type", "client_id", "client_secret", "refresh_token"]

    @field_validator('type')
    def type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['oauth']):
            raise ValueError("must be one of enum values ('oauth')")
        return value

    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 GoogleDriveOAuthCredentials 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 GoogleDriveOAuthCredentials from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "type": obj.get("type") if obj.get("type") is not None else 'oauth',
            "client_id": obj.get("client_id"),
            "client_secret": obj.get("client_secret"),
            "refresh_token": obj.get("refresh_token")
        })
        return _obj


