# This file was auto-generated by Fern from our API Definition.

import typing
from json.decoder import JSONDecodeError

from ..core.api_error import ApiError
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.http_response import AsyncHttpResponse, HttpResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..core.request_options import RequestOptions
from ..core.serialization import convert_and_respect_annotation_metadata
from ..core.unchecked_base_model import construct_type
from ..errors.bad_request_error import BadRequestError
from ..errors.conflict_error import ConflictError
from ..errors.forbidden_error import ForbiddenError
from ..errors.not_found_error import NotFoundError
from ..errors.too_many_requests_error import TooManyRequestsError
from ..errors.unauthorized_error import UnauthorizedError
from ..errors.unprocessable_entity_error import UnprocessableEntityError
from ..types.bad_request import BadRequest
from ..types.children_type import ChildrenType
from ..types.conflict import Conflict
from ..types.folder_assets_with_includes_response import FolderAssetsWithIncludesResponse
from ..types.folder_copy_response import FolderCopyResponse
from ..types.folder_response import FolderResponse
from ..types.folder_with_includes_response import FolderWithIncludesResponse
from ..types.folders_with_includes_response import FoldersWithIncludesResponse
from ..types.forbidden import Forbidden
from ..types.include_total_count import IncludeTotalCount
from ..types.not_found import NotFound
from ..types.request_after_opaque_cursor import RequestAfterOpaqueCursor
from ..types.request_page_size import RequestPageSize
from ..types.too_many_requests import TooManyRequests
from ..types.unauthorized import Unauthorized
from ..types.uuid_ import Uuid
from .types.folder_copy_params_data import FolderCopyParamsData
from .types.folder_create_params_data import FolderCreateParamsData
from .types.folder_move_params_data import FolderMoveParamsData
from .types.folder_update_params_data import FolderUpdateParamsData
from .types.folders_index_request_include import FoldersIndexRequestInclude
from .types.folders_list_request_include import FoldersListRequestInclude
from .types.folders_show_request_include import FoldersShowRequestInclude

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


class RawFoldersClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper

    def show(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        include: typing.Optional[FoldersShowRequestInclude] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[FolderWithIncludesResponse]:
        """
        Show folder details. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        folder_id : Uuid


        include : typing.Optional[FoldersShowRequestInclude]


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

        Returns
        -------
        HttpResponse[FolderWithIncludesResponse]
            OK
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}",
            method="GET",
            params={
                "include": include,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FolderWithIncludesResponse,
                    construct_type(
                        type_=FolderWithIncludesResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def delete(
        self, account_id: Uuid, folder_id: Uuid, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[None]:
        """
        Delete folder by id. <br>Rate Limits: 60 calls per 1.00 minute(s) per account_user

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


        folder_id : Uuid


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

        Returns
        -------
        HttpResponse[None]
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return HttpResponse(response=_response, data=None)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def update(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        data: FolderUpdateParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[FolderResponse]:
        """
        Update folder details. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        folder_id : Uuid


        data : FolderUpdateParamsData

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

        Returns
        -------
        HttpResponse[FolderResponse]
            OK
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}",
            method="PATCH",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FolderUpdateParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FolderResponse,
                    construct_type(
                        type_=FolderResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def index(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        include: typing.Optional[FoldersIndexRequestInclude] = None,
        type: typing.Optional[ChildrenType] = 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,
    ) -> HttpResponse[FolderAssetsWithIncludesResponse]:
        """
        List the children in the given folder.
        <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


        folder_id : Uuid


        include : typing.Optional[FoldersIndexRequestInclude]


        type : typing.Optional[ChildrenType]


        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
        -------
        HttpResponse[FolderAssetsWithIncludesResponse]
            OK
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}/children",
            method="GET",
            params={
                "include": include,
                "type": type,
                "after": after,
                "page_size": page_size,
                "include_total_count": include_total_count,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FolderAssetsWithIncludesResponse,
                    construct_type(
                        type_=FolderAssetsWithIncludesResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def copy(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        copy_metadata: typing.Optional[bool] = None,
        data: typing.Optional[FolderCopyParamsData] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[FolderCopyResponse]:
        """
        Copy folder. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        folder_id : Uuid


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

        data : typing.Optional[FolderCopyParamsData]

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

        Returns
        -------
        HttpResponse[FolderCopyResponse]
            OK
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}/copy",
            method="POST",
            params={
                "copy_metadata": copy_metadata,
            },
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FolderCopyParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FolderCopyResponse,
                    construct_type(
                        type_=FolderCopyResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def list(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        include: typing.Optional[FoldersListRequestInclude] = 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,
    ) -> HttpResponse[FoldersWithIncludesResponse]:
        """
        List folders 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[FoldersListRequestInclude]


        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
        -------
        HttpResponse[FoldersWithIncludesResponse]
            OK
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}/folders",
            method="GET",
            params={
                "include": include,
                "after": after,
                "page_size": page_size,
                "include_total_count": include_total_count,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FoldersWithIncludesResponse,
                    construct_type(
                        type_=FoldersWithIncludesResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def create(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        data: FolderCreateParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[FolderResponse]:
        """
        Create a new folder inside the given <i>folder_id</i> path param. <br>Rate Limits: 3 calls per 1 second(s) per account_user

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


        folder_id : Uuid


        data : FolderCreateParamsData

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

        Returns
        -------
        HttpResponse[FolderResponse]
            Created
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}/folders",
            method="POST",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FolderCreateParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FolderResponse,
                    construct_type(
                        type_=FolderResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

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


        folder_id : Uuid


        data : FolderMoveParamsData

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

        Returns
        -------
        HttpResponse[FolderResponse]
            OK
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}/move",
            method="PATCH",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FolderMoveParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FolderResponse,
                    construct_type(
                        type_=FolderResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)


class AsyncRawFoldersClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def show(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        include: typing.Optional[FoldersShowRequestInclude] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[FolderWithIncludesResponse]:
        """
        Show folder details. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        folder_id : Uuid


        include : typing.Optional[FoldersShowRequestInclude]


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

        Returns
        -------
        AsyncHttpResponse[FolderWithIncludesResponse]
            OK
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}",
            method="GET",
            params={
                "include": include,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FolderWithIncludesResponse,
                    construct_type(
                        type_=FolderWithIncludesResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def delete(
        self, account_id: Uuid, folder_id: Uuid, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[None]:
        """
        Delete folder by id. <br>Rate Limits: 60 calls per 1.00 minute(s) per account_user

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


        folder_id : Uuid


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

        Returns
        -------
        AsyncHttpResponse[None]
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return AsyncHttpResponse(response=_response, data=None)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def update(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        data: FolderUpdateParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[FolderResponse]:
        """
        Update folder details. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        folder_id : Uuid


        data : FolderUpdateParamsData

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

        Returns
        -------
        AsyncHttpResponse[FolderResponse]
            OK
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}",
            method="PATCH",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FolderUpdateParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FolderResponse,
                    construct_type(
                        type_=FolderResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def index(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        include: typing.Optional[FoldersIndexRequestInclude] = None,
        type: typing.Optional[ChildrenType] = 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,
    ) -> AsyncHttpResponse[FolderAssetsWithIncludesResponse]:
        """
        List the children in the given folder.
        <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


        folder_id : Uuid


        include : typing.Optional[FoldersIndexRequestInclude]


        type : typing.Optional[ChildrenType]


        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
        -------
        AsyncHttpResponse[FolderAssetsWithIncludesResponse]
            OK
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}/children",
            method="GET",
            params={
                "include": include,
                "type": type,
                "after": after,
                "page_size": page_size,
                "include_total_count": include_total_count,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FolderAssetsWithIncludesResponse,
                    construct_type(
                        type_=FolderAssetsWithIncludesResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def copy(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        copy_metadata: typing.Optional[bool] = None,
        data: typing.Optional[FolderCopyParamsData] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[FolderCopyResponse]:
        """
        Copy folder. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        folder_id : Uuid


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

        data : typing.Optional[FolderCopyParamsData]

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

        Returns
        -------
        AsyncHttpResponse[FolderCopyResponse]
            OK
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}/copy",
            method="POST",
            params={
                "copy_metadata": copy_metadata,
            },
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FolderCopyParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FolderCopyResponse,
                    construct_type(
                        type_=FolderCopyResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def list(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        include: typing.Optional[FoldersListRequestInclude] = 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,
    ) -> AsyncHttpResponse[FoldersWithIncludesResponse]:
        """
        List folders 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[FoldersListRequestInclude]


        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
        -------
        AsyncHttpResponse[FoldersWithIncludesResponse]
            OK
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}/folders",
            method="GET",
            params={
                "include": include,
                "after": after,
                "page_size": page_size,
                "include_total_count": include_total_count,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FoldersWithIncludesResponse,
                    construct_type(
                        type_=FoldersWithIncludesResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def create(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        data: FolderCreateParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[FolderResponse]:
        """
        Create a new folder inside the given <i>folder_id</i> path param. <br>Rate Limits: 3 calls per 1 second(s) per account_user

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


        folder_id : Uuid


        data : FolderCreateParamsData

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

        Returns
        -------
        AsyncHttpResponse[FolderResponse]
            Created
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}/folders",
            method="POST",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FolderCreateParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FolderResponse,
                    construct_type(
                        type_=FolderResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

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


        folder_id : Uuid


        data : FolderMoveParamsData

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

        Returns
        -------
        AsyncHttpResponse[FolderResponse]
            OK
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}/move",
            method="PATCH",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FolderMoveParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FolderResponse,
                    construct_type(
                        type_=FolderResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        BadRequest,
                        construct_type(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        construct_type(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        construct_type(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        construct_type(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 409:
                raise ConflictError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Conflict,
                        construct_type(
                            type_=Conflict,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        construct_type(
                            type_=TooManyRequests,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
