# 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.field_definition_response import FieldDefinitionResponse
from ..types.field_definitions_with_includes_response import FieldDefinitionsWithIncludesResponse
from ..types.include_total_count import IncludeTotalCount
from ..types.request_after_opaque_cursor import RequestAfterOpaqueCursor
from ..types.request_page_size import RequestPageSize
from ..types.uuid_ import Uuid
from .raw_client import AsyncRawMetadataFieldsClient, RawMetadataFieldsClient
from .types.create_field_definition_params_data import CreateFieldDefinitionParamsData
from .types.update_field_definition_params_data import UpdateFieldDefinitionParamsData

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


class MetadataFieldsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawMetadataFieldsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawMetadataFieldsClient
        """
        return self._raw_client

    def metadata_field_definitions_delete(
        self, account_id: Uuid, field_definition_id: Uuid, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete account level custom field definitions. <br>Rate Limits: 60 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        field_definition_id : Uuid


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

        Returns
        -------
        None

        Examples
        --------
        from frameio import Frameio

        client = Frameio(
            token="YOUR_TOKEN",
        )
        client.metadata_fields.metadata_field_definitions_delete(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            field_definition_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
        )
        """
        _response = self._raw_client.metadata_field_definitions_delete(
            account_id, field_definition_id, request_options=request_options
        )
        return _response.data

    def metadata_field_definitions_update(
        self,
        account_id: Uuid,
        field_definition_id: Uuid,
        *,
        data: typing.Optional[UpdateFieldDefinitionParamsData] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FieldDefinitionResponse:
        """
        Update account level custom field definitions. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        field_definition_id : Uuid


        data : typing.Optional[UpdateFieldDefinitionParamsData]

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

        Returns
        -------
        FieldDefinitionResponse
            OK

        Examples
        --------
        from frameio import (
            Frameio,
            UpdateSelectDefinitionParamsFieldConfiguration,
            UpdateSelectDefinitionParamsFieldConfigurationOptionsItem,
        )
        from frameio.metadata_fields import UpdateFieldDefinitionParamsData_Select

        client = Frameio(
            token="YOUR_TOKEN",
        )
        client.metadata_fields.metadata_field_definitions_update(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            field_definition_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            data=UpdateFieldDefinitionParamsData_Select(
                field_configuration=UpdateSelectDefinitionParamsFieldConfiguration(
                    enable_add_new=False,
                    options=[
                        UpdateSelectDefinitionParamsFieldConfigurationOptionsItem(
                            display_name="Option 1",
                        ),
                        UpdateSelectDefinitionParamsFieldConfigurationOptionsItem(
                            display_name="Option 2",
                        ),
                    ],
                ),
                name="Updated-Field-Name",
            ),
        )
        """
        _response = self._raw_client.metadata_field_definitions_update(
            account_id, field_definition_id, data=data, request_options=request_options
        )
        return _response.data

    def metadata_field_definitions_index(
        self,
        account_id: Uuid,
        *,
        include: typing.Optional[typing.Literal["creator"]] = None,
        after: typing.Optional[RequestAfterOpaqueCursor] = None,
        page_size: typing.Optional[RequestPageSize] = None,
        include_total_count: typing.Optional[IncludeTotalCount] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FieldDefinitionsWithIncludesResponse:
        """
        List account level field definitions. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        include : typing.Optional[typing.Literal["creator"]]


        after : typing.Optional[RequestAfterOpaqueCursor]
            Opaque Cursor query param for requests returning paginated results.
            <br/>
            NOTE: this value is auto-generated and included as part of links from a previous response. It is not intended to be human readable.

        page_size : typing.Optional[RequestPageSize]


        include_total_count : typing.Optional[IncludeTotalCount]


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

        Returns
        -------
        FieldDefinitionsWithIncludesResponse
            OK

        Examples
        --------
        from frameio import Frameio

        client = Frameio(
            token="YOUR_TOKEN",
        )
        client.metadata_fields.metadata_field_definitions_index(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            after="<opaque_cursor>",
            page_size=10,
            include_total_count=False,
        )
        """
        _response = self._raw_client.metadata_field_definitions_index(
            account_id,
            include=include,
            after=after,
            page_size=page_size,
            include_total_count=include_total_count,
            request_options=request_options,
        )
        return _response.data

    def metadata_field_definitions_create(
        self,
        account_id: Uuid,
        *,
        data: typing.Optional[CreateFieldDefinitionParamsData] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FieldDefinitionResponse:
        """
        Create account level field definitions. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        data : typing.Optional[CreateFieldDefinitionParamsData]

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

        Returns
        -------
        FieldDefinitionResponse
            Created

        Examples
        --------
        from frameio import (
            Frameio,
            SelectDefinitionParamsFieldConfiguration,
            SelectDefinitionParamsFieldConfigurationOptionsItem,
        )
        from frameio.metadata_fields import CreateFieldDefinitionParamsData_Select

        client = Frameio(
            token="YOUR_TOKEN",
        )
        client.metadata_fields.metadata_field_definitions_create(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            data=CreateFieldDefinitionParamsData_Select(
                field_configuration=SelectDefinitionParamsFieldConfiguration(
                    enable_add_new=False,
                    options=[
                        SelectDefinitionParamsFieldConfigurationOptionsItem(
                            display_name="Option 1",
                        ),
                        SelectDefinitionParamsFieldConfigurationOptionsItem(
                            display_name="Option 2",
                        ),
                    ],
                ),
                name="Fields definition name",
            ),
        )
        """
        _response = self._raw_client.metadata_field_definitions_create(
            account_id, data=data, request_options=request_options
        )
        return _response.data


class AsyncMetadataFieldsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawMetadataFieldsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawMetadataFieldsClient
        """
        return self._raw_client

    async def metadata_field_definitions_delete(
        self, account_id: Uuid, field_definition_id: Uuid, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete account level custom field definitions. <br>Rate Limits: 60 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        field_definition_id : Uuid


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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.metadata_fields.metadata_field_definitions_delete(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                field_definition_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.metadata_field_definitions_delete(
            account_id, field_definition_id, request_options=request_options
        )
        return _response.data

    async def metadata_field_definitions_update(
        self,
        account_id: Uuid,
        field_definition_id: Uuid,
        *,
        data: typing.Optional[UpdateFieldDefinitionParamsData] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FieldDefinitionResponse:
        """
        Update account level custom field definitions. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        field_definition_id : Uuid


        data : typing.Optional[UpdateFieldDefinitionParamsData]

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

        Returns
        -------
        FieldDefinitionResponse
            OK

        Examples
        --------
        import asyncio

        from frameio import (
            AsyncFrameio,
            UpdateSelectDefinitionParamsFieldConfiguration,
            UpdateSelectDefinitionParamsFieldConfigurationOptionsItem,
        )
        from frameio.metadata_fields import UpdateFieldDefinitionParamsData_Select

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.metadata_fields.metadata_field_definitions_update(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                field_definition_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                data=UpdateFieldDefinitionParamsData_Select(
                    field_configuration=UpdateSelectDefinitionParamsFieldConfiguration(
                        enable_add_new=False,
                        options=[
                            UpdateSelectDefinitionParamsFieldConfigurationOptionsItem(
                                display_name="Option 1",
                            ),
                            UpdateSelectDefinitionParamsFieldConfigurationOptionsItem(
                                display_name="Option 2",
                            ),
                        ],
                    ),
                    name="Updated-Field-Name",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.metadata_field_definitions_update(
            account_id, field_definition_id, data=data, request_options=request_options
        )
        return _response.data

    async def metadata_field_definitions_index(
        self,
        account_id: Uuid,
        *,
        include: typing.Optional[typing.Literal["creator"]] = None,
        after: typing.Optional[RequestAfterOpaqueCursor] = None,
        page_size: typing.Optional[RequestPageSize] = None,
        include_total_count: typing.Optional[IncludeTotalCount] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FieldDefinitionsWithIncludesResponse:
        """
        List account level field definitions. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        include : typing.Optional[typing.Literal["creator"]]


        after : typing.Optional[RequestAfterOpaqueCursor]
            Opaque Cursor query param for requests returning paginated results.
            <br/>
            NOTE: this value is auto-generated and included as part of links from a previous response. It is not intended to be human readable.

        page_size : typing.Optional[RequestPageSize]


        include_total_count : typing.Optional[IncludeTotalCount]


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

        Returns
        -------
        FieldDefinitionsWithIncludesResponse
            OK

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.metadata_fields.metadata_field_definitions_index(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                after="<opaque_cursor>",
                page_size=10,
                include_total_count=False,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.metadata_field_definitions_index(
            account_id,
            include=include,
            after=after,
            page_size=page_size,
            include_total_count=include_total_count,
            request_options=request_options,
        )
        return _response.data

    async def metadata_field_definitions_create(
        self,
        account_id: Uuid,
        *,
        data: typing.Optional[CreateFieldDefinitionParamsData] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FieldDefinitionResponse:
        """
        Create account level field definitions. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        data : typing.Optional[CreateFieldDefinitionParamsData]

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

        Returns
        -------
        FieldDefinitionResponse
            Created

        Examples
        --------
        import asyncio

        from frameio import (
            AsyncFrameio,
            SelectDefinitionParamsFieldConfiguration,
            SelectDefinitionParamsFieldConfigurationOptionsItem,
        )
        from frameio.metadata_fields import CreateFieldDefinitionParamsData_Select

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.metadata_fields.metadata_field_definitions_create(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                data=CreateFieldDefinitionParamsData_Select(
                    field_configuration=SelectDefinitionParamsFieldConfiguration(
                        enable_add_new=False,
                        options=[
                            SelectDefinitionParamsFieldConfigurationOptionsItem(
                                display_name="Option 1",
                            ),
                            SelectDefinitionParamsFieldConfigurationOptionsItem(
                                display_name="Option 2",
                            ),
                        ],
                    ),
                    name="Fields definition name",
                ),
            )


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