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

from __future__ import annotations

import typing

import httpx
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .environment import FrameioExperimentalEnvironment

if typing.TYPE_CHECKING:
    from .account_permissions.client import AccountPermissionsClient, AsyncAccountPermissionsClient
    from .accounts.client import AccountsClient, AsyncAccountsClient
    from .collections.client import AsyncCollectionsClient, CollectionsClient
    from .comments.client import AsyncCommentsClient, CommentsClient
    from .custom_actions.client import AsyncCustomActionsClient, CustomActionsClient
    from .files.client import AsyncFilesClient, FilesClient
    from .folder_permissions.client import AsyncFolderPermissionsClient, FolderPermissionsClient
    from .folders.client import AsyncFoldersClient, FoldersClient
    from .groups.client import AsyncGroupsClient, GroupsClient
    from .metadata.client import AsyncMetadataClient, MetadataClient
    from .metadata_fields.client import AsyncMetadataFieldsClient, MetadataFieldsClient
    from .project_permissions.client import AsyncProjectPermissionsClient, ProjectPermissionsClient
    from .projects.client import AsyncProjectsClient, ProjectsClient
    from .shares.client import AsyncSharesClient, SharesClient
    from .version_stacks.client import AsyncVersionStacksClient, VersionStacksClient
    from .webhooks.client import AsyncWebhooksClient, WebhooksClient
    from .workspace_permissions.client import AsyncWorkspacePermissionsClient, WorkspacePermissionsClient
    from .workspaces.client import AsyncWorkspacesClient, WorkspacesClient


