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

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.account_request import AccountRequest
from ..types.account_response import AccountResponse
from ..types.organization_membership_request import OrganizationMembershipRequest
from ..types.organization_request import OrganizationRequest
from ..types.plan import Plan
from ..types.project_membership_request import ProjectMembershipRequest
from ..types.project_request import ProjectRequest
from ..types.scopes_response_model import ScopesResponseModel
from ..types.user_request import UserRequest
from ..types.workspace_membership_request import WorkspaceMembershipRequest
from ..types.workspace_request import WorkspaceRequest
from .raw_client import AsyncRawAdminClient, RawAdminClient

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


class AdminClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAdminClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawAdminClient
        """
        return self._raw_client

    def create_accounts(
        self,
        *,
        users: typing.Dict[str, UserRequest],
        organizations: typing.Dict[str, OrganizationRequest],
        workspaces: typing.Dict[str, WorkspaceRequest],
        projects: typing.Dict[str, ProjectRequest],
        organization_memberships: typing.Dict[str, OrganizationMembershipRequest],
        workspace_memberships: typing.Dict[str, WorkspaceMembershipRequest],
        project_memberships: typing.Dict[str, ProjectMembershipRequest],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ScopesResponseModel:
        """
        Parameters
        ----------
        users : typing.Dict[str, UserRequest]

        organizations : typing.Dict[str, OrganizationRequest]

        workspaces : typing.Dict[str, WorkspaceRequest]

        projects : typing.Dict[str, ProjectRequest]

        organization_memberships : typing.Dict[str, OrganizationMembershipRequest]

        workspace_memberships : typing.Dict[str, WorkspaceMembershipRequest]

        project_memberships : typing.Dict[str, ProjectMembershipRequest]

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

        Returns
        -------
        ScopesResponseModel
            Successful Response

        Examples
        --------
        from agenta import (
            AgentaApi,
            OrganizationMembershipRequest,
            OrganizationRequest,
            ProjectMembershipRequest,
            ProjectRequest,
            Reference,
            UserRequest,
            WorkspaceMembershipRequest,
            WorkspaceRequest,
        )

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.admin.create_accounts(
            users={
                "key": UserRequest(
                    name="name",
                    email="email",
                )
            },
            organizations={
                "key": OrganizationRequest(
                    name="name",
                    description="description",
                    is_paying=True,
                )
            },
            workspaces={
                "key": WorkspaceRequest(
                    name="name",
                    description="description",
                    is_default=True,
                    organization_ref=Reference(),
                )
            },
            projects={
                "key": ProjectRequest(
                    name="name",
                    description="description",
                    is_default=True,
                    workspace_ref=Reference(),
                    organization_ref=Reference(),
                )
            },
            organization_memberships={
                "key": OrganizationMembershipRequest(
                    role="owner",
                    is_demo=True,
                    user_ref=Reference(),
                    organization_ref=Reference(),
                )
            },
            workspace_memberships={
                "key": WorkspaceMembershipRequest(
                    role="owner",
                    is_demo=True,
                    user_ref=Reference(),
                    workspace_ref=Reference(),
                )
            },
            project_memberships={
                "key": ProjectMembershipRequest(
                    role="owner",
                    is_demo=True,
                    user_ref=Reference(),
                    project_ref=Reference(),
                )
            },
        )
        """
        _response = self._raw_client.create_accounts(
            users=users,
            organizations=organizations,
            workspaces=workspaces,
            projects=projects,
            organization_memberships=organization_memberships,
            workspace_memberships=workspace_memberships,
            project_memberships=project_memberships,
            request_options=request_options,
        )
        return _response.data

    def create_account(
        self,
        *,
        request: typing.Optional[AccountRequest] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AccountResponse:
        """
        Parameters
        ----------
        request : typing.Optional[AccountRequest]

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

        Returns
        -------
        AccountResponse
            Successful Response

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

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

    def create_portal(
        self,
        *,
        organization_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        organization_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.admin.create_portal(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.create_portal(
            organization_id=organization_id, request_options=request_options
        )
        return _response.data

    def create_checkout(
        self,
        *,
        organization_id: str,
        plan: Plan,
        success_url: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        organization_id : str

        plan : Plan

        success_url : 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.admin.create_checkout(
            organization_id="organization_id",
            plan="cloud_v0_hobby",
            success_url="success_url",
        )
        """
        _response = self._raw_client.create_checkout(
            organization_id=organization_id,
            plan=plan,
            success_url=success_url,
            request_options=request_options,
        )
        return _response.data

    def switch_plans(
        self,
        *,
        organization_id: str,
        plan: Plan,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        organization_id : str

        plan : Plan

        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.admin.switch_plans(
            organization_id="organization_id",
            plan="cloud_v0_hobby",
        )
        """
        _response = self._raw_client.switch_plans(
            organization_id=organization_id, plan=plan, request_options=request_options
        )
        return _response.data

    def cancel_subscription(
        self,
        *,
        organization_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        organization_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.admin.cancel_subscription(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.cancel_subscription(
            organization_id=organization_id, request_options=request_options
        )
        return _response.data

    def report_usage(
        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.admin.report_usage()
        """
        _response = self._raw_client.report_usage(request_options=request_options)
        return _response.data


class AsyncAdminClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAdminClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawAdminClient
        """
        return self._raw_client

    async def create_accounts(
        self,
        *,
        users: typing.Dict[str, UserRequest],
        organizations: typing.Dict[str, OrganizationRequest],
        workspaces: typing.Dict[str, WorkspaceRequest],
        projects: typing.Dict[str, ProjectRequest],
        organization_memberships: typing.Dict[str, OrganizationMembershipRequest],
        workspace_memberships: typing.Dict[str, WorkspaceMembershipRequest],
        project_memberships: typing.Dict[str, ProjectMembershipRequest],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ScopesResponseModel:
        """
        Parameters
        ----------
        users : typing.Dict[str, UserRequest]

        organizations : typing.Dict[str, OrganizationRequest]

        workspaces : typing.Dict[str, WorkspaceRequest]

        projects : typing.Dict[str, ProjectRequest]

        organization_memberships : typing.Dict[str, OrganizationMembershipRequest]

        workspace_memberships : typing.Dict[str, WorkspaceMembershipRequest]

        project_memberships : typing.Dict[str, ProjectMembershipRequest]

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

        Returns
        -------
        ScopesResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import (
            AsyncAgentaApi,
            OrganizationMembershipRequest,
            OrganizationRequest,
            ProjectMembershipRequest,
            ProjectRequest,
            Reference,
            UserRequest,
            WorkspaceMembershipRequest,
            WorkspaceRequest,
        )

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.admin.create_accounts(
                users={
                    "key": UserRequest(
                        name="name",
                        email="email",
                    )
                },
                organizations={
                    "key": OrganizationRequest(
                        name="name",
                        description="description",
                        is_paying=True,
                    )
                },
                workspaces={
                    "key": WorkspaceRequest(
                        name="name",
                        description="description",
                        is_default=True,
                        organization_ref=Reference(),
                    )
                },
                projects={
                    "key": ProjectRequest(
                        name="name",
                        description="description",
                        is_default=True,
                        workspace_ref=Reference(),
                        organization_ref=Reference(),
                    )
                },
                organization_memberships={
                    "key": OrganizationMembershipRequest(
                        role="owner",
                        is_demo=True,
                        user_ref=Reference(),
                        organization_ref=Reference(),
                    )
                },
                workspace_memberships={
                    "key": WorkspaceMembershipRequest(
                        role="owner",
                        is_demo=True,
                        user_ref=Reference(),
                        workspace_ref=Reference(),
                    )
                },
                project_memberships={
                    "key": ProjectMembershipRequest(
                        role="owner",
                        is_demo=True,
                        user_ref=Reference(),
                        project_ref=Reference(),
                    )
                },
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_accounts(
            users=users,
            organizations=organizations,
            workspaces=workspaces,
            projects=projects,
            organization_memberships=organization_memberships,
            workspace_memberships=workspace_memberships,
            project_memberships=project_memberships,
            request_options=request_options,
        )
        return _response.data

    async def create_account(
        self,
        *,
        request: typing.Optional[AccountRequest] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AccountResponse:
        """
        Parameters
        ----------
        request : typing.Optional[AccountRequest]

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

        Returns
        -------
        AccountResponse
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


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


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

    async def create_portal(
        self,
        *,
        organization_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        organization_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.admin.create_portal(
                organization_id="organization_id",
            )


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

    async def create_checkout(
        self,
        *,
        organization_id: str,
        plan: Plan,
        success_url: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        organization_id : str

        plan : Plan

        success_url : 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.admin.create_checkout(
                organization_id="organization_id",
                plan="cloud_v0_hobby",
                success_url="success_url",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_checkout(
            organization_id=organization_id,
            plan=plan,
            success_url=success_url,
            request_options=request_options,
        )
        return _response.data

    async def switch_plans(
        self,
        *,
        organization_id: str,
        plan: Plan,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        organization_id : str

        plan : Plan

        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.admin.switch_plans(
                organization_id="organization_id",
                plan="cloud_v0_hobby",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.switch_plans(
            organization_id=organization_id, plan=plan, request_options=request_options
        )
        return _response.data

    async def cancel_subscription(
        self,
        *,
        organization_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        organization_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.admin.cancel_subscription(
                organization_id="organization_id",
            )


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

    async def report_usage(
        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.admin.report_usage()


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