# 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 SharePointClientCredentials(BaseModel):
    """
    SharePoint/OneDrive client credentials (app-only) authentication.  Client credentials flow provides application-level access without user interaction. Recommended for automated sync operations in enterprise environments.  Prerequisites:     1. Register an application in Azure AD (portal.azure.com)     2. Grant Microsoft Graph API permissions:        - Sites.Read.All (Application) - for SharePoint site access        - Files.Read.All (Application) - for file access     3. Admin consent granted for the permissions     4. Generate client secret  Security:     - client_secret encrypted at rest via CSFLE     - Provides application-level access to all sites (based on permissions)     - No user context - accesses files as the application itself     - Consider using certificate-based auth for production  Use Cases:     - Automated enterprise-wide document ingestion     - Background sync without user interaction     - Multi-tenant applications with admin consent
    """ # noqa: E501
    type: Optional[StrictStr] = 'client_credentials'
    tenant_id: StrictStr = Field(description="REQUIRED. Azure AD tenant ID (directory ID). Find in: Azure Portal > Azure Active Directory > Overview. Format: UUID (e.g., '12345678-1234-1234-1234-123456789abc')")
    client_id: StrictStr = Field(description="REQUIRED. Azure AD application (client) ID. Find in: Azure Portal > App Registrations > Your App > Overview. Format: UUID")
    client_secret: StrictStr = Field(description="REQUIRED. Azure AD client secret for authentication. SECURITY: This field is encrypted at rest via CSFLE. Never log or expose. Generate in: Azure Portal > App Registrations > Your App > Certificates & secrets. Note: Secrets expire; consider using certificates for production.")
    __properties: ClassVar[List[str]] = ["type", "tenant_id", "client_id", "client_secret"]

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

        if value not in set(['client_credentials']):
            raise ValueError("must be one of enum values ('client_credentials')")
        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 SharePointClientCredentials 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 SharePointClientCredentials 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 'client_credentials',
            "tenant_id": obj.get("tenant_id"),
            "client_id": obj.get("client_id"),
            "client_secret": obj.get("client_secret")
        })
        return _obj


