# This file was auto-generated by Fern from our API Definition.

from __future__ import annotations

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from .raw_client import AsyncRawWorkspaceClient, RawWorkspaceClient

if typing.TYPE_CHECKING:
    from .analytics.client import AnalyticsClient, AsyncAnalyticsClient
    from .audit_logs.client import AsyncAuditLogsClient, AuditLogsClient
    from .auth_connections.client import AsyncAuthConnectionsClient, AuthConnectionsClient
    from .groups.client import AsyncGroupsClient, GroupsClient
    from .invites.client import AsyncInvitesClient, InvitesClient
    from .members.client import AsyncMembersClient, MembersClient
    from .resources.client import AsyncResourcesClient, ResourcesClient
    from .usage.client import AsyncUsageClient, UsageClient
# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class WorkspaceClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawWorkspaceClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._audit_logs: typing.Optional[AuditLogsClient] = None
        self._auth_connections: typing.Optional[AuthConnectionsClient] = None
        self._groups: typing.Optional[GroupsClient] = None
        self._invites: typing.Optional[InvitesClient] = None
        self._members: typing.Optional[MembersClient] = None
        self._resources: typing.Optional[ResourcesClient] = None
        self._usage: typing.Optional[UsageClient] = None
        self._analytics: typing.Optional[AnalyticsClient] = None

    @property
    def with_raw_response(self) -> RawWorkspaceClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawWorkspaceClient
        """
        return self._raw_client

    def set_third_party_disabling_policy(
        self,
        *,
        third_party_disable_allowed: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Set the workspace-wide Third-Party Disabling policy. When set, it forces, for every API key in the workspace, whether the holder of a key (potentially a third party who found it) may disable it via the self-disable endpoint or when it leaks publicly — overriding each key's own setting. Pass `true` to allow it for all keys, `false` to forbid it for all keys, or `null` to clear the override so per-key values and the plan default apply again. Workspace admins only.

        Parameters
        ----------
        third_party_disable_allowed : typing.Optional[bool]
            `true` forces every key in the workspace to be disable-able by its holder; `false` forbids it for every key; `null` clears the override (per-key values and the plan default apply).

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.workspace.set_third_party_disabling_policy()
        """
        _response = self._raw_client.set_third_party_disabling_policy(
            third_party_disable_allowed=third_party_disable_allowed, request_options=request_options
        )
        return _response.data

    @property
    def audit_logs(self):
        if self._audit_logs is None:
            from .audit_logs.client import AuditLogsClient  # noqa: E402

            self._audit_logs = AuditLogsClient(client_wrapper=self._client_wrapper)
        return self._audit_logs

    @property
    def auth_connections(self):
        if self._auth_connections is None:
            from .auth_connections.client import AuthConnectionsClient  # noqa: E402

            self._auth_connections = AuthConnectionsClient(client_wrapper=self._client_wrapper)
        return self._auth_connections

    @property
    def groups(self):
        if self._groups is None:
            from .groups.client import GroupsClient  # noqa: E402

            self._groups = GroupsClient(client_wrapper=self._client_wrapper)
        return self._groups

    @property
    def invites(self):
        if self._invites is None:
            from .invites.client import InvitesClient  # noqa: E402

            self._invites = InvitesClient(client_wrapper=self._client_wrapper)
        return self._invites

    @property
    def members(self):
        if self._members is None:
            from .members.client import MembersClient  # noqa: E402

            self._members = MembersClient(client_wrapper=self._client_wrapper)
        return self._members

    @property
    def resources(self):
        if self._resources is None:
            from .resources.client import ResourcesClient  # noqa: E402

            self._resources = ResourcesClient(client_wrapper=self._client_wrapper)
        return self._resources

    @property
    def usage(self):
        if self._usage is None:
            from .usage.client import UsageClient  # noqa: E402

            self._usage = UsageClient(client_wrapper=self._client_wrapper)
        return self._usage

    @property
    def analytics(self):
        if self._analytics is None:
            from .analytics.client import AnalyticsClient  # noqa: E402

            self._analytics = AnalyticsClient(client_wrapper=self._client_wrapper)
        return self._analytics


class AsyncWorkspaceClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawWorkspaceClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._audit_logs: typing.Optional[AsyncAuditLogsClient] = None
        self._auth_connections: typing.Optional[AsyncAuthConnectionsClient] = None
        self._groups: typing.Optional[AsyncGroupsClient] = None
        self._invites: typing.Optional[AsyncInvitesClient] = None
        self._members: typing.Optional[AsyncMembersClient] = None
        self._resources: typing.Optional[AsyncResourcesClient] = None
        self._usage: typing.Optional[AsyncUsageClient] = None
        self._analytics: typing.Optional[AsyncAnalyticsClient] = None

    @property
    def with_raw_response(self) -> AsyncRawWorkspaceClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawWorkspaceClient
        """
        return self._raw_client

    async def set_third_party_disabling_policy(
        self,
        *,
        third_party_disable_allowed: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Set the workspace-wide Third-Party Disabling policy. When set, it forces, for every API key in the workspace, whether the holder of a key (potentially a third party who found it) may disable it via the self-disable endpoint or when it leaks publicly — overriding each key's own setting. Pass `true` to allow it for all keys, `false` to forbid it for all keys, or `null` to clear the override so per-key values and the plan default apply again. Workspace admins only.

        Parameters
        ----------
        third_party_disable_allowed : typing.Optional[bool]
            `true` forces every key in the workspace to be disable-able by its holder; `false` forbids it for every key; `null` clears the override (per-key values and the plan default apply).

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.workspace.set_third_party_disabling_policy()


        asyncio.run(main())
        """
        _response = await self._raw_client.set_third_party_disabling_policy(
            third_party_disable_allowed=third_party_disable_allowed, request_options=request_options
        )
        return _response.data

    @property
    def audit_logs(self):
        if self._audit_logs is None:
            from .audit_logs.client import AsyncAuditLogsClient  # noqa: E402

            self._audit_logs = AsyncAuditLogsClient(client_wrapper=self._client_wrapper)
        return self._audit_logs

    @property
    def auth_connections(self):
        if self._auth_connections is None:
            from .auth_connections.client import AsyncAuthConnectionsClient  # noqa: E402

            self._auth_connections = AsyncAuthConnectionsClient(client_wrapper=self._client_wrapper)
        return self._auth_connections

    @property
    def groups(self):
        if self._groups is None:
            from .groups.client import AsyncGroupsClient  # noqa: E402

            self._groups = AsyncGroupsClient(client_wrapper=self._client_wrapper)
        return self._groups

    @property
    def invites(self):
        if self._invites is None:
            from .invites.client import AsyncInvitesClient  # noqa: E402

            self._invites = AsyncInvitesClient(client_wrapper=self._client_wrapper)
        return self._invites

    @property
    def members(self):
        if self._members is None:
            from .members.client import AsyncMembersClient  # noqa: E402

            self._members = AsyncMembersClient(client_wrapper=self._client_wrapper)
        return self._members

    @property
    def resources(self):
        if self._resources is None:
            from .resources.client import AsyncResourcesClient  # noqa: E402

            self._resources = AsyncResourcesClient(client_wrapper=self._client_wrapper)
        return self._resources

    @property
    def usage(self):
        if self._usage is None:
            from .usage.client import AsyncUsageClient  # noqa: E402

            self._usage = AsyncUsageClient(client_wrapper=self._client_wrapper)
        return self._usage

    @property
    def analytics(self):
        if self._analytics is None:
            from .analytics.client import AsyncAnalyticsClient  # noqa: E402

            self._analytics = AsyncAnalyticsClient(client_wrapper=self._client_wrapper)
        return self._analytics
