# 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 AsyncRawFunctionsClient, RawFunctionsClient
from .types.functions_create_request_dependencies_value import (
    FunctionsCreateRequestDependenciesValue,
)
from .types.functions_create_response import FunctionsCreateResponse
from .types.functions_find_by_hash_response import FunctionsFindByHashResponse
from .types.functions_get_by_env_response import FunctionsGetByEnvResponse
from .types.functions_get_response import FunctionsGetResponse
from .types.functions_list_by_env_response import FunctionsListByEnvResponse
from .types.functions_list_response import FunctionsListResponse

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


class FunctionsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawFunctionsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawFunctionsClient
        """
        return self._raw_client

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

        Returns
        -------
        FunctionsListResponse
            Success

        Examples
        --------
        from mirascope.api._generated import Mirascope

        client = Mirascope()
        client.functions.list()
        """
        _response = self._raw_client.list(request_options=request_options)
        return _response.data

    def create(
        self,
        *,
        code: str,
        hash: str,
        signature: str,
        signature_hash: str,
        name: str,
        description: typing.Optional[str] = OMIT,
        tags: typing.Optional[typing.Sequence[str]] = OMIT,
        metadata: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
        dependencies: typing.Optional[
            typing.Dict[str, typing.Optional[FunctionsCreateRequestDependenciesValue]]
        ] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FunctionsCreateResponse:
        """
        Parameters
        ----------
        code : str

        hash : str

        signature : str

        signature_hash : str

        name : str

        description : typing.Optional[str]

        tags : typing.Optional[typing.Sequence[str]]

        metadata : typing.Optional[typing.Dict[str, typing.Optional[str]]]

        dependencies : typing.Optional[typing.Dict[str, typing.Optional[FunctionsCreateRequestDependenciesValue]]]

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

        Returns
        -------
        FunctionsCreateResponse
            Success

        Examples
        --------
        from mirascope.api._generated import Mirascope

        client = Mirascope()
        client.functions.create(
            code="code",
            hash="hash",
            signature="signature",
            signature_hash="signatureHash",
            name="name",
        )
        """
        _response = self._raw_client.create(
            code=code,
            hash=hash,
            signature=signature,
            signature_hash=signature_hash,
            name=name,
            description=description,
            tags=tags,
            metadata=metadata,
            dependencies=dependencies,
            request_options=request_options,
        )
        return _response.data

    def get(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> FunctionsGetResponse:
        """
        Parameters
        ----------
        id : str

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

        Returns
        -------
        FunctionsGetResponse
            Success

        Examples
        --------
        from mirascope.api._generated import Mirascope

        client = Mirascope()
        client.functions.get(
            id="id",
        )
        """
        _response = self._raw_client.get(id, request_options=request_options)
        return _response.data

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

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

        Returns
        -------
        None

        Examples
        --------
        from mirascope.api._generated import Mirascope

        client = Mirascope()
        client.functions.delete(
            id="id",
        )
        """
        _response = self._raw_client.delete(id, request_options=request_options)
        return _response.data

    def findbyhash(
        self, hash: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> FunctionsFindByHashResponse:
        """
        Parameters
        ----------
        hash : str

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

        Returns
        -------
        FunctionsFindByHashResponse
            Success

        Examples
        --------
        from mirascope.api._generated import Mirascope

        client = Mirascope()
        client.functions.findbyhash(
            hash="hash",
        )
        """
        _response = self._raw_client.findbyhash(hash, request_options=request_options)
        return _response.data

    def getbyenv(
        self,
        organization_id: str,
        project_id: str,
        environment_id: str,
        function_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FunctionsGetByEnvResponse:
        """
        Parameters
        ----------
        organization_id : str

        project_id : str

        environment_id : str

        function_id : str

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

        Returns
        -------
        FunctionsGetByEnvResponse
            Success

        Examples
        --------
        from mirascope.api._generated import Mirascope

        client = Mirascope()
        client.functions.getbyenv(
            organization_id="organizationId",
            project_id="projectId",
            environment_id="environmentId",
            function_id="functionId",
        )
        """
        _response = self._raw_client.getbyenv(
            organization_id,
            project_id,
            environment_id,
            function_id,
            request_options=request_options,
        )
        return _response.data

    def listbyenv(
        self,
        organization_id: str,
        project_id: str,
        environment_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FunctionsListByEnvResponse:
        """
        Parameters
        ----------
        organization_id : str

        project_id : str

        environment_id : str

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

        Returns
        -------
        FunctionsListByEnvResponse
            Success

        Examples
        --------
        from mirascope.api._generated import Mirascope

        client = Mirascope()
        client.functions.listbyenv(
            organization_id="organizationId",
            project_id="projectId",
            environment_id="environmentId",
        )
        """
        _response = self._raw_client.listbyenv(
            organization_id, project_id, environment_id, request_options=request_options
        )
        return _response.data


class AsyncFunctionsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawFunctionsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawFunctionsClient
        """
        return self._raw_client

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

        Returns
        -------
        FunctionsListResponse
            Success

        Examples
        --------
        import asyncio

        from mirascope.api._generated import AsyncMirascope

        client = AsyncMirascope()


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


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

    async def create(
        self,
        *,
        code: str,
        hash: str,
        signature: str,
        signature_hash: str,
        name: str,
        description: typing.Optional[str] = OMIT,
        tags: typing.Optional[typing.Sequence[str]] = OMIT,
        metadata: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
        dependencies: typing.Optional[
            typing.Dict[str, typing.Optional[FunctionsCreateRequestDependenciesValue]]
        ] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FunctionsCreateResponse:
        """
        Parameters
        ----------
        code : str

        hash : str

        signature : str

        signature_hash : str

        name : str

        description : typing.Optional[str]

        tags : typing.Optional[typing.Sequence[str]]

        metadata : typing.Optional[typing.Dict[str, typing.Optional[str]]]

        dependencies : typing.Optional[typing.Dict[str, typing.Optional[FunctionsCreateRequestDependenciesValue]]]

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

        Returns
        -------
        FunctionsCreateResponse
            Success

        Examples
        --------
        import asyncio

        from mirascope.api._generated import AsyncMirascope

        client = AsyncMirascope()


        async def main() -> None:
            await client.functions.create(
                code="code",
                hash="hash",
                signature="signature",
                signature_hash="signatureHash",
                name="name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            code=code,
            hash=hash,
            signature=signature,
            signature_hash=signature_hash,
            name=name,
            description=description,
            tags=tags,
            metadata=metadata,
            dependencies=dependencies,
            request_options=request_options,
        )
        return _response.data

    async def get(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> FunctionsGetResponse:
        """
        Parameters
        ----------
        id : str

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

        Returns
        -------
        FunctionsGetResponse
            Success

        Examples
        --------
        import asyncio

        from mirascope.api._generated import AsyncMirascope

        client = AsyncMirascope()


        async def main() -> None:
            await client.functions.get(
                id="id",
            )


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

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

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from mirascope.api._generated import AsyncMirascope

        client = AsyncMirascope()


        async def main() -> None:
            await client.functions.delete(
                id="id",
            )


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

    async def findbyhash(
        self, hash: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> FunctionsFindByHashResponse:
        """
        Parameters
        ----------
        hash : str

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

        Returns
        -------
        FunctionsFindByHashResponse
            Success

        Examples
        --------
        import asyncio

        from mirascope.api._generated import AsyncMirascope

        client = AsyncMirascope()


        async def main() -> None:
            await client.functions.findbyhash(
                hash="hash",
            )


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

    async def getbyenv(
        self,
        organization_id: str,
        project_id: str,
        environment_id: str,
        function_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FunctionsGetByEnvResponse:
        """
        Parameters
        ----------
        organization_id : str

        project_id : str

        environment_id : str

        function_id : str

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

        Returns
        -------
        FunctionsGetByEnvResponse
            Success

        Examples
        --------
        import asyncio

        from mirascope.api._generated import AsyncMirascope

        client = AsyncMirascope()


        async def main() -> None:
            await client.functions.getbyenv(
                organization_id="organizationId",
                project_id="projectId",
                environment_id="environmentId",
                function_id="functionId",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.getbyenv(
            organization_id,
            project_id,
            environment_id,
            function_id,
            request_options=request_options,
        )
        return _response.data

    async def listbyenv(
        self,
        organization_id: str,
        project_id: str,
        environment_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FunctionsListByEnvResponse:
        """
        Parameters
        ----------
        organization_id : str

        project_id : str

        environment_id : str

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

        Returns
        -------
        FunctionsListByEnvResponse
            Success

        Examples
        --------
        import asyncio

        from mirascope.api._generated import AsyncMirascope

        client = AsyncMirascope()


        async def main() -> None:
            await client.functions.listbyenv(
                organization_id="organizationId",
                project_id="projectId",
                environment_id="environmentId",
            )


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