# 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.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 ..types.version_stack_assets_with_includes_response import VersionStackAssetsWithIncludesResponse
from ..types.version_stack_copy_response import VersionStackCopyResponse
from ..types.version_stack_response import VersionStackResponse
from ..types.version_stack_with_includes_response import VersionStackWithIncludesResponse
from ..types.version_stacks_with_includes_response import VersionStacksWithIncludesResponse
from .raw_client import AsyncRawVersionStacksClient, RawVersionStacksClient
from .types.version_stack_copy_params_data import VersionStackCopyParamsData
from .types.version_stack_create_params_data import VersionStackCreateParamsData
from .types.version_stack_move_params_data import VersionStackMoveParamsData
from .types.version_stacks_index_request_include import VersionStacksIndexRequestInclude
from .types.version_stacks_list_request_include import VersionStacksListRequestInclude
from .types.version_stacks_show_request_include import VersionStacksShowRequestInclude

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


class VersionStacksClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawVersionStacksClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawVersionStacksClient
        """
        return self._raw_client

    def index(
        self,
        account_id: Uuid,
        version_stack_id: Uuid,
        *,
        include: typing.Optional[VersionStacksIndexRequestInclude] = 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,
    ) -> VersionStackAssetsWithIncludesResponse:
        """
        List the children (files) in a given version stack.
        <br>
        Use the `include` query parameter to selectively include additional properties in the response.
        <br>
        Note: if you include `media_links.original` and the user does not have permission to download files
        in the corresponding project, then this endpoint will respond with a `403 Forbidden` error.
        If the content is inaccessible because watermarking is required for this user and isn't supported by
        the requested media_links, then the request will succeed but the unsupported media links will be set to null.
        Similarly, if a requested transcode link does not exist for a particular file (e.g. including
        `media_links.video_h264_180` on a static image file) or transoding process hasn't finished
        (i.e. the file's `status` is "uploaded" rather than "transcoded"), then the a media link will also be set to
        null in the response payload. In short, the client must handle null media links gracefully.
        <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        version_stack_id : Uuid


        include : typing.Optional[VersionStacksIndexRequestInclude]


        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
        -------
        VersionStackAssetsWithIncludesResponse
            OK

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

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

    def show(
        self,
        account_id: Uuid,
        version_stack_id: Uuid,
        *,
        include: typing.Optional[VersionStacksShowRequestInclude] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> VersionStackWithIncludesResponse:
        """
        Show version stack details. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        version_stack_id : Uuid


        include : typing.Optional[VersionStacksShowRequestInclude]


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

        Returns
        -------
        VersionStackWithIncludesResponse
            OK

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

        client = Frameio(
            token="YOUR_TOKEN",
        )
        client.version_stacks.show(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            version_stack_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            include="media_links",
        )
        """
        _response = self._raw_client.show(
            account_id, version_stack_id, include=include, request_options=request_options
        )
        return _response.data

    def copy(
        self,
        account_id: Uuid,
        version_stack_id: Uuid,
        *,
        copy_metadata: typing.Optional[bool] = None,
        data: typing.Optional[VersionStackCopyParamsData] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> VersionStackCopyResponse:
        """
        Copy version stack. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        version_stack_id : Uuid


        copy_metadata : typing.Optional[bool]
            Whether to copy metadata values along with the version stack

        data : typing.Optional[VersionStackCopyParamsData]

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

        Returns
        -------
        VersionStackCopyResponse
            OK

        Examples
        --------
        from frameio import Frameio
        from frameio.version_stacks import VersionStackCopyParamsData

        client = Frameio(
            token="YOUR_TOKEN",
        )
        client.version_stacks.copy(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            version_stack_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            copy_metadata=True,
            data=VersionStackCopyParamsData(
                parent_id="2e426fe0-f965-4594-8b2b-b4dff1dc00ec",
            ),
        )
        """
        _response = self._raw_client.copy(
            account_id, version_stack_id, copy_metadata=copy_metadata, data=data, request_options=request_options
        )
        return _response.data

    def list(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        include: typing.Optional[VersionStacksListRequestInclude] = 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,
    ) -> VersionStacksWithIncludesResponse:
        """
        List version stacks in a given folder.  <br>Rate Limits: 5 calls per 1 second(s) per account_user

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


        folder_id : Uuid


        include : typing.Optional[VersionStacksListRequestInclude]


        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
        -------
        VersionStacksWithIncludesResponse
            OK

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

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

    def create(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        data: VersionStackCreateParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> VersionStackWithIncludesResponse:
        """
        Create a new Version Stack under the parent folder. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        folder_id : Uuid


        data : VersionStackCreateParamsData

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

        Returns
        -------
        VersionStackWithIncludesResponse
            Created

        Examples
        --------
        from frameio import Frameio
        from frameio.version_stacks import VersionStackCreateParamsData

        client = Frameio(
            token="YOUR_TOKEN",
        )
        client.version_stacks.create(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            folder_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            data=VersionStackCreateParamsData(
                file_ids=[
                    "6ba6eaa7-1079-46ab-8448-0f9e9c7075e2",
                    "2ea8d129-5381-48e0-852f-be35f90435a9",
                ],
            ),
        )
        """
        _response = self._raw_client.create(account_id, folder_id, data=data, request_options=request_options)
        return _response.data

    def move(
        self,
        account_id: Uuid,
        version_stack_id: Uuid,
        *,
        data: VersionStackMoveParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> VersionStackResponse:
        """
        Move version stack to a folder. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        version_stack_id : Uuid


        data : VersionStackMoveParamsData

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

        Returns
        -------
        VersionStackResponse
            OK

        Examples
        --------
        from frameio import Frameio
        from frameio.version_stacks import VersionStackMoveParamsData

        client = Frameio(
            token="YOUR_TOKEN",
        )
        client.version_stacks.move(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            version_stack_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            data=VersionStackMoveParamsData(
                parent_id="2e426fe0-f965-4594-8b2b-b4dff1dc00ec",
            ),
        )
        """
        _response = self._raw_client.move(account_id, version_stack_id, data=data, request_options=request_options)
        return _response.data


class AsyncVersionStacksClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawVersionStacksClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawVersionStacksClient
        """
        return self._raw_client

    async def index(
        self,
        account_id: Uuid,
        version_stack_id: Uuid,
        *,
        include: typing.Optional[VersionStacksIndexRequestInclude] = 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,
    ) -> VersionStackAssetsWithIncludesResponse:
        """
        List the children (files) in a given version stack.
        <br>
        Use the `include` query parameter to selectively include additional properties in the response.
        <br>
        Note: if you include `media_links.original` and the user does not have permission to download files
        in the corresponding project, then this endpoint will respond with a `403 Forbidden` error.
        If the content is inaccessible because watermarking is required for this user and isn't supported by
        the requested media_links, then the request will succeed but the unsupported media links will be set to null.
        Similarly, if a requested transcode link does not exist for a particular file (e.g. including
        `media_links.video_h264_180` on a static image file) or transoding process hasn't finished
        (i.e. the file's `status` is "uploaded" rather than "transcoded"), then the a media link will also be set to
        null in the response payload. In short, the client must handle null media links gracefully.
        <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        version_stack_id : Uuid


        include : typing.Optional[VersionStacksIndexRequestInclude]


        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
        -------
        VersionStackAssetsWithIncludesResponse
            OK

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


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


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

    async def show(
        self,
        account_id: Uuid,
        version_stack_id: Uuid,
        *,
        include: typing.Optional[VersionStacksShowRequestInclude] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> VersionStackWithIncludesResponse:
        """
        Show version stack details. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        version_stack_id : Uuid


        include : typing.Optional[VersionStacksShowRequestInclude]


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

        Returns
        -------
        VersionStackWithIncludesResponse
            OK

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.version_stacks.show(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                version_stack_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                include="media_links",
            )


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

    async def copy(
        self,
        account_id: Uuid,
        version_stack_id: Uuid,
        *,
        copy_metadata: typing.Optional[bool] = None,
        data: typing.Optional[VersionStackCopyParamsData] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> VersionStackCopyResponse:
        """
        Copy version stack. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        version_stack_id : Uuid


        copy_metadata : typing.Optional[bool]
            Whether to copy metadata values along with the version stack

        data : typing.Optional[VersionStackCopyParamsData]

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

        Returns
        -------
        VersionStackCopyResponse
            OK

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio
        from frameio.version_stacks import VersionStackCopyParamsData

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.version_stacks.copy(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                version_stack_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                copy_metadata=True,
                data=VersionStackCopyParamsData(
                    parent_id="2e426fe0-f965-4594-8b2b-b4dff1dc00ec",
                ),
            )


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

    async def list(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        include: typing.Optional[VersionStacksListRequestInclude] = 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,
    ) -> VersionStacksWithIncludesResponse:
        """
        List version stacks in a given folder.  <br>Rate Limits: 5 calls per 1 second(s) per account_user

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


        folder_id : Uuid


        include : typing.Optional[VersionStacksListRequestInclude]


        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
        -------
        VersionStacksWithIncludesResponse
            OK

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


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


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

    async def create(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        data: VersionStackCreateParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> VersionStackWithIncludesResponse:
        """
        Create a new Version Stack under the parent folder. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        folder_id : Uuid


        data : VersionStackCreateParamsData

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

        Returns
        -------
        VersionStackWithIncludesResponse
            Created

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio
        from frameio.version_stacks import VersionStackCreateParamsData

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.version_stacks.create(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                folder_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                data=VersionStackCreateParamsData(
                    file_ids=[
                        "6ba6eaa7-1079-46ab-8448-0f9e9c7075e2",
                        "2ea8d129-5381-48e0-852f-be35f90435a9",
                    ],
                ),
            )


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

    async def move(
        self,
        account_id: Uuid,
        version_stack_id: Uuid,
        *,
        data: VersionStackMoveParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> VersionStackResponse:
        """
        Move version stack to a folder. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        version_stack_id : Uuid


        data : VersionStackMoveParamsData

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

        Returns
        -------
        VersionStackResponse
            OK

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio
        from frameio.version_stacks import VersionStackMoveParamsData

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.version_stacks.move(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                version_stack_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                data=VersionStackMoveParamsData(
                    parent_id="2e426fe0-f965-4594-8b2b-b4dff1dc00ec",
                ),
            )


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