# This file is auto-generated by oagen. Do not edit.

from __future__ import annotations

from dataclasses import dataclass
from typing import Any

from workos._types import _raise_deserialize_error


@dataclass(slots=True)
class ConfigureDataIntegrationBody:
    """Configure Data Integration Body model."""

    enabled: bool | None = None
    """Whether the provider is enabled for the organization."""
    scopes: list[str] | None = None
    """The OAuth scopes to request for the organization. Pass `null` to inherit the provider scopes."""
    client_id: str | None = None
    """The OAuth client ID of the organization's own application. Must be provided together with `client_secret`, and only for providers whose credentials are supplied by the organization."""
    client_secret: str | None = None
    """The OAuth client secret of the organization's own application. Must be provided together with `client_id`."""
    config: dict[str, str] | None = None
    """Provider-specific config values to set for the organization, keyed by config field. Only fields the provider declares are accepted, and each value must match that field's pattern. Accepted only for providers whose credentials are organization-managed; for shared or custom credential providers, config belongs on the integration itself (via the data-integrations API) and supplying it here is rejected."""

    @classmethod
    def from_dict(cls, data: dict[str, Any]) -> ConfigureDataIntegrationBody:
        """Deserialize from a dictionary."""
        try:
            return cls(
                enabled=data.get("enabled"),
                scopes=data.get("scopes"),
                client_id=data.get("client_id"),
                client_secret=data.get("client_secret"),
                config=data.get("config"),
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("ConfigureDataIntegrationBody", e)

    def to_dict(self) -> dict[str, Any]:
        """Serialize to a dictionary."""
        result: dict[str, Any] = {}
        if self.enabled is not None:
            result["enabled"] = self.enabled
        if self.scopes is not None:
            result["scopes"] = self.scopes
        else:
            result["scopes"] = None
        if self.client_id is not None:
            result["client_id"] = self.client_id
        if self.client_secret is not None:
            result["client_secret"] = self.client_secret
        if self.config is not None:
            result["config"] = self.config
        return result
