# 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 GoogleDriveServiceAccountCredentials(BaseModel):
    """
    Credentials for Google Drive service account authentication.  Service accounts provide server-to-server authentication for Google Drive without requiring user interaction. They are ideal for automated sync operations.  Prerequisites:     - Create a service account in Google Cloud Console     - Enable Google Drive API for the project     - Download the JSON key file     - Share target Drive files/folders with the service account email  Security:     - private_key field is encrypted at rest using MongoDB client-side field level encryption     - Credentials never appear in logs or API responses     - Use domain-wide delegation for G Suite environments  Use Cases:     - Automated ingestion pipelines from shared drives     - Scheduled sync operations without user interaction     - Service-to-service integration for enterprise deployments
    """ # noqa: E501
    type: Optional[StrictStr] = 'service_account'
    project_id: StrictStr = Field(description="REQUIRED. Google Cloud project ID where the service account was created. Found in the JSON key file as 'project_id'. Format: lowercase alphanumeric with hyphens (e.g., 'my-project-123').")
    private_key_id: StrictStr = Field(description="REQUIRED. Unique identifier for the private key. Found in the JSON key file as 'private_key_id'. Format: 40-character hexadecimal string.")
    private_key: StrictStr = Field(description="REQUIRED. PEM-encoded RSA private key for authentication. Found in the JSON key file as 'private_key'. SECURITY: This field is encrypted at rest. Never log or expose this value. Format: Must include BEGIN/END PRIVATE KEY markers.")
    client_email: StrictStr = Field(description="REQUIRED. Service account email address. Found in the JSON key file as 'client_email'. Share Drive files/folders with this email to grant access. Format: {account-name}@{project-id}.iam.gserviceaccount.com")
    client_id: StrictStr = Field(description="REQUIRED. Numeric service account identifier. Found in the JSON key file as 'client_id'. Format: 21-digit numeric string.")
    __properties: ClassVar[List[str]] = ["type", "project_id", "private_key_id", "private_key", "client_email", "client_id"]

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

        if value not in set(['service_account']):
            raise ValueError("must be one of enum values ('service_account')")
        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 GoogleDriveServiceAccountCredentials 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 GoogleDriveServiceAccountCredentials 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 'service_account',
            "project_id": obj.get("project_id"),
            "private_key_id": obj.get("private_key_id"),
            "private_key": obj.get("private_key"),
            "client_email": obj.get("client_email"),
            "client_id": obj.get("client_id")
        })
        return _obj


