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

import datetime as dt
import typing

import httpx
from .access_control.client import AccessControlClient, AsyncAccessControlClient
from .admin.client import AdminClient, AsyncAdminClient
from .api_keys.client import ApiKeysClient, AsyncApiKeysClient
from .apps.client import AppsClient, AsyncAppsClient
from .bases.client import AsyncBasesClient, BasesClient
from .billing.client import AsyncBillingClient, BillingClient
from .configs.client import AsyncConfigsClient, ConfigsClient
from .containers.client import AsyncContainersClient, ContainersClient
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .core.request_options import RequestOptions
from .environment import AgentaApiEnvironment
from .environments.client import AsyncEnvironmentsClient, EnvironmentsClient
from .evals.client import AsyncEvalsClient, EvalsClient
from .evaluations.client import AsyncEvaluationsClient, EvaluationsClient
from .evaluators.client import AsyncEvaluatorsClient, EvaluatorsClient
from .human_evaluations.client import (
    AsyncHumanEvaluationsClient,
    HumanEvaluationsClient,
)
from .observability.client import AsyncObservabilityClient, ObservabilityClient
from .organization.client import AsyncOrganizationClient, OrganizationClient
from .raw_client import AsyncRawAgentaApi, RawAgentaApi
from .scopes.client import AsyncScopesClient, ScopesClient
from .testsets.client import AsyncTestsetsClient, TestsetsClient
from .tracing.client import AsyncTracingClient, TracingClient
from .types.organization_output import OrganizationOutput
from .types.permission import Permission
from .types.workspace_response import WorkspaceResponse
from .variants.client import AsyncVariantsClient, VariantsClient
from .vault.client import AsyncVaultClient, VaultClient
from .workflows.client import AsyncWorkflowsClient, WorkflowsClient
from .workspace.client import AsyncWorkspaceClient, WorkspaceClient

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class AgentaApi:
    """
    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 : AgentaApiEnvironment
        The environment to use for requests from the client. from .environment import AgentaApiEnvironment



        Defaults to AgentaApiEnvironment.DEFAULT



    api_key : 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 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 agenta import AgentaApi

    client = AgentaApi(
        api_key="YOUR_API_KEY",
    )
    """

    def __init__(
        self,
        *,
        base_url: typing.Optional[str] = None,
        environment: AgentaApiEnvironment = AgentaApiEnvironment.DEFAULT,
        api_key: str,
        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_key=api_key,
            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._raw_client = RawAgentaApi(client_wrapper=self._client_wrapper)
        self.admin = AdminClient(client_wrapper=self._client_wrapper)
        self.organization = OrganizationClient(client_wrapper=self._client_wrapper)
        self.evaluations = EvaluationsClient(client_wrapper=self._client_wrapper)
        self.human_evaluations = HumanEvaluationsClient(
            client_wrapper=self._client_wrapper
        )
        self.billing = BillingClient(client_wrapper=self._client_wrapper)
        self.access_control = AccessControlClient(client_wrapper=self._client_wrapper)
        self.scopes = ScopesClient(client_wrapper=self._client_wrapper)
        self.apps = AppsClient(client_wrapper=self._client_wrapper)
        self.variants = VariantsClient(client_wrapper=self._client_wrapper)
        self.containers = ContainersClient(client_wrapper=self._client_wrapper)
        self.evaluators = EvaluatorsClient(client_wrapper=self._client_wrapper)
        self.testsets = TestsetsClient(client_wrapper=self._client_wrapper)
        self.environments = EnvironmentsClient(client_wrapper=self._client_wrapper)
        self.bases = BasesClient(client_wrapper=self._client_wrapper)
        self.configs = ConfigsClient(client_wrapper=self._client_wrapper)
        self.api_keys = ApiKeysClient(client_wrapper=self._client_wrapper)
        self.workspace = WorkspaceClient(client_wrapper=self._client_wrapper)
        self.tracing = TracingClient(client_wrapper=self._client_wrapper)
        self.evals = EvalsClient(client_wrapper=self._client_wrapper)
        self.workflows = WorkflowsClient(client_wrapper=self._client_wrapper)
        self.observability = ObservabilityClient(client_wrapper=self._client_wrapper)
        self.vault = VaultClient(client_wrapper=self._client_wrapper)

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

        Returns
        -------
        RawAgentaApi
        """
        return self._raw_client

    def get_own_org(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> OrganizationOutput:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationOutput
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.get_own_org()
        """
        _response = self._raw_client.get_own_org(request_options=request_options)
        return _response.data

    def update_organization(
        self,
        org_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        updated_at: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        org_id : str

        name : typing.Optional[str]

        description : typing.Optional[str]

        updated_at : typing.Optional[str]

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.update_organization(
            org_id="org_id",
        )
        """
        _response = self._raw_client.update_organization(
            org_id,
            name=name,
            description=description,
            updated_at=updated_at,
            request_options=request_options,
        )
        return _response.data

    def create_workspace(
        self,
        org_id: str,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        type: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkspaceResponse:
        """
        Parameters
        ----------
        org_id : str

        name : str

        description : typing.Optional[str]

        type : typing.Optional[str]

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

        Returns
        -------
        WorkspaceResponse
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.create_workspace(
            org_id="org_id",
            name="name",
        )
        """
        _response = self._raw_client.create_workspace(
            org_id,
            name=name,
            description=description,
            type=type,
            request_options=request_options,
        )
        return _response.data

    def update_workspace(
        self,
        org_id: str,
        workspace_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        updated_at: typing.Optional[dt.datetime] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkspaceResponse:
        """
        Parameters
        ----------
        org_id : str

        workspace_id : str

        name : typing.Optional[str]

        description : typing.Optional[str]

        updated_at : typing.Optional[dt.datetime]

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

        Returns
        -------
        WorkspaceResponse
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.update_workspace(
            org_id="org_id",
            workspace_id="workspace_id",
        )
        """
        _response = self._raw_client.update_workspace(
            org_id,
            workspace_id,
            name=name,
            description=description,
            updated_at=updated_at,
            request_options=request_options,
        )
        return _response.data

    def get_all_workspace_permissions(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[Permission]:
        """
        Get all workspace permissions.

        Returns a list of all available workspace permissions.

        Returns:
            List[Permission]: A list of Permission objects representing the available workspace permissions.

        Raises:
            HTTPException: If there is an error retrieving the workspace permissions.

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

        Returns
        -------
        typing.List[Permission]
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.get_all_workspace_permissions()
        """
        _response = self._raw_client.get_all_workspace_permissions(
            request_options=request_options
        )
        return _response.data

    def assign_role_to_user(
        self,
        workspace_id: str,
        *,
        email: str,
        organization_id: str,
        role: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Assigns a role to a user in a workspace.

        Args:
            payload (UserRole): The payload containing the organization id, user email, and role to assign.
            workspace_id (str): The ID of the workspace.
            request (Request): The FastAPI request object.

        Returns:
            bool: True if the role was successfully assigned, False otherwise.

        Raises:
            HTTPException: If the user does not have permission to perform this action.
            HTTPException: If there is an error assigning the role to the user.

        Parameters
        ----------
        workspace_id : str

        email : str

        organization_id : str

        role : typing.Optional[str]

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.assign_role_to_user(
            workspace_id="workspace_id",
            email="email",
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.assign_role_to_user(
            workspace_id,
            email=email,
            organization_id=organization_id,
            role=role,
            request_options=request_options,
        )
        return _response.data

    def unassign_role_from_user(
        self,
        workspace_id: str,
        *,
        email: str,
        org_id: str,
        role: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Delete a role assignment from a user in a workspace.

        Args:
            workspace_id (str): The ID of the workspace.
            email (str): The email of the user to remove the role from.
            org_id (str): The ID of the organization.
            role (str): The role to remove from the user.
            request (Request): The FastAPI request object.

        Returns:
            bool: True if the role assignment was successfully deleted.

        Raises:
            HTTPException: If there is an error in the request or the user does not have permission to perform the action.
            HTTPException: If there is an error in updating the user's roles.

        Parameters
        ----------
        workspace_id : str

        email : str

        org_id : str

        role : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.unassign_role_from_user(
            workspace_id="workspace_id",
            email="email",
            org_id="org_id",
            role="role",
        )
        """
        _response = self._raw_client.unassign_role_from_user(
            workspace_id,
            email=email,
            org_id=org_id,
            role=role,
            request_options=request_options,
        )
        return _response.data

    def delete_accounts(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.delete_accounts()
        """
        _response = self._raw_client.delete_accounts(request_options=request_options)
        return _response.data

    def health_check(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.health_check()
        """
        _response = self._raw_client.health_check(request_options=request_options)
        return _response.data

    def fetch_user_profile(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.fetch_user_profile()
        """
        _response = self._raw_client.fetch_user_profile(request_options=request_options)
        return _response.data

    def reset_user_password(
        self, *, user_id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        user_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.reset_user_password(
            user_id="user_id",
        )
        """
        _response = self._raw_client.reset_user_password(
            user_id=user_id, request_options=request_options
        )
        return _response.data


class AsyncAgentaApi:
    """
    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 : AgentaApiEnvironment
        The environment to use for requests from the client. from .environment import AgentaApiEnvironment



        Defaults to AgentaApiEnvironment.DEFAULT



    api_key : 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 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 agenta import AsyncAgentaApi

    client = AsyncAgentaApi(
        api_key="YOUR_API_KEY",
    )
    """

    def __init__(
        self,
        *,
        base_url: typing.Optional[str] = None,
        environment: AgentaApiEnvironment = AgentaApiEnvironment.DEFAULT,
        api_key: str,
        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_key=api_key,
            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._raw_client = AsyncRawAgentaApi(client_wrapper=self._client_wrapper)
        self.admin = AsyncAdminClient(client_wrapper=self._client_wrapper)
        self.organization = AsyncOrganizationClient(client_wrapper=self._client_wrapper)
        self.evaluations = AsyncEvaluationsClient(client_wrapper=self._client_wrapper)
        self.human_evaluations = AsyncHumanEvaluationsClient(
            client_wrapper=self._client_wrapper
        )
        self.billing = AsyncBillingClient(client_wrapper=self._client_wrapper)
        self.access_control = AsyncAccessControlClient(
            client_wrapper=self._client_wrapper
        )
        self.scopes = AsyncScopesClient(client_wrapper=self._client_wrapper)
        self.apps = AsyncAppsClient(client_wrapper=self._client_wrapper)
        self.variants = AsyncVariantsClient(client_wrapper=self._client_wrapper)
        self.containers = AsyncContainersClient(client_wrapper=self._client_wrapper)
        self.evaluators = AsyncEvaluatorsClient(client_wrapper=self._client_wrapper)
        self.testsets = AsyncTestsetsClient(client_wrapper=self._client_wrapper)
        self.environments = AsyncEnvironmentsClient(client_wrapper=self._client_wrapper)
        self.bases = AsyncBasesClient(client_wrapper=self._client_wrapper)
        self.configs = AsyncConfigsClient(client_wrapper=self._client_wrapper)
        self.api_keys = AsyncApiKeysClient(client_wrapper=self._client_wrapper)
        self.workspace = AsyncWorkspaceClient(client_wrapper=self._client_wrapper)
        self.tracing = AsyncTracingClient(client_wrapper=self._client_wrapper)
        self.evals = AsyncEvalsClient(client_wrapper=self._client_wrapper)
        self.workflows = AsyncWorkflowsClient(client_wrapper=self._client_wrapper)
        self.observability = AsyncObservabilityClient(
            client_wrapper=self._client_wrapper
        )
        self.vault = AsyncVaultClient(client_wrapper=self._client_wrapper)

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

        Returns
        -------
        AsyncRawAgentaApi
        """
        return self._raw_client

    async def get_own_org(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> OrganizationOutput:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        OrganizationOutput
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.get_own_org(request_options=request_options)
        return _response.data

    async def update_organization(
        self,
        org_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        updated_at: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        org_id : str

        name : typing.Optional[str]

        description : typing.Optional[str]

        updated_at : typing.Optional[str]

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.update_organization(
                org_id="org_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_organization(
            org_id,
            name=name,
            description=description,
            updated_at=updated_at,
            request_options=request_options,
        )
        return _response.data

    async def create_workspace(
        self,
        org_id: str,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        type: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkspaceResponse:
        """
        Parameters
        ----------
        org_id : str

        name : str

        description : typing.Optional[str]

        type : typing.Optional[str]

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

        Returns
        -------
        WorkspaceResponse
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.create_workspace(
                org_id="org_id",
                name="name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_workspace(
            org_id,
            name=name,
            description=description,
            type=type,
            request_options=request_options,
        )
        return _response.data

    async def update_workspace(
        self,
        org_id: str,
        workspace_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        updated_at: typing.Optional[dt.datetime] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkspaceResponse:
        """
        Parameters
        ----------
        org_id : str

        workspace_id : str

        name : typing.Optional[str]

        description : typing.Optional[str]

        updated_at : typing.Optional[dt.datetime]

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

        Returns
        -------
        WorkspaceResponse
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.update_workspace(
                org_id="org_id",
                workspace_id="workspace_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_workspace(
            org_id,
            workspace_id,
            name=name,
            description=description,
            updated_at=updated_at,
            request_options=request_options,
        )
        return _response.data

    async def get_all_workspace_permissions(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[Permission]:
        """
        Get all workspace permissions.

        Returns a list of all available workspace permissions.

        Returns:
            List[Permission]: A list of Permission objects representing the available workspace permissions.

        Raises:
            HTTPException: If there is an error retrieving the workspace permissions.

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

        Returns
        -------
        typing.List[Permission]
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.get_all_workspace_permissions(
            request_options=request_options
        )
        return _response.data

    async def assign_role_to_user(
        self,
        workspace_id: str,
        *,
        email: str,
        organization_id: str,
        role: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Assigns a role to a user in a workspace.

        Args:
            payload (UserRole): The payload containing the organization id, user email, and role to assign.
            workspace_id (str): The ID of the workspace.
            request (Request): The FastAPI request object.

        Returns:
            bool: True if the role was successfully assigned, False otherwise.

        Raises:
            HTTPException: If the user does not have permission to perform this action.
            HTTPException: If there is an error assigning the role to the user.

        Parameters
        ----------
        workspace_id : str

        email : str

        organization_id : str

        role : typing.Optional[str]

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.assign_role_to_user(
                workspace_id="workspace_id",
                email="email",
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.assign_role_to_user(
            workspace_id,
            email=email,
            organization_id=organization_id,
            role=role,
            request_options=request_options,
        )
        return _response.data

    async def unassign_role_from_user(
        self,
        workspace_id: str,
        *,
        email: str,
        org_id: str,
        role: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Delete a role assignment from a user in a workspace.

        Args:
            workspace_id (str): The ID of the workspace.
            email (str): The email of the user to remove the role from.
            org_id (str): The ID of the organization.
            role (str): The role to remove from the user.
            request (Request): The FastAPI request object.

        Returns:
            bool: True if the role assignment was successfully deleted.

        Raises:
            HTTPException: If there is an error in the request or the user does not have permission to perform the action.
            HTTPException: If there is an error in updating the user's roles.

        Parameters
        ----------
        workspace_id : str

        email : str

        org_id : str

        role : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.unassign_role_from_user(
                workspace_id="workspace_id",
                email="email",
                org_id="org_id",
                role="role",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.unassign_role_from_user(
            workspace_id,
            email=email,
            org_id=org_id,
            role=role,
            request_options=request_options,
        )
        return _response.data

    async def delete_accounts(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_accounts(
            request_options=request_options
        )
        return _response.data

    async def health_check(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.health_check(request_options=request_options)
        return _response.data

    async def fetch_user_profile(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.fetch_user_profile(
            request_options=request_options
        )
        return _response.data

    async def reset_user_password(
        self, *, user_id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        user_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.reset_user_password(
                user_id="user_id",
            )


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


def _get_base_url(
    *, base_url: typing.Optional[str] = None, environment: AgentaApiEnvironment
) -> 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"
        )