class FrameioExperimental:
    """
    Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.

    Parameters
    ----------
    base_url : typing.Optional[str]
        The base url to use for requests from the client.

    environment : FrameioExperimentalEnvironment
        The environment to use for requests from the client. from .environment import FrameioExperimentalEnvironment



        Defaults to FrameioExperimentalEnvironment.DEFAULT



    api_version : typing.Optional[typing.Literal["experimental"]]
    token : typing.Union[str, typing.Callable[[], str]]
    headers : typing.Optional[typing.Dict[str, str]]
        Additional headers to send with every request.

    timeout : typing.Optional[float]
        The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.

    follow_redirects : typing.Optional[bool]
        Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.

    httpx_client : typing.Optional[httpx.Client]
        The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.

    Examples
    --------
    from frameio_experimental import FrameioExperimental

    client = FrameioExperimental(
        api_version="YOUR_API_VERSION",
        token="YOUR_TOKEN",
    )
    """

    def __init__(
        self,
        *,
        base_url: typing.Optional[str] = None,
        environment: FrameioExperimentalEnvironment = FrameioExperimentalEnvironment.DEFAULT,
        api_version: typing.Optional[typing.Literal["experimental"]] = None,
        token: typing.Union[str, typing.Callable[[], str]],
        headers: typing.Optional[typing.Dict[str, str]] = None,
        timeout: typing.Optional[float] = None,
        follow_redirects: typing.Optional[bool] = True,
        httpx_client: typing.Optional[httpx.Client] = None,
    ):
        _defaulted_timeout = (
            timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
        )
        self._client_wrapper = SyncClientWrapper(
            base_url=_get_base_url(base_url=base_url, environment=environment),
            api_version=api_version,
            token=token,
            headers=headers,
            httpx_client=httpx_client
            if httpx_client is not None
            else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
            if follow_redirects is not None
            else httpx.Client(timeout=_defaulted_timeout),
            timeout=_defaulted_timeout,
        )
        self._custom_actions: typing.Optional[CustomActionsClient] = None
        self._metadata_fields: typing.Optional[MetadataFieldsClient] = None
        self._project_permissions: typing.Optional[ProjectPermissionsClient] = None
        self._folders: typing.Optional[FoldersClient] = None
        self._version_stacks: typing.Optional[VersionStacksClient] = None
        self._account_permissions: typing.Optional[AccountPermissionsClient] = None
        self._comments: typing.Optional[CommentsClient] = None
        self._accounts: typing.Optional[AccountsClient] = None
        self._webhooks: typing.Optional[WebhooksClient] = None
        self._workspace_permissions: typing.Optional[WorkspacePermissionsClient] = None
        self._groups: typing.Optional[GroupsClient] = None
        self._projects: typing.Optional[ProjectsClient] = None
        self._metadata: typing.Optional[MetadataClient] = None
        self._files: typing.Optional[FilesClient] = None
        self._shares: typing.Optional[SharesClient] = None
        self._folder_permissions: typing.Optional[FolderPermissionsClient] = None
        self._workspaces: typing.Optional[WorkspacesClient] = None
        self._collections: typing.Optional[CollectionsClient] = None

    @property
    def custom_actions(self):
        if self._custom_actions is None:
            from .custom_actions.client import CustomActionsClient  # noqa: E402

            self._custom_actions = CustomActionsClient(client_wrapper=self._client_wrapper)
        return self._custom_actions

    @property
    def metadata_fields(self):
        if self._metadata_fields is None:
            from .metadata_fields.client import MetadataFieldsClient  # noqa: E402

            self._metadata_fields = MetadataFieldsClient(client_wrapper=self._client_wrapper)
        return self._metadata_fields

    @property
    def project_permissions(self):
        if self._project_permissions is None:
            from .project_permissions.client import ProjectPermissionsClient  # noqa: E402

            self._project_permissions = ProjectPermissionsClient(client_wrapper=self._client_wrapper)
        return self._project_permissions

    @property
    def folders(self):
        if self._folders is None:
            from .folders.client import FoldersClient  # noqa: E402

            self._folders = FoldersClient(client_wrapper=self._client_wrapper)
        return self._folders

    @property
    def version_stacks(self):
        if self._version_stacks is None:
            from .version_stacks.client import VersionStacksClient  # noqa: E402

            self._version_stacks = VersionStacksClient(client_wrapper=self._client_wrapper)
        return self._version_stacks

    @property
    def account_permissions(self):
        if self._account_permissions is None:
            from .account_permissions.client import AccountPermissionsClient  # noqa: E402

            self._account_permissions = AccountPermissionsClient(client_wrapper=self._client_wrapper)
        return self._account_permissions

    @property
    def comments(self):
        if self._comments is None:
            from .comments.client import CommentsClient  # noqa: E402

            self._comments = CommentsClient(client_wrapper=self._client_wrapper)
        return self._comments

    @property
    def accounts(self):
        if self._accounts is None:
            from .accounts.client import AccountsClient  # noqa: E402

            self._accounts = AccountsClient(client_wrapper=self._client_wrapper)
        return self._accounts

    @property
    def webhooks(self):
        if self._webhooks is None:
            from .webhooks.client import WebhooksClient  # noqa: E402

            self._webhooks = WebhooksClient(client_wrapper=self._client_wrapper)
        return self._webhooks

    @property
    def workspace_permissions(self):
        if self._workspace_permissions is None:
            from .workspace_permissions.client import WorkspacePermissionsClient  # noqa: E402

            self._workspace_permissions = WorkspacePermissionsClient(client_wrapper=self._client_wrapper)
        return self._workspace_permissions

    @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 projects(self):
        if self._projects is None:
            from .projects.client import ProjectsClient  # noqa: E402

            self._projects = ProjectsClient(client_wrapper=self._client_wrapper)
        return self._projects

    @property
    def metadata(self):
        if self._metadata is None:
            from .metadata.client import MetadataClient  # noqa: E402

            self._metadata = MetadataClient(client_wrapper=self._client_wrapper)
        return self._metadata

    @property
    def files(self):
        if self._files is None:
            from .files.client import FilesClient  # noqa: E402

            self._files = FilesClient(client_wrapper=self._client_wrapper)
        return self._files

    @property
    def shares(self):
        if self._shares is None:
            from .shares.client import SharesClient  # noqa: E402

            self._shares = SharesClient(client_wrapper=self._client_wrapper)
        return self._shares

    @property
    def folder_permissions(self):
        if self._folder_permissions is None:
            from .folder_permissions.client import FolderPermissionsClient  # noqa: E402

            self._folder_permissions = FolderPermissionsClient(client_wrapper=self._client_wrapper)
        return self._folder_permissions

    @property
    def workspaces(self):
        if self._workspaces is None:
            from .workspaces.client import WorkspacesClient  # noqa: E402

            self._workspaces = WorkspacesClient(client_wrapper=self._client_wrapper)
        return self._workspaces

    @property
    def collections(self):
        if self._collections is None:
            from .collections.client import CollectionsClient  # noqa: E402

            self._collections = CollectionsClient(client_wrapper=self._client_wrapper)
        return self._collections


