# 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 AsyncRawComponentsClient, RawComponentsClient
from .types.count_components_response import CountComponentsResponse
from .types.create_component_request_body_entity_type import CreateComponentRequestBodyEntityType
from .types.create_component_response import CreateComponentResponse
from .types.delete_component_response import DeleteComponentResponse
from .types.get_component_response import GetComponentResponse
from .types.list_components_response import ListComponentsResponse
from .types.preview_component_data_response import PreviewComponentDataResponse
from .types.update_component_request_body_entity_type import UpdateComponentRequestBodyEntityType
from .types.update_component_request_body_state import UpdateComponentRequestBodyState
from .types.update_component_response import UpdateComponentResponse

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


class ComponentsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawComponentsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawComponentsClient
        """
        return self._raw_client

    def list_components(
        self,
        *,
        q: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ListComponentsResponse:
        """
        Parameters
        ----------
        q : typing.Optional[str]

        limit : typing.Optional[int]
            Page limit (default 100)

        offset : typing.Optional[int]
            Page offset (default 0)

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

        Returns
        -------
        ListComponentsResponse
            OK

        Examples
        --------
        from schematic import Schematic

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.components.list_components()
        """
        _response = self._raw_client.list_components(q=q, limit=limit, offset=offset, request_options=request_options)
        return _response.data

    def create_component(
        self,
        *,
        entity_type: CreateComponentRequestBodyEntityType,
        name: str,
        ast: typing.Optional[typing.Dict[str, float]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateComponentResponse:
        """
        Parameters
        ----------
        entity_type : CreateComponentRequestBodyEntityType

        name : str

        ast : typing.Optional[typing.Dict[str, float]]

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

        Returns
        -------
        CreateComponentResponse
            Created

        Examples
        --------
        from schematic import Schematic

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.components.create_component(
            entity_type="entitlement",
            name="name",
        )
        """
        _response = self._raw_client.create_component(
            entity_type=entity_type, name=name, ast=ast, request_options=request_options
        )
        return _response.data

    def get_component(
        self, component_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetComponentResponse:
        """
        Parameters
        ----------
        component_id : str
            component_id

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

        Returns
        -------
        GetComponentResponse
            OK

        Examples
        --------
        from schematic import Schematic

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.components.get_component(
            component_id="component_id",
        )
        """
        _response = self._raw_client.get_component(component_id, request_options=request_options)
        return _response.data

    def update_component(
        self,
        component_id: str,
        *,
        ast: typing.Optional[typing.Dict[str, float]] = OMIT,
        entity_type: typing.Optional[UpdateComponentRequestBodyEntityType] = OMIT,
        name: typing.Optional[str] = OMIT,
        state: typing.Optional[UpdateComponentRequestBodyState] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateComponentResponse:
        """
        Parameters
        ----------
        component_id : str
            component_id

        ast : typing.Optional[typing.Dict[str, float]]

        entity_type : typing.Optional[UpdateComponentRequestBodyEntityType]

        name : typing.Optional[str]

        state : typing.Optional[UpdateComponentRequestBodyState]

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

        Returns
        -------
        UpdateComponentResponse
            OK

        Examples
        --------
        from schematic import Schematic

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.components.update_component(
            component_id="component_id",
        )
        """
        _response = self._raw_client.update_component(
            component_id, ast=ast, entity_type=entity_type, name=name, state=state, request_options=request_options
        )
        return _response.data

    def delete_component(
        self, component_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteComponentResponse:
        """
        Parameters
        ----------
        component_id : str
            component_id

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

        Returns
        -------
        DeleteComponentResponse
            OK

        Examples
        --------
        from schematic import Schematic

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.components.delete_component(
            component_id="component_id",
        )
        """
        _response = self._raw_client.delete_component(component_id, request_options=request_options)
        return _response.data

    def count_components(
        self,
        *,
        q: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CountComponentsResponse:
        """
        Parameters
        ----------
        q : typing.Optional[str]

        limit : typing.Optional[int]
            Page limit (default 100)

        offset : typing.Optional[int]
            Page offset (default 0)

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

        Returns
        -------
        CountComponentsResponse
            OK

        Examples
        --------
        from schematic import Schematic

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.components.count_components()
        """
        _response = self._raw_client.count_components(q=q, limit=limit, offset=offset, request_options=request_options)
        return _response.data

    def preview_component_data(
        self,
        *,
        company_id: typing.Optional[str] = None,
        component_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PreviewComponentDataResponse:
        """
        Parameters
        ----------
        company_id : typing.Optional[str]

        component_id : typing.Optional[str]

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

        Returns
        -------
        PreviewComponentDataResponse
            OK

        Examples
        --------
        from schematic import Schematic

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.components.preview_component_data()
        """
        _response = self._raw_client.preview_component_data(
            company_id=company_id, component_id=component_id, request_options=request_options
        )
        return _response.data


class AsyncComponentsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawComponentsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawComponentsClient
        """
        return self._raw_client

    async def list_components(
        self,
        *,
        q: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ListComponentsResponse:
        """
        Parameters
        ----------
        q : typing.Optional[str]

        limit : typing.Optional[int]
            Page limit (default 100)

        offset : typing.Optional[int]
            Page offset (default 0)

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

        Returns
        -------
        ListComponentsResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.list_components(
            q=q, limit=limit, offset=offset, request_options=request_options
        )
        return _response.data

    async def create_component(
        self,
        *,
        entity_type: CreateComponentRequestBodyEntityType,
        name: str,
        ast: typing.Optional[typing.Dict[str, float]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateComponentResponse:
        """
        Parameters
        ----------
        entity_type : CreateComponentRequestBodyEntityType

        name : str

        ast : typing.Optional[typing.Dict[str, float]]

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

        Returns
        -------
        CreateComponentResponse
            Created

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.components.create_component(
                entity_type="entitlement",
                name="name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_component(
            entity_type=entity_type, name=name, ast=ast, request_options=request_options
        )
        return _response.data

    async def get_component(
        self, component_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetComponentResponse:
        """
        Parameters
        ----------
        component_id : str
            component_id

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

        Returns
        -------
        GetComponentResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.components.get_component(
                component_id="component_id",
            )


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

    async def update_component(
        self,
        component_id: str,
        *,
        ast: typing.Optional[typing.Dict[str, float]] = OMIT,
        entity_type: typing.Optional[UpdateComponentRequestBodyEntityType] = OMIT,
        name: typing.Optional[str] = OMIT,
        state: typing.Optional[UpdateComponentRequestBodyState] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateComponentResponse:
        """
        Parameters
        ----------
        component_id : str
            component_id

        ast : typing.Optional[typing.Dict[str, float]]

        entity_type : typing.Optional[UpdateComponentRequestBodyEntityType]

        name : typing.Optional[str]

        state : typing.Optional[UpdateComponentRequestBodyState]

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

        Returns
        -------
        UpdateComponentResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.components.update_component(
                component_id="component_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_component(
            component_id, ast=ast, entity_type=entity_type, name=name, state=state, request_options=request_options
        )
        return _response.data

    async def delete_component(
        self, component_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteComponentResponse:
        """
        Parameters
        ----------
        component_id : str
            component_id

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

        Returns
        -------
        DeleteComponentResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.components.delete_component(
                component_id="component_id",
            )


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

    async def count_components(
        self,
        *,
        q: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CountComponentsResponse:
        """
        Parameters
        ----------
        q : typing.Optional[str]

        limit : typing.Optional[int]
            Page limit (default 100)

        offset : typing.Optional[int]
            Page offset (default 0)

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

        Returns
        -------
        CountComponentsResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.count_components(
            q=q, limit=limit, offset=offset, request_options=request_options
        )
        return _response.data

    async def preview_component_data(
        self,
        *,
        company_id: typing.Optional[str] = None,
        component_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PreviewComponentDataResponse:
        """
        Parameters
        ----------
        company_id : typing.Optional[str]

        component_id : typing.Optional[str]

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

        Returns
        -------
        PreviewComponentDataResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.preview_component_data(
            company_id=company_id, component_id=component_id, request_options=request_options
        )
        return _response.data
