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

import os
import typing

import httpx

from .core.api_error import ApiError
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .generators.client import AsyncGeneratorsClient, GeneratorsClient
from .parse.client import AsyncParseClient, ParseClient
from .pipelines.client import AsyncPipelinesClient, PipelinesClient
from .storage.client import AsyncStorageClient, StorageClient
from .workflows.client import AsyncWorkflowsClient, WorkflowsClient


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

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

        - authorization: typing.Optional[str].

        - index_id: typing.Optional[str].

        - api_key: typing.Optional[typing.Union[str, typing.Callable[[], str]]].

        - 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 a default is not set.

        - 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.
    ---
    from mixpeek.client import Mixpeek

    client = Mixpeek(
        authorization="YOUR_AUTHORIZATION",
        index_id="YOUR_INDEX_ID",
        api_key="YOUR_API_KEY",
        base_url="https://yourhost.com/path/to/api",
    )
    """

    def __init__(
        self,
        *,
        base_url: str,
        authorization: typing.Optional[str] = None,
        index_id: typing.Optional[str] = None,
        api_key: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv("MIXPEEK_API_KEY"),
        timeout: typing.Optional[float] = None,
        httpx_client: typing.Optional[httpx.Client] = None
    ):
        _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
        if api_key is None:
            raise ApiError(
                body="The client must be instantiated be either passing in api_key or setting MIXPEEK_API_KEY"
            )
        self._client_wrapper = SyncClientWrapper(
            base_url=base_url,
            authorization=authorization,
            index_id=index_id,
            api_key=api_key,
            httpx_client=httpx.Client(timeout=_defaulted_timeout) if httpx_client is None else httpx_client,
            timeout=_defaulted_timeout,
        )
        self.pipelines = PipelinesClient(client_wrapper=self._client_wrapper)
        self.parse = ParseClient(client_wrapper=self._client_wrapper)
        self.workflows = WorkflowsClient(client_wrapper=self._client_wrapper)
        self.generators = GeneratorsClient(client_wrapper=self._client_wrapper)
        self.storage = StorageClient(client_wrapper=self._client_wrapper)


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

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

        - authorization: typing.Optional[str].

        - index_id: typing.Optional[str].

        - api_key: typing.Optional[typing.Union[str, typing.Callable[[], str]]].

        - 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 a default is not set.

        - 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.
    ---
    from mixpeek.client import AsyncMixpeek

    client = AsyncMixpeek(
        authorization="YOUR_AUTHORIZATION",
        index_id="YOUR_INDEX_ID",
        api_key="YOUR_API_KEY",
        base_url="https://yourhost.com/path/to/api",
    )
    """

    def __init__(
        self,
        *,
        base_url: str,
        authorization: typing.Optional[str] = None,
        index_id: typing.Optional[str] = None,
        api_key: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv("MIXPEEK_API_KEY"),
        timeout: typing.Optional[float] = None,
        httpx_client: typing.Optional[httpx.AsyncClient] = None
    ):
        _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
        if api_key is None:
            raise ApiError(
                body="The client must be instantiated be either passing in api_key or setting MIXPEEK_API_KEY"
            )
        self._client_wrapper = AsyncClientWrapper(
            base_url=base_url,
            authorization=authorization,
            index_id=index_id,
            api_key=api_key,
            httpx_client=httpx.AsyncClient(timeout=_defaulted_timeout) if httpx_client is None else httpx_client,
            timeout=_defaulted_timeout,
        )
        self.pipelines = AsyncPipelinesClient(client_wrapper=self._client_wrapper)
        self.parse = AsyncParseClient(client_wrapper=self._client_wrapper)
        self.workflows = AsyncWorkflowsClient(client_wrapper=self._client_wrapper)
        self.generators = AsyncGeneratorsClient(client_wrapper=self._client_wrapper)
        self.storage = AsyncStorageClient(client_wrapper=self._client_wrapper)
