# 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.metadata_response import MetadataResponse
from ..types.uuid_ import Uuid
from .raw_client import AsyncRawMetadataClient, RawMetadataClient
from .types.bulk_update_metadata_params_data import BulkUpdateMetadataParamsData

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


class MetadataClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawMetadataClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawMetadataClient
        """
        return self._raw_client

    def bulk_update(
        self,
        account_id: Uuid,
        project_id: Uuid,
        *,
        data: BulkUpdateMetadataParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Update metadata values across multiple files. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        project_id : Uuid


        data : BulkUpdateMetadataParamsData

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

        Returns
        -------
        None

        Examples
        --------
        from frameio import Frameio
        from frameio.metadata import (
            BulkUpdateMetadataParamsData,
            BulkUpdateMetadataParamsDataValuesItem,
        )

        client = Frameio(
            token="YOUR_TOKEN",
        )
        client.metadata.bulk_update(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            project_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            data=BulkUpdateMetadataParamsData(
                file_ids=[
                    "6aa84ef8-7f0a-431e-805e-a5e96345a176",
                    "54916a83-698a-43f8-9f14-19fd99094474",
                ],
                values=[
                    BulkUpdateMetadataParamsDataValuesItem(
                        field_definition_id="79e05ece-741a-4a20-b320-3a09c15673bb",
                        value=[
                            {
                                "id": "95681686-3627-4b8c-9a7c-982e41dc8af6",
                                "type": "user",
                            },
                            {
                                "id": "8759b175-9d71-41af-8b52-0dc79db384ec",
                                "type": "account_user_group",
                            },
                        ],
                    )
                ],
            ),
        )
        """
        _response = self._raw_client.bulk_update(account_id, project_id, data=data, request_options=request_options)
        return _response.data

    def show(
        self,
        account_id: Uuid,
        file_id: Uuid,
        *,
        show_null: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MetadataResponse:
        """
        Show the metadata of a file. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        file_id : Uuid


        show_null : typing.Optional[bool]


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

        Returns
        -------
        MetadataResponse
            OK

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

        client = Frameio(
            token="YOUR_TOKEN",
        )
        client.metadata.show(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            file_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            show_null=True,
        )
        """
        _response = self._raw_client.show(account_id, file_id, show_null=show_null, request_options=request_options)
        return _response.data


class AsyncMetadataClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawMetadataClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawMetadataClient
        """
        return self._raw_client

    async def bulk_update(
        self,
        account_id: Uuid,
        project_id: Uuid,
        *,
        data: BulkUpdateMetadataParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Update metadata values across multiple files. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        project_id : Uuid


        data : BulkUpdateMetadataParamsData

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio
        from frameio.metadata import (
            BulkUpdateMetadataParamsData,
            BulkUpdateMetadataParamsDataValuesItem,
        )

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.metadata.bulk_update(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                project_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                data=BulkUpdateMetadataParamsData(
                    file_ids=[
                        "6aa84ef8-7f0a-431e-805e-a5e96345a176",
                        "54916a83-698a-43f8-9f14-19fd99094474",
                    ],
                    values=[
                        BulkUpdateMetadataParamsDataValuesItem(
                            field_definition_id="79e05ece-741a-4a20-b320-3a09c15673bb",
                            value=[
                                {
                                    "id": "95681686-3627-4b8c-9a7c-982e41dc8af6",
                                    "type": "user",
                                },
                                {
                                    "id": "8759b175-9d71-41af-8b52-0dc79db384ec",
                                    "type": "account_user_group",
                                },
                            ],
                        )
                    ],
                ),
            )


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

    async def show(
        self,
        account_id: Uuid,
        file_id: Uuid,
        *,
        show_null: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MetadataResponse:
        """
        Show the metadata of a file. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        file_id : Uuid


        show_null : typing.Optional[bool]


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

        Returns
        -------
        MetadataResponse
            OK

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.metadata.show(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                file_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                show_null=True,
            )


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