# 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 .raw_client import AsyncRawScimClient, RawScimClient
from .types.empty_response import EmptyResponse
from .types.resource_types_response import ResourceTypesResponse
from .types.schemas_response import SchemasResponse
from .types.scim_email import ScimEmail
from .types.scim_name import ScimName
from .types.scim_user import ScimUser
from .types.scim_users_list_response import ScimUsersListResponse
from .types.service_provider_config import ServiceProviderConfig

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


class ScimClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawScimClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawScimClient
        """
        return self._raw_client

    def get_service_provider_config(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ServiceProviderConfig:
        """
        Get SCIM Service Provider Configuration (requires organization-scoped API key)

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

        Returns
        -------
        ServiceProviderConfig

        Examples
        --------
        from langfuse import LangfuseAPI

        client = LangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )
        client.scim.get_service_provider_config()
        """
        _response = self._raw_client.get_service_provider_config(
            request_options=request_options
        )
        return _response.data

    def get_resource_types(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ResourceTypesResponse:
        """
        Get SCIM Resource Types (requires organization-scoped API key)

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

        Returns
        -------
        ResourceTypesResponse

        Examples
        --------
        from langfuse import LangfuseAPI

        client = LangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )
        client.scim.get_resource_types()
        """
        _response = self._raw_client.get_resource_types(request_options=request_options)
        return _response.data

    def get_schemas(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SchemasResponse:
        """
        Get SCIM Schemas (requires organization-scoped API key)

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

        Returns
        -------
        SchemasResponse

        Examples
        --------
        from langfuse import LangfuseAPI

        client = LangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )
        client.scim.get_schemas()
        """
        _response = self._raw_client.get_schemas(request_options=request_options)
        return _response.data

    def list_users(
        self,
        *,
        filter: typing.Optional[str] = None,
        start_index: typing.Optional[int] = None,
        count: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ScimUsersListResponse:
        """
        List users in the organization (requires organization-scoped API key)

        Parameters
        ----------
        filter : typing.Optional[str]
            Filter expression (e.g. userName eq "value")

        start_index : typing.Optional[int]
            1-based index of the first result to return (default 1)

        count : typing.Optional[int]
            Maximum number of results to return (default 100)

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

        Returns
        -------
        ScimUsersListResponse

        Examples
        --------
        from langfuse import LangfuseAPI

        client = LangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )
        client.scim.list_users()
        """
        _response = self._raw_client.list_users(
            filter=filter,
            start_index=start_index,
            count=count,
            request_options=request_options,
        )
        return _response.data

    def create_user(
        self,
        *,
        user_name: str,
        name: ScimName,
        emails: typing.Optional[typing.Sequence[ScimEmail]] = OMIT,
        active: typing.Optional[bool] = OMIT,
        password: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ScimUser:
        """
        Create a new user in the organization (requires organization-scoped API key)

        Parameters
        ----------
        user_name : str
            User's email address (required)

        name : ScimName
            User's name information

        emails : typing.Optional[typing.Sequence[ScimEmail]]
            User's email addresses

        active : typing.Optional[bool]
            Whether the user is active

        password : typing.Optional[str]
            Initial password for the user

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

        Returns
        -------
        ScimUser

        Examples
        --------
        from langfuse import LangfuseAPI
        from langfuse.scim import ScimName

        client = LangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )
        client.scim.create_user(
            user_name="userName",
            name=ScimName(),
        )
        """
        _response = self._raw_client.create_user(
            user_name=user_name,
            name=name,
            emails=emails,
            active=active,
            password=password,
            request_options=request_options,
        )
        return _response.data

    def get_user(
        self, user_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ScimUser:
        """
        Get a specific user by ID (requires organization-scoped API key)

        Parameters
        ----------
        user_id : str

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

        Returns
        -------
        ScimUser

        Examples
        --------
        from langfuse import LangfuseAPI

        client = LangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )
        client.scim.get_user(
            user_id="userId",
        )
        """
        _response = self._raw_client.get_user(user_id, request_options=request_options)
        return _response.data

    def delete_user(
        self, user_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> EmptyResponse:
        """
        Remove a user from the organization (requires organization-scoped API key). Note that this only removes the user from the organization but does not delete the user entity itself.

        Parameters
        ----------
        user_id : str

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

        Returns
        -------
        EmptyResponse

        Examples
        --------
        from langfuse import LangfuseAPI

        client = LangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )
        client.scim.delete_user(
            user_id="userId",
        )
        """
        _response = self._raw_client.delete_user(
            user_id, request_options=request_options
        )
        return _response.data


class AsyncScimClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawScimClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawScimClient
        """
        return self._raw_client

    async def get_service_provider_config(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ServiceProviderConfig:
        """
        Get SCIM Service Provider Configuration (requires organization-scoped API key)

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

        Returns
        -------
        ServiceProviderConfig

        Examples
        --------
        import asyncio

        from langfuse import AsyncLangfuseAPI

        client = AsyncLangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )


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


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

    async def get_resource_types(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ResourceTypesResponse:
        """
        Get SCIM Resource Types (requires organization-scoped API key)

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

        Returns
        -------
        ResourceTypesResponse

        Examples
        --------
        import asyncio

        from langfuse import AsyncLangfuseAPI

        client = AsyncLangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )


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


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

    async def get_schemas(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SchemasResponse:
        """
        Get SCIM Schemas (requires organization-scoped API key)

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

        Returns
        -------
        SchemasResponse

        Examples
        --------
        import asyncio

        from langfuse import AsyncLangfuseAPI

        client = AsyncLangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )


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


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

    async def list_users(
        self,
        *,
        filter: typing.Optional[str] = None,
        start_index: typing.Optional[int] = None,
        count: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ScimUsersListResponse:
        """
        List users in the organization (requires organization-scoped API key)

        Parameters
        ----------
        filter : typing.Optional[str]
            Filter expression (e.g. userName eq "value")

        start_index : typing.Optional[int]
            1-based index of the first result to return (default 1)

        count : typing.Optional[int]
            Maximum number of results to return (default 100)

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

        Returns
        -------
        ScimUsersListResponse

        Examples
        --------
        import asyncio

        from langfuse import AsyncLangfuseAPI

        client = AsyncLangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.list_users(
            filter=filter,
            start_index=start_index,
            count=count,
            request_options=request_options,
        )
        return _response.data

    async def create_user(
        self,
        *,
        user_name: str,
        name: ScimName,
        emails: typing.Optional[typing.Sequence[ScimEmail]] = OMIT,
        active: typing.Optional[bool] = OMIT,
        password: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ScimUser:
        """
        Create a new user in the organization (requires organization-scoped API key)

        Parameters
        ----------
        user_name : str
            User's email address (required)

        name : ScimName
            User's name information

        emails : typing.Optional[typing.Sequence[ScimEmail]]
            User's email addresses

        active : typing.Optional[bool]
            Whether the user is active

        password : typing.Optional[str]
            Initial password for the user

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

        Returns
        -------
        ScimUser

        Examples
        --------
        import asyncio

        from langfuse import AsyncLangfuseAPI
        from langfuse.scim import ScimName

        client = AsyncLangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.scim.create_user(
                user_name="userName",
                name=ScimName(),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_user(
            user_name=user_name,
            name=name,
            emails=emails,
            active=active,
            password=password,
            request_options=request_options,
        )
        return _response.data

    async def get_user(
        self, user_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ScimUser:
        """
        Get a specific user by ID (requires organization-scoped API key)

        Parameters
        ----------
        user_id : str

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

        Returns
        -------
        ScimUser

        Examples
        --------
        import asyncio

        from langfuse import AsyncLangfuseAPI

        client = AsyncLangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )


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


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

    async def delete_user(
        self, user_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> EmptyResponse:
        """
        Remove a user from the organization (requires organization-scoped API key). Note that this only removes the user from the organization but does not delete the user entity itself.

        Parameters
        ----------
        user_id : str

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

        Returns
        -------
        EmptyResponse

        Examples
        --------
        import asyncio

        from langfuse import AsyncLangfuseAPI

        client = AsyncLangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )


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


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