# 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.pydantic_utilities import parse_obj_as
from ..core.request_options import RequestOptions
from ..core.serialization import convert_and_respect_annotation_metadata
from ..errors.bad_request_error import BadRequestError
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.file_copy_response import FileCopyResponse
from ..types.file_remote_upload_response import FileRemoteUploadResponse
from ..types.file_response import FileResponse
from ..types.file_upload_status_response import FileUploadStatusResponse
from ..types.file_with_includes_response import FileWithIncludesResponse
from ..types.file_with_media_links_include import FileWithMediaLinksInclude
from ..types.forbidden import Forbidden
from ..types.not_found import NotFound
from ..types.too_many_requests import TooManyRequests
from ..types.unauthorized import Unauthorized
from ..types.uuid_ import Uuid
from .types.file_copy_params_data import FileCopyParamsData
from .types.file_create_remote_upload_params_data import FileCreateRemoteUploadParamsData
from .types.file_import_params_data import FileImportParamsData
from .types.file_move_params_data import FileMoveParamsData
from .types.file_update_params_data import FileUpdateParamsData

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


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

    def show(
        self,
        account_id: Uuid,
        file_id: Uuid,
        *,
        include: typing.Optional[FileWithMediaLinksInclude] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[FileWithIncludesResponse]:
        """
        Show file details.
        <br><br>
        This endpoint has been added to `Current Version` of the API.
        <br><br>
        Please see https://developer.adobe.com/frameio/api/current/#tag/Files/operation/files.show.
        <br><br>
        Use the `include` query parameter to selectively include additional properties in the response.
        <br><br>
        Note: if you include `media_links.original` and the user does not have permission to download the file
        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 completed
        (i.e. the file's `status` is "uploaded" rather than "transcoded"), then the link will also be set to null in
        the response payload. In short, the client must handle null media links gracefully.
        <br><br>
        Rate Limits: 5 calls per 1 second(s) per account

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


        file_id : Uuid


        include : typing.Optional[FileWithMediaLinksInclude]


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

        Returns
        -------
        HttpResponse[FileWithIncludesResponse]
            OK
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/files/{jsonable_encoder(file_id)}",
            method="GET",
            params={
                "include": include,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileWithIncludesResponse,
                    parse_obj_as(
                        type_=FileWithIncludesResponse,  # 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,
                        parse_obj_as(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        parse_obj_as(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        parse_obj_as(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        parse_obj_as(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        parse_obj_as(
                            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,
        file_id: Uuid,
        *,
        data: FileUpdateParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[FileResponse]:
        """
        Update file details.
              <br><br>
              This endpoint has been added to `Current Version` of the API.
              <br><br>
              Please see https://developer.adobe.com/frameio/api/current/#tag/Files/operation/files.update.
              <br><br>
              Rate Limits: 100 calls per 1.00 minute(s) per account

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


        file_id : Uuid


        data : FileUpdateParamsData

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

        Returns
        -------
        HttpResponse[FileResponse]
            OK
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/files/{jsonable_encoder(file_id)}",
            method="PATCH",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FileUpdateParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileResponse,
                    parse_obj_as(
                        type_=FileResponse,  # 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,
                        parse_obj_as(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        parse_obj_as(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        parse_obj_as(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        parse_obj_as(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        parse_obj_as(
                            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,
        file_id: Uuid,
        *,
        data: typing.Optional[FileCopyParamsData] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[FileCopyResponse]:
        """
        Copy file.
            <br><br>
            This endpoint has been added to `Current Version` of the API.
            <br><br>
            Please see https://developer.adobe.com/frameio/api/current/#tag/Files/operation/files.copy.
            <br><br>
            Rate Limits: 100 calls per 1.00 minute(s) per account

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


        file_id : Uuid


        data : typing.Optional[FileCopyParamsData]

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

        Returns
        -------
        HttpResponse[FileCopyResponse]
            OK
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/files/{jsonable_encoder(file_id)}/copy",
            method="POST",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FileCopyParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileCopyResponse,
                    parse_obj_as(
                        type_=FileCopyResponse,  # 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,
                        parse_obj_as(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        parse_obj_as(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        parse_obj_as(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        parse_obj_as(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        parse_obj_as(
                            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,
        file_id: Uuid,
        *,
        data: FileMoveParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[FileResponse]:
        """
        Move file to a folder or version_stack.
              <br><br>
              This endpoint has been added to `Current Version` of the API.
              <br><br>
              Please see https://developer.adobe.com/frameio/api/current/#tag/Files/operation/files.move.
              <br><br>
              Rate Limits: 100 calls per 1.00 minute(s) per account

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


        file_id : Uuid


        data : FileMoveParamsData

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

        Returns
        -------
        HttpResponse[FileResponse]
            OK
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/files/{jsonable_encoder(file_id)}/move",
            method="PATCH",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FileMoveParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileResponse,
                    parse_obj_as(
                        type_=FileResponse,  # 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,
                        parse_obj_as(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        parse_obj_as(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        parse_obj_as(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        parse_obj_as(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        parse_obj_as(
                            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 show_file_upload_status(
        self, account_id: Uuid, file_id: Uuid, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[FileUploadStatusResponse]:
        """
        Show file upload status details.
              <br><br>
              This endpoint has been added to `Current Version` of the API.
              <br><br>
              Please see https://developer.adobe.com/frameio/api/current/#tag/Files/operation/files.show_file_upload_status.
              <br><br>
              Rate Limits: 5 calls per 1 second(s) per account

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


        file_id : Uuid


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

        Returns
        -------
        HttpResponse[FileUploadStatusResponse]
            OK
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/files/{jsonable_encoder(file_id)}/status",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileUploadStatusResponse,
                    parse_obj_as(
                        type_=FileUploadStatusResponse,  # 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,
                        parse_obj_as(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        parse_obj_as(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        parse_obj_as(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        parse_obj_as(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        parse_obj_as(
                            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 import_file(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        data: FileImportParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[FileResponse]:
        """
        Import a file from a storage location configured on the account. <br><br>Rate Limits: 5 calls per 1 second(s) per account

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


        folder_id : Uuid


        data : FileImportParamsData

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

        Returns
        -------
        HttpResponse[FileResponse]
            Accepted
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}/files/import",
            method="POST",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FileImportParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileResponse,
                    parse_obj_as(
                        type_=FileResponse,  # 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,
                        parse_obj_as(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        parse_obj_as(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        parse_obj_as(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        parse_obj_as(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        parse_obj_as(
                            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_remote_upload(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        data: FileCreateRemoteUploadParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[FileRemoteUploadResponse]:
        """
        Create new file under parent folder through remote upload.
              <br><br>
              This endpoint has been added to `Current Version` of the API.
              <br><br>
              Please see https://developer.adobe.com/frameio/api/current/#tag/Files/operation/files.create_remote_upload.
              <br><br>
              Rate Limits: 5 calls per 1 second(s) per account

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


        folder_id : Uuid


        data : FileCreateRemoteUploadParamsData

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

        Returns
        -------
        HttpResponse[FileRemoteUploadResponse]
            Accepted
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}/files/remote_upload",
            method="POST",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FileCreateRemoteUploadParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileRemoteUploadResponse,
                    parse_obj_as(
                        type_=FileRemoteUploadResponse,  # 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,
                        parse_obj_as(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        parse_obj_as(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        parse_obj_as(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        parse_obj_as(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        parse_obj_as(
                            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 AsyncRawFilesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def show(
        self,
        account_id: Uuid,
        file_id: Uuid,
        *,
        include: typing.Optional[FileWithMediaLinksInclude] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[FileWithIncludesResponse]:
        """
        Show file details.
        <br><br>
        This endpoint has been added to `Current Version` of the API.
        <br><br>
        Please see https://developer.adobe.com/frameio/api/current/#tag/Files/operation/files.show.
        <br><br>
        Use the `include` query parameter to selectively include additional properties in the response.
        <br><br>
        Note: if you include `media_links.original` and the user does not have permission to download the file
        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 completed
        (i.e. the file's `status` is "uploaded" rather than "transcoded"), then the link will also be set to null in
        the response payload. In short, the client must handle null media links gracefully.
        <br><br>
        Rate Limits: 5 calls per 1 second(s) per account

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


        file_id : Uuid


        include : typing.Optional[FileWithMediaLinksInclude]


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

        Returns
        -------
        AsyncHttpResponse[FileWithIncludesResponse]
            OK
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/files/{jsonable_encoder(file_id)}",
            method="GET",
            params={
                "include": include,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileWithIncludesResponse,
                    parse_obj_as(
                        type_=FileWithIncludesResponse,  # 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,
                        parse_obj_as(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        parse_obj_as(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        parse_obj_as(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        parse_obj_as(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        parse_obj_as(
                            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,
        file_id: Uuid,
        *,
        data: FileUpdateParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[FileResponse]:
        """
        Update file details.
              <br><br>
              This endpoint has been added to `Current Version` of the API.
              <br><br>
              Please see https://developer.adobe.com/frameio/api/current/#tag/Files/operation/files.update.
              <br><br>
              Rate Limits: 100 calls per 1.00 minute(s) per account

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


        file_id : Uuid


        data : FileUpdateParamsData

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

        Returns
        -------
        AsyncHttpResponse[FileResponse]
            OK
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/files/{jsonable_encoder(file_id)}",
            method="PATCH",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FileUpdateParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileResponse,
                    parse_obj_as(
                        type_=FileResponse,  # 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,
                        parse_obj_as(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        parse_obj_as(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        parse_obj_as(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        parse_obj_as(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        parse_obj_as(
                            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,
        file_id: Uuid,
        *,
        data: typing.Optional[FileCopyParamsData] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[FileCopyResponse]:
        """
        Copy file.
            <br><br>
            This endpoint has been added to `Current Version` of the API.
            <br><br>
            Please see https://developer.adobe.com/frameio/api/current/#tag/Files/operation/files.copy.
            <br><br>
            Rate Limits: 100 calls per 1.00 minute(s) per account

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


        file_id : Uuid


        data : typing.Optional[FileCopyParamsData]

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

        Returns
        -------
        AsyncHttpResponse[FileCopyResponse]
            OK
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/files/{jsonable_encoder(file_id)}/copy",
            method="POST",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FileCopyParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileCopyResponse,
                    parse_obj_as(
                        type_=FileCopyResponse,  # 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,
                        parse_obj_as(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        parse_obj_as(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        parse_obj_as(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        parse_obj_as(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        parse_obj_as(
                            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,
        file_id: Uuid,
        *,
        data: FileMoveParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[FileResponse]:
        """
        Move file to a folder or version_stack.
              <br><br>
              This endpoint has been added to `Current Version` of the API.
              <br><br>
              Please see https://developer.adobe.com/frameio/api/current/#tag/Files/operation/files.move.
              <br><br>
              Rate Limits: 100 calls per 1.00 minute(s) per account

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


        file_id : Uuid


        data : FileMoveParamsData

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

        Returns
        -------
        AsyncHttpResponse[FileResponse]
            OK
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/files/{jsonable_encoder(file_id)}/move",
            method="PATCH",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FileMoveParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileResponse,
                    parse_obj_as(
                        type_=FileResponse,  # 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,
                        parse_obj_as(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        parse_obj_as(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        parse_obj_as(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        parse_obj_as(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        parse_obj_as(
                            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 show_file_upload_status(
        self, account_id: Uuid, file_id: Uuid, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[FileUploadStatusResponse]:
        """
        Show file upload status details.
              <br><br>
              This endpoint has been added to `Current Version` of the API.
              <br><br>
              Please see https://developer.adobe.com/frameio/api/current/#tag/Files/operation/files.show_file_upload_status.
              <br><br>
              Rate Limits: 5 calls per 1 second(s) per account

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


        file_id : Uuid


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

        Returns
        -------
        AsyncHttpResponse[FileUploadStatusResponse]
            OK
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/files/{jsonable_encoder(file_id)}/status",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileUploadStatusResponse,
                    parse_obj_as(
                        type_=FileUploadStatusResponse,  # 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,
                        parse_obj_as(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        parse_obj_as(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        parse_obj_as(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        parse_obj_as(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        parse_obj_as(
                            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 import_file(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        data: FileImportParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[FileResponse]:
        """
        Import a file from a storage location configured on the account. <br><br>Rate Limits: 5 calls per 1 second(s) per account

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


        folder_id : Uuid


        data : FileImportParamsData

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

        Returns
        -------
        AsyncHttpResponse[FileResponse]
            Accepted
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}/files/import",
            method="POST",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FileImportParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileResponse,
                    parse_obj_as(
                        type_=FileResponse,  # 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,
                        parse_obj_as(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        parse_obj_as(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        parse_obj_as(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        parse_obj_as(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        parse_obj_as(
                            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_remote_upload(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        data: FileCreateRemoteUploadParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[FileRemoteUploadResponse]:
        """
        Create new file under parent folder through remote upload.
              <br><br>
              This endpoint has been added to `Current Version` of the API.
              <br><br>
              Please see https://developer.adobe.com/frameio/api/current/#tag/Files/operation/files.create_remote_upload.
              <br><br>
              Rate Limits: 5 calls per 1 second(s) per account

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


        folder_id : Uuid


        data : FileCreateRemoteUploadParamsData

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

        Returns
        -------
        AsyncHttpResponse[FileRemoteUploadResponse]
            Accepted
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v4/accounts/{jsonable_encoder(account_id)}/folders/{jsonable_encoder(folder_id)}/files/remote_upload",
            method="POST",
            json={
                "data": convert_and_respect_annotation_metadata(
                    object_=data, annotation=FileCreateRemoteUploadParamsData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileRemoteUploadResponse,
                    parse_obj_as(
                        type_=FileRemoteUploadResponse,  # 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,
                        parse_obj_as(
                            type_=BadRequest,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Unauthorized,
                        parse_obj_as(
                            type_=Unauthorized,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        Forbidden,
                        parse_obj_as(
                            type_=Forbidden,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        NotFound,
                        parse_obj_as(
                            type_=NotFound,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 429:
                raise TooManyRequestsError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        TooManyRequests,
                        parse_obj_as(
                            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)