class AsyncFrameioExperimental:
    """
    Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.

    Parameters
    ----------
    base_url : typing.Optional[str]
        The base url to use for requests from the client.

    environment : FrameioExperimentalEnvironment
        The environment to use for requests from the client. from .environment import FrameioExperimentalEnvironment



        Defaults to FrameioExperimentalEnvironment.DEFAULT



    api_version : typing.Optional[typing.Literal["experimental"]]
    token : typing.Union[str, typing.Callable[[], str]]
    headers : typing.Optional[typing.Dict[str, str]]
        Additional headers to send with every request.

    timeout : typing.Optional[float]
        The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.

    follow_redirects : typing.Optional[bool]
        Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.

    httpx_client : typing.Optional[httpx.AsyncClient]
        The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.

    Examples
    --------
    from frameio_experimental import AsyncFrameioExperimental

    client = AsyncFrameioExperimental(
        api_version="YOUR_API_VERSION",
        token="YOUR_TOKEN",
    )
    """

    def __init__(
        self,
        *,
        base_url: typing.Optional[str] = None,
        environment: FrameioExperimentalEnvironment = FrameioExperimentalEnvironment.DEFAULT,
        api_version: typing.Optional[typing.Literal["experimental"]] = None,
        token: typing.Union[str, typing.Callable[[], str]],
        headers: typing.Optional[typing.Dict[str, str]] = None,
        timeout: typing.Optional[float] = None,
        follow_redirects: typing.Optional[bool] = True,
        httpx_client: typing.Optional[httpx.AsyncClient] = None,
    ):
        _defaulted_timeout = (
            timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
        )
        self._client_wrapper = AsyncClientWrapper(
            base_url=_get_base_url(base_url=base_url, environment=environment),
            api_version=api_version,
            token=token,
            headers=headers,
            httpx_client=httpx_client
            if httpx_client is not None
            else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
            if follow_redirects is not None
            else httpx.AsyncClient(timeout=_defaulted_timeout),
            timeout=_defaulted_timeout,
        )
        self._custom_actions: typing.Optional[AsyncCustomActionsClient] = None
        self._metadata_fields: typing.Optional[AsyncMetadataFieldsClient] = None
        self._project_permissions: typing.Optional[AsyncProjectPermissionsClient] = None
        self._folders: typing.Optional[AsyncFoldersClient] = None
        self._version_stacks: typing.Optional[AsyncVersionStacksClient] = None
        self._account_permissions: typing.Optional[AsyncAccountPermissionsClient] = None
        self._comments: typing.Optional[AsyncCommentsClient] = None
        self._accounts: typing.Optional[AsyncAccountsClient] = None
        self._webhooks: typing.Optional[AsyncWebhooksClient] = None
        self._workspace_permissions: typing.Optional[AsyncWorkspacePermissionsClient] = None
        self._groups: typing.Optional[AsyncGroupsClient] = None
        self._projects: typing.Optional[AsyncProjectsClient] = None
        self._metadata: typing.Optional[AsyncMetadataClient] = None
        self._files: typing.Optional[AsyncFilesClient] = None
        self._shares: typing.Optional[AsyncSharesClient] = None
        self._folder_permissions: typing.Optional[AsyncFolderPermissionsClient] = None
        self._workspaces: typing.Optional[AsyncWorkspacesClient] = None
        self._collections: typing.Optional[AsyncCollectionsClient] = None

    @property
    def custom_actions(self):
        if self._custom_actions is None:
            from .custom_actions.client import AsyncCustomActionsClient  # noqa: E402

            self._custom_actions = AsyncCustomActionsClient(client_wrapper=self._client_wrapper)
        return self._custom_actions

    @property
    def metadata_fields(self):
        if self._metadata_fields is None:
            from .metadata_fields.client import AsyncMetadataFieldsClient  # noqa: E402

            self._metadata_fields = AsyncMetadataFieldsClient(client_wrapper=self._client_wrapper)
        return self._metadata_fields

    @property
    def project_permissions(self):
        if self._project_permissions is None:
            from .project_permissions.client import AsyncProjectPermissionsClient  # noqa: E402

            self._project_permissions = AsyncProjectPermissionsClient(client_wrapper=self._client_wrapper)
        return self._project_permissions

    @property
    def folders(self):
        if self._folders is None:
            from .folders.client import AsyncFoldersClient  # noqa: E402

            self._folders = AsyncFoldersClient(client_wrapper=self._client_wrapper)
        return self._folders

    @property
    def version_stacks(self):
        if self._version_stacks is None:
            from .version_stacks.client import AsyncVersionStacksClient  # noqa: E402

            self._version_stacks = AsyncVersionStacksClient(client_wrapper=self._client_wrapper)
        return self._version_stacks

    @property
    def account_permissions(self):
        if self._account_permissions is None:
            from .account_permissions.client import AsyncAccountPermissionsClient  # noqa: E402

            self._account_permissions = AsyncAccountPermissionsClient(client_wrapper=self._client_wrapper)
        return self._account_permissions

    @property
    def comments(self):
        if self._comments is None:
            from .comments.client import AsyncCommentsClient  # noqa: E402

            self._comments = AsyncCommentsClient(client_wrapper=self._client_wrapper)
        return self._comments

    @property
    def accounts(self):
        if self._accounts is None:
            from .accounts.client import AsyncAccountsClient  # noqa: E402

            self._accounts = AsyncAccountsClient(client_wrapper=self._client_wrapper)
        return self._accounts

    @property
    def webhooks(self):
        if self._webhooks is None:
            from .webhooks.client import AsyncWebhooksClient  # noqa: E402

            self._webhooks = AsyncWebhooksClient(client_wrapper=self._client_wrapper)
        return self._webhooks

    @property
    def workspace_permissions(self):
        if self._workspace_permissions is None:
            from .workspace_permissions.client import AsyncWorkspacePermissionsClient  # noqa: E402

            self._workspace_permissions = AsyncWorkspacePermissionsClient(client_wrapper=self._client_wrapper)
        return self._workspace_permissions

    @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 projects(self):
        if self._projects is None:
            from .projects.client import AsyncProjectsClient  # noqa: E402

            self._projects = AsyncProjectsClient(client_wrapper=self._client_wrapper)
        return self._projects

    @property
    def metadata(self):
        if self._metadata is None:
            from .metadata.client import AsyncMetadataClient  # noqa: E402

            self._metadata = AsyncMetadataClient(client_wrapper=self._client_wrapper)
        return self._metadata

    @property
    def files(self):
        if self._files is None:
            from .files.client import AsyncFilesClient  # noqa: E402

            self._files = AsyncFilesClient(client_wrapper=self._client_wrapper)
        return self._files

    @property
    def shares(self):
        if self._shares is None:
            from .shares.client import AsyncSharesClient  # noqa: E402

            self._shares = AsyncSharesClient(client_wrapper=self._client_wrapper)
        return self._shares

    @property
    def folder_permissions(self):
        if self._folder_permissions is None:
            from .folder_permissions.client import AsyncFolderPermissionsClient  # noqa: E402

            self._folder_permissions = AsyncFolderPermissionsClient(client_wrapper=self._client_wrapper)
        return self._folder_permissions

    @property
    def workspaces(self):
        if self._workspaces is None:
            from .workspaces.client import AsyncWorkspacesClient  # noqa: E402

            self._workspaces = AsyncWorkspacesClient(client_wrapper=self._client_wrapper)
        return self._workspaces

    @property
    def collections(self):
        if self._collections is None:
            from .collections.client import AsyncCollectionsClient  # noqa: E402

            self._collections = AsyncCollectionsClient(client_wrapper=self._client_wrapper)
        return self._collections


def _get_base_url(*, base_url: typing.Optional[str] = None, environment: FrameioExperimentalEnvironment) -> str:
    if base_url is not None:
        return base_url
    elif environment is not None:
        return environment.value
    else:
        raise Exception("Please pass in either base_url or environment to construct the client")
