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

import typing
from ..core.client_wrapper import SyncClientWrapper
from ..core.request_options import RequestOptions
from ..core.jsonable_encoder import jsonable_encoder
from ..errors.unprocessable_entity_error import UnprocessableEntityError
from ..types.http_validation_error import HttpValidationError
from ..core.pydantic_utilities import parse_obj_as
from json.decoder import JSONDecodeError
from ..core.api_error import ApiError
from ..types.llama_parse_supported_file_extensions import LlamaParseSupportedFileExtensions
from ..types.parsing_job import ParsingJob
from ..types.parser_languages import ParserLanguages
from ..types.parsing_usage import ParsingUsage
from ..types.parsing_job_text_result import ParsingJobTextResult
from ..types.parsing_job_structured_result import ParsingJobStructuredResult
from ..types.parsing_job_markdown_result import ParsingJobMarkdownResult
from ..types.parsing_job_json_result import ParsingJobJsonResult
from ..types.parsing_history_item import ParsingHistoryItem
from ..types.presigned_url import PresignedUrl
from ..core.client_wrapper import AsyncClientWrapper

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


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

    def get_job_image_result(
        self, job_id: str, name: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Iterator[bytes]:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

        name : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Yields
        ------
        typing.Iterator[bytes]
            Successful Response
        """
        with self._client_wrapper.httpx_client.stream(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/image/{jsonable_encoder(name)}",
            method="GET",
            request_options=request_options,
        ) as _response:
            try:
                if 200 <= _response.status_code < 300:
                    _chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
                    for _chunk in _response.iter_bytes(chunk_size=_chunk_size):
                        yield _chunk
                    return
                _response.read()
                if _response.status_code == 422:
                    raise UnprocessableEntityError(
                        typing.cast(
                            HttpValidationError,
                            parse_obj_as(
                                type_=HttpValidationError,  # type: ignore
                                object_=_response.json(),
                            ),
                        )
                    )
                _response_json = _response.json()
            except JSONDecodeError:
                raise ApiError(status_code=_response.status_code, body=_response.text)
            raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_supported_file_extensions(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[LlamaParseSupportedFileExtensions]:
        """
        Get a list of supported file extensions

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

        Returns
        -------
        typing.List[LlamaParseSupportedFileExtensions]
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.get_supported_file_extensions()
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/v1/parsing/supported_file_extensions",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[LlamaParseSupportedFileExtensions],
                    parse_obj_as(
                        type_=typing.List[LlamaParseSupportedFileExtensions],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def screenshot(
        self,
        *,
        organization_id: typing.Optional[str] = None,
        project_id: typing.Optional[str] = None,
        file: typing.Optional[str] = OMIT,
        do_not_cache: typing.Optional[bool] = OMIT,
        http_proxy: typing.Optional[str] = OMIT,
        input_s_3_path: typing.Optional[str] = OMIT,
        input_s_3_region: typing.Optional[str] = OMIT,
        input_url: typing.Optional[str] = OMIT,
        invalidate_cache: typing.Optional[bool] = OMIT,
        max_pages: typing.Optional[int] = OMIT,
        output_s_3_path_prefix: typing.Optional[str] = OMIT,
        output_s_3_region: typing.Optional[str] = OMIT,
        target_pages: typing.Optional[str] = OMIT,
        webhook_url: typing.Optional[str] = OMIT,
        job_timeout_in_seconds: typing.Optional[float] = OMIT,
        job_timeout_extra_time_per_page_in_seconds: typing.Optional[float] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ParsingJob:
        """
        Parameters
        ----------
        organization_id : typing.Optional[str]

        project_id : typing.Optional[str]

        file : typing.Optional[str]

        do_not_cache : typing.Optional[bool]

        http_proxy : typing.Optional[str]

        input_s_3_path : typing.Optional[str]

        input_s_3_region : typing.Optional[str]

        input_url : typing.Optional[str]

        invalidate_cache : typing.Optional[bool]

        max_pages : typing.Optional[int]

        output_s_3_path_prefix : typing.Optional[str]

        output_s_3_region : typing.Optional[str]

        target_pages : typing.Optional[str]

        webhook_url : typing.Optional[str]

        job_timeout_in_seconds : typing.Optional[float]

        job_timeout_extra_time_per_page_in_seconds : typing.Optional[float]

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

        Returns
        -------
        ParsingJob
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.screenshot()
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/v1/parsing/screenshot",
            method="POST",
            params={
                "organization_id": organization_id,
                "project_id": project_id,
            },
            data={
                "file": file,
                "do_not_cache": do_not_cache,
                "http_proxy": http_proxy,
                "input_s3_path": input_s_3_path,
                "input_s3_region": input_s_3_region,
                "input_url": input_url,
                "invalidate_cache": invalidate_cache,
                "max_pages": max_pages,
                "output_s3_path_prefix": output_s_3_path_prefix,
                "output_s3_region": output_s_3_region,
                "target_pages": target_pages,
                "webhook_url": webhook_url,
                "job_timeout_in_seconds": job_timeout_in_seconds,
                "job_timeout_extra_time_per_page_in_seconds": job_timeout_extra_time_per_page_in_seconds,
            },
            files={},
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingJob,
                    parse_obj_as(
                        type_=ParsingJob,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def upload_file(
        self,
        *,
        organization_id: typing.Optional[str] = None,
        project_id: typing.Optional[str] = None,
        file: typing.Optional[str] = OMIT,
        annotate_links: typing.Optional[bool] = OMIT,
        auto_mode: typing.Optional[bool] = OMIT,
        auto_mode_trigger_on_image_in_page: typing.Optional[bool] = OMIT,
        auto_mode_trigger_on_table_in_page: typing.Optional[bool] = OMIT,
        auto_mode_trigger_on_text_in_page: typing.Optional[str] = OMIT,
        auto_mode_trigger_on_regexp_in_page: typing.Optional[str] = OMIT,
        azure_openai_api_version: typing.Optional[str] = OMIT,
        azure_openai_deployment_name: typing.Optional[str] = OMIT,
        azure_openai_endpoint: typing.Optional[str] = OMIT,
        azure_openai_key: typing.Optional[str] = OMIT,
        bbox_bottom: typing.Optional[float] = OMIT,
        bbox_left: typing.Optional[float] = OMIT,
        bbox_right: typing.Optional[float] = OMIT,
        bbox_top: typing.Optional[float] = OMIT,
        complemental_formatting_instruction: typing.Optional[str] = OMIT,
        content_guideline_instruction: typing.Optional[str] = OMIT,
        continuous_mode: typing.Optional[bool] = OMIT,
        disable_ocr: typing.Optional[bool] = OMIT,
        disable_reconstruction: typing.Optional[bool] = OMIT,
        disable_image_extraction: typing.Optional[bool] = OMIT,
        do_not_cache: typing.Optional[bool] = OMIT,
        do_not_unroll_columns: typing.Optional[bool] = OMIT,
        extract_charts: typing.Optional[bool] = OMIT,
        fast_mode: typing.Optional[bool] = OMIT,
        formatting_instruction: typing.Optional[str] = OMIT,
        guess_xlsx_sheet_name: typing.Optional[bool] = OMIT,
        html_make_all_elements_visible: typing.Optional[bool] = OMIT,
        html_remove_fixed_elements: typing.Optional[bool] = OMIT,
        html_remove_navigation_elements: typing.Optional[bool] = OMIT,
        http_proxy: typing.Optional[str] = OMIT,
        input_s_3_path: typing.Optional[str] = OMIT,
        input_s_3_region: typing.Optional[str] = OMIT,
        input_url: typing.Optional[str] = OMIT,
        invalidate_cache: typing.Optional[bool] = OMIT,
        is_formatting_instruction: typing.Optional[bool] = OMIT,
        language: typing.Optional[typing.List[ParserLanguages]] = OMIT,
        extract_layout: typing.Optional[bool] = OMIT,
        max_pages: typing.Optional[int] = OMIT,
        output_pdf_of_document: typing.Optional[bool] = OMIT,
        output_s_3_path_prefix: typing.Optional[str] = OMIT,
        output_s_3_region: typing.Optional[str] = OMIT,
        page_prefix: typing.Optional[str] = OMIT,
        page_separator: typing.Optional[str] = OMIT,
        page_suffix: typing.Optional[str] = OMIT,
        parsing_instruction: typing.Optional[str] = OMIT,
        premium_mode: typing.Optional[bool] = OMIT,
        skip_diagonal_text: typing.Optional[bool] = OMIT,
        spreadsheet_extract_sub_tables: typing.Optional[bool] = OMIT,
        structured_output: typing.Optional[bool] = OMIT,
        structured_output_json_schema: typing.Optional[str] = OMIT,
        structured_output_json_schema_name: typing.Optional[str] = OMIT,
        take_screenshot: typing.Optional[bool] = OMIT,
        target_pages: typing.Optional[str] = OMIT,
        use_vendor_multimodal_model: typing.Optional[bool] = OMIT,
        vendor_multimodal_api_key: typing.Optional[str] = OMIT,
        vendor_multimodal_model_name: typing.Optional[str] = OMIT,
        webhook_url: typing.Optional[str] = OMIT,
        bounding_box: typing.Optional[str] = OMIT,
        gpt_4_o_mode: typing.Optional[bool] = OMIT,
        gpt_4_o_api_key: typing.Optional[str] = OMIT,
        job_timeout_in_seconds: typing.Optional[float] = OMIT,
        job_timeout_extra_time_per_page_in_seconds: typing.Optional[float] = OMIT,
        strict_mode_image_extraction: typing.Optional[bool] = OMIT,
        strict_mode_image_ocr: typing.Optional[bool] = OMIT,
        strict_mode_reconstruction: typing.Optional[bool] = OMIT,
        strict_mode_buggy_font: typing.Optional[bool] = OMIT,
        ignore_document_elements_for_layout_detection: typing.Optional[bool] = OMIT,
        output_tables_as_html: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ParsingJob:
        """
        Upload a file to s3 and create a job. return a job id

        Parameters
        ----------
        organization_id : typing.Optional[str]

        project_id : typing.Optional[str]

        file : typing.Optional[str]

        annotate_links : typing.Optional[bool]

        auto_mode : typing.Optional[bool]

        auto_mode_trigger_on_image_in_page : typing.Optional[bool]

        auto_mode_trigger_on_table_in_page : typing.Optional[bool]

        auto_mode_trigger_on_text_in_page : typing.Optional[str]

        auto_mode_trigger_on_regexp_in_page : typing.Optional[str]

        azure_openai_api_version : typing.Optional[str]

        azure_openai_deployment_name : typing.Optional[str]

        azure_openai_endpoint : typing.Optional[str]

        azure_openai_key : typing.Optional[str]

        bbox_bottom : typing.Optional[float]

        bbox_left : typing.Optional[float]

        bbox_right : typing.Optional[float]

        bbox_top : typing.Optional[float]

        complemental_formatting_instruction : typing.Optional[str]

        content_guideline_instruction : typing.Optional[str]

        continuous_mode : typing.Optional[bool]

        disable_ocr : typing.Optional[bool]

        disable_reconstruction : typing.Optional[bool]

        disable_image_extraction : typing.Optional[bool]

        do_not_cache : typing.Optional[bool]

        do_not_unroll_columns : typing.Optional[bool]

        extract_charts : typing.Optional[bool]

        fast_mode : typing.Optional[bool]

        formatting_instruction : typing.Optional[str]

        guess_xlsx_sheet_name : typing.Optional[bool]

        html_make_all_elements_visible : typing.Optional[bool]

        html_remove_fixed_elements : typing.Optional[bool]

        html_remove_navigation_elements : typing.Optional[bool]

        http_proxy : typing.Optional[str]

        input_s_3_path : typing.Optional[str]

        input_s_3_region : typing.Optional[str]

        input_url : typing.Optional[str]

        invalidate_cache : typing.Optional[bool]

        is_formatting_instruction : typing.Optional[bool]

        language : typing.Optional[typing.List[ParserLanguages]]

        extract_layout : typing.Optional[bool]

        max_pages : typing.Optional[int]

        output_pdf_of_document : typing.Optional[bool]

        output_s_3_path_prefix : typing.Optional[str]

        output_s_3_region : typing.Optional[str]

        page_prefix : typing.Optional[str]

        page_separator : typing.Optional[str]

        page_suffix : typing.Optional[str]

        parsing_instruction : typing.Optional[str]

        premium_mode : typing.Optional[bool]

        skip_diagonal_text : typing.Optional[bool]

        spreadsheet_extract_sub_tables : typing.Optional[bool]

        structured_output : typing.Optional[bool]

        structured_output_json_schema : typing.Optional[str]

        structured_output_json_schema_name : typing.Optional[str]

        take_screenshot : typing.Optional[bool]

        target_pages : typing.Optional[str]

        use_vendor_multimodal_model : typing.Optional[bool]

        vendor_multimodal_api_key : typing.Optional[str]

        vendor_multimodal_model_name : typing.Optional[str]

        webhook_url : typing.Optional[str]

        bounding_box : typing.Optional[str]

        gpt_4_o_mode : typing.Optional[bool]

        gpt_4_o_api_key : typing.Optional[str]

        job_timeout_in_seconds : typing.Optional[float]

        job_timeout_extra_time_per_page_in_seconds : typing.Optional[float]

        strict_mode_image_extraction : typing.Optional[bool]

        strict_mode_image_ocr : typing.Optional[bool]

        strict_mode_reconstruction : typing.Optional[bool]

        strict_mode_buggy_font : typing.Optional[bool]

        ignore_document_elements_for_layout_detection : typing.Optional[bool]

        output_tables_as_html : typing.Optional[bool]

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

        Returns
        -------
        ParsingJob
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.upload_file()
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/v1/parsing/upload",
            method="POST",
            params={
                "organization_id": organization_id,
                "project_id": project_id,
            },
            data={
                "file": file,
                "annotate_links": annotate_links,
                "auto_mode": auto_mode,
                "auto_mode_trigger_on_image_in_page": auto_mode_trigger_on_image_in_page,
                "auto_mode_trigger_on_table_in_page": auto_mode_trigger_on_table_in_page,
                "auto_mode_trigger_on_text_in_page": auto_mode_trigger_on_text_in_page,
                "auto_mode_trigger_on_regexp_in_page": auto_mode_trigger_on_regexp_in_page,
                "azure_openai_api_version": azure_openai_api_version,
                "azure_openai_deployment_name": azure_openai_deployment_name,
                "azure_openai_endpoint": azure_openai_endpoint,
                "azure_openai_key": azure_openai_key,
                "bbox_bottom": bbox_bottom,
                "bbox_left": bbox_left,
                "bbox_right": bbox_right,
                "bbox_top": bbox_top,
                "complemental_formatting_instruction": complemental_formatting_instruction,
                "content_guideline_instruction": content_guideline_instruction,
                "continuous_mode": continuous_mode,
                "disable_ocr": disable_ocr,
                "disable_reconstruction": disable_reconstruction,
                "disable_image_extraction": disable_image_extraction,
                "do_not_cache": do_not_cache,
                "do_not_unroll_columns": do_not_unroll_columns,
                "extract_charts": extract_charts,
                "fast_mode": fast_mode,
                "formatting_instruction": formatting_instruction,
                "guess_xlsx_sheet_name": guess_xlsx_sheet_name,
                "html_make_all_elements_visible": html_make_all_elements_visible,
                "html_remove_fixed_elements": html_remove_fixed_elements,
                "html_remove_navigation_elements": html_remove_navigation_elements,
                "http_proxy": http_proxy,
                "input_s3_path": input_s_3_path,
                "input_s3_region": input_s_3_region,
                "input_url": input_url,
                "invalidate_cache": invalidate_cache,
                "is_formatting_instruction": is_formatting_instruction,
                "language": language,
                "extract_layout": extract_layout,
                "max_pages": max_pages,
                "output_pdf_of_document": output_pdf_of_document,
                "output_s3_path_prefix": output_s_3_path_prefix,
                "output_s3_region": output_s_3_region,
                "page_prefix": page_prefix,
                "page_separator": page_separator,
                "page_suffix": page_suffix,
                "parsing_instruction": parsing_instruction,
                "premium_mode": premium_mode,
                "skip_diagonal_text": skip_diagonal_text,
                "spreadsheet_extract_sub_tables": spreadsheet_extract_sub_tables,
                "structured_output": structured_output,
                "structured_output_json_schema": structured_output_json_schema,
                "structured_output_json_schema_name": structured_output_json_schema_name,
                "take_screenshot": take_screenshot,
                "target_pages": target_pages,
                "use_vendor_multimodal_model": use_vendor_multimodal_model,
                "vendor_multimodal_api_key": vendor_multimodal_api_key,
                "vendor_multimodal_model_name": vendor_multimodal_model_name,
                "webhook_url": webhook_url,
                "bounding_box": bounding_box,
                "gpt4o_mode": gpt_4_o_mode,
                "gpt4o_api_key": gpt_4_o_api_key,
                "job_timeout_in_seconds": job_timeout_in_seconds,
                "job_timeout_extra_time_per_page_in_seconds": job_timeout_extra_time_per_page_in_seconds,
                "strict_mode_image_extraction": strict_mode_image_extraction,
                "strict_mode_image_ocr": strict_mode_image_ocr,
                "strict_mode_reconstruction": strict_mode_reconstruction,
                "strict_mode_buggy_font": strict_mode_buggy_font,
                "ignore_document_elements_for_layout_detection": ignore_document_elements_for_layout_detection,
                "output_tables_as_HTML": output_tables_as_html,
            },
            files={},
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingJob,
                    parse_obj_as(
                        type_=ParsingJob,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def usage(
        self, *, organization_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> ParsingUsage:
        """
        DEPRECATED: use either /organizations/{organization_id}/usage or /projects/{project_id}/usage instead
        Get parsing usage for user

        Parameters
        ----------
        organization_id : typing.Optional[str]

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

        Returns
        -------
        ParsingUsage
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.usage()
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/v1/parsing/usage",
            method="GET",
            params={
                "organization_id": organization_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingUsage,
                    parse_obj_as(
                        type_=ParsingUsage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_job(self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ParsingJob:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

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

        Returns
        -------
        ParsingJob
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.get_job(
            job_id="job_id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingJob,
                    parse_obj_as(
                        type_=ParsingJob,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_parsing_job_details(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.get_parsing_job_details(
            job_id="job_id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/details",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.Optional[typing.Any],
                    parse_obj_as(
                        type_=typing.Optional[typing.Any],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_job_text_result(
        self,
        job_id: str,
        *,
        organization_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ParsingJobTextResult:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

        organization_id : typing.Optional[str]

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

        Returns
        -------
        ParsingJobTextResult
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.get_job_text_result(
            job_id="job_id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/text",
            method="GET",
            params={
                "organization_id": organization_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingJobTextResult,
                    parse_obj_as(
                        type_=ParsingJobTextResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_job_raw_text_result(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.get_job_raw_text_result(
            job_id="job_id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/raw/pdf",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.Optional[typing.Any],
                    parse_obj_as(
                        type_=typing.Optional[typing.Any],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_job_structured_result(
        self,
        job_id: str,
        *,
        organization_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ParsingJobStructuredResult:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

        organization_id : typing.Optional[str]

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

        Returns
        -------
        ParsingJobStructuredResult
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.get_job_structured_result(
            job_id="job_id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/structured",
            method="GET",
            params={
                "organization_id": organization_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingJobStructuredResult,
                    parse_obj_as(
                        type_=ParsingJobStructuredResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_job_raw_structured_result(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.get_job_raw_structured_result(
            job_id="job_id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/raw/structured",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.Optional[typing.Any],
                    parse_obj_as(
                        type_=typing.Optional[typing.Any],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_job_raw_xlsx_result(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.get_job_raw_xlsx_result(
            job_id="job_id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/raw/xlsx",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.Optional[typing.Any],
                    parse_obj_as(
                        type_=typing.Optional[typing.Any],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_job_result(
        self,
        job_id: str,
        *,
        organization_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ParsingJobMarkdownResult:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

        organization_id : typing.Optional[str]

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

        Returns
        -------
        ParsingJobMarkdownResult
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.get_job_result(
            job_id="job_id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/markdown",
            method="GET",
            params={
                "organization_id": organization_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingJobMarkdownResult,
                    parse_obj_as(
                        type_=ParsingJobMarkdownResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_job_raw_md_result(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.get_job_raw_md_result(
            job_id="job_id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/raw/markdown",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.Optional[typing.Any],
                    parse_obj_as(
                        type_=typing.Optional[typing.Any],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_job_json_result(
        self,
        job_id: str,
        *,
        organization_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ParsingJobJsonResult:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

        organization_id : typing.Optional[str]

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

        Returns
        -------
        ParsingJobJsonResult
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.get_job_json_result(
            job_id="job_id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/json",
            method="GET",
            params={
                "organization_id": organization_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingJobJsonResult,
                    parse_obj_as(
                        type_=ParsingJobJsonResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_job_json_raw_result(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.get_job_json_raw_result(
            job_id="job_id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/raw/json",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.Optional[typing.Any],
                    parse_obj_as(
                        type_=typing.Optional[typing.Any],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_parsing_history_result(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[ParsingHistoryItem]:
        """
        Get parsing history for user

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

        Returns
        -------
        typing.List[ParsingHistoryItem]
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.get_parsing_history_result()
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/v1/parsing/history",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[ParsingHistoryItem],
                    parse_obj_as(
                        type_=typing.List[ParsingHistoryItem],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def generate_presigned_url(
        self, job_id: str, filename: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PresignedUrl:
        """
        Generate a presigned URL for a job

        Parameters
        ----------
        job_id : str

        filename : str

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

        Returns
        -------
        PresignedUrl
            Successful Response

        Examples
        --------
        from llama_index import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.parsing.generate_presigned_url(
            job_id="job_id",
            filename="filename",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/read/{jsonable_encoder(filename)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    PresignedUrl,
                    parse_obj_as(
                        type_=PresignedUrl,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)


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

    async def get_job_image_result(
        self, job_id: str, name: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.AsyncIterator[bytes]:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

        name : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Yields
        ------
        typing.AsyncIterator[bytes]
            Successful Response
        """
        async with self._client_wrapper.httpx_client.stream(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/image/{jsonable_encoder(name)}",
            method="GET",
            request_options=request_options,
        ) as _response:
            try:
                if 200 <= _response.status_code < 300:
                    _chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
                    async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size):
                        yield _chunk
                    return
                await _response.aread()
                if _response.status_code == 422:
                    raise UnprocessableEntityError(
                        typing.cast(
                            HttpValidationError,
                            parse_obj_as(
                                type_=HttpValidationError,  # type: ignore
                                object_=_response.json(),
                            ),
                        )
                    )
                _response_json = _response.json()
            except JSONDecodeError:
                raise ApiError(status_code=_response.status_code, body=_response.text)
            raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_supported_file_extensions(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[LlamaParseSupportedFileExtensions]:
        """
        Get a list of supported file extensions

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

        Returns
        -------
        typing.List[LlamaParseSupportedFileExtensions]
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.get_supported_file_extensions()


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/v1/parsing/supported_file_extensions",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[LlamaParseSupportedFileExtensions],
                    parse_obj_as(
                        type_=typing.List[LlamaParseSupportedFileExtensions],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def screenshot(
        self,
        *,
        organization_id: typing.Optional[str] = None,
        project_id: typing.Optional[str] = None,
        file: typing.Optional[str] = OMIT,
        do_not_cache: typing.Optional[bool] = OMIT,
        http_proxy: typing.Optional[str] = OMIT,
        input_s_3_path: typing.Optional[str] = OMIT,
        input_s_3_region: typing.Optional[str] = OMIT,
        input_url: typing.Optional[str] = OMIT,
        invalidate_cache: typing.Optional[bool] = OMIT,
        max_pages: typing.Optional[int] = OMIT,
        output_s_3_path_prefix: typing.Optional[str] = OMIT,
        output_s_3_region: typing.Optional[str] = OMIT,
        target_pages: typing.Optional[str] = OMIT,
        webhook_url: typing.Optional[str] = OMIT,
        job_timeout_in_seconds: typing.Optional[float] = OMIT,
        job_timeout_extra_time_per_page_in_seconds: typing.Optional[float] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ParsingJob:
        """
        Parameters
        ----------
        organization_id : typing.Optional[str]

        project_id : typing.Optional[str]

        file : typing.Optional[str]

        do_not_cache : typing.Optional[bool]

        http_proxy : typing.Optional[str]

        input_s_3_path : typing.Optional[str]

        input_s_3_region : typing.Optional[str]

        input_url : typing.Optional[str]

        invalidate_cache : typing.Optional[bool]

        max_pages : typing.Optional[int]

        output_s_3_path_prefix : typing.Optional[str]

        output_s_3_region : typing.Optional[str]

        target_pages : typing.Optional[str]

        webhook_url : typing.Optional[str]

        job_timeout_in_seconds : typing.Optional[float]

        job_timeout_extra_time_per_page_in_seconds : typing.Optional[float]

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

        Returns
        -------
        ParsingJob
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.screenshot()


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/v1/parsing/screenshot",
            method="POST",
            params={
                "organization_id": organization_id,
                "project_id": project_id,
            },
            data={
                "file": file,
                "do_not_cache": do_not_cache,
                "http_proxy": http_proxy,
                "input_s3_path": input_s_3_path,
                "input_s3_region": input_s_3_region,
                "input_url": input_url,
                "invalidate_cache": invalidate_cache,
                "max_pages": max_pages,
                "output_s3_path_prefix": output_s_3_path_prefix,
                "output_s3_region": output_s_3_region,
                "target_pages": target_pages,
                "webhook_url": webhook_url,
                "job_timeout_in_seconds": job_timeout_in_seconds,
                "job_timeout_extra_time_per_page_in_seconds": job_timeout_extra_time_per_page_in_seconds,
            },
            files={},
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingJob,
                    parse_obj_as(
                        type_=ParsingJob,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def upload_file(
        self,
        *,
        organization_id: typing.Optional[str] = None,
        project_id: typing.Optional[str] = None,
        file: typing.Optional[str] = OMIT,
        annotate_links: typing.Optional[bool] = OMIT,
        auto_mode: typing.Optional[bool] = OMIT,
        auto_mode_trigger_on_image_in_page: typing.Optional[bool] = OMIT,
        auto_mode_trigger_on_table_in_page: typing.Optional[bool] = OMIT,
        auto_mode_trigger_on_text_in_page: typing.Optional[str] = OMIT,
        auto_mode_trigger_on_regexp_in_page: typing.Optional[str] = OMIT,
        azure_openai_api_version: typing.Optional[str] = OMIT,
        azure_openai_deployment_name: typing.Optional[str] = OMIT,
        azure_openai_endpoint: typing.Optional[str] = OMIT,
        azure_openai_key: typing.Optional[str] = OMIT,
        bbox_bottom: typing.Optional[float] = OMIT,
        bbox_left: typing.Optional[float] = OMIT,
        bbox_right: typing.Optional[float] = OMIT,
        bbox_top: typing.Optional[float] = OMIT,
        complemental_formatting_instruction: typing.Optional[str] = OMIT,
        content_guideline_instruction: typing.Optional[str] = OMIT,
        continuous_mode: typing.Optional[bool] = OMIT,
        disable_ocr: typing.Optional[bool] = OMIT,
        disable_reconstruction: typing.Optional[bool] = OMIT,
        disable_image_extraction: typing.Optional[bool] = OMIT,
        do_not_cache: typing.Optional[bool] = OMIT,
        do_not_unroll_columns: typing.Optional[bool] = OMIT,
        extract_charts: typing.Optional[bool] = OMIT,
        fast_mode: typing.Optional[bool] = OMIT,
        formatting_instruction: typing.Optional[str] = OMIT,
        guess_xlsx_sheet_name: typing.Optional[bool] = OMIT,
        html_make_all_elements_visible: typing.Optional[bool] = OMIT,
        html_remove_fixed_elements: typing.Optional[bool] = OMIT,
        html_remove_navigation_elements: typing.Optional[bool] = OMIT,
        http_proxy: typing.Optional[str] = OMIT,
        input_s_3_path: typing.Optional[str] = OMIT,
        input_s_3_region: typing.Optional[str] = OMIT,
        input_url: typing.Optional[str] = OMIT,
        invalidate_cache: typing.Optional[bool] = OMIT,
        is_formatting_instruction: typing.Optional[bool] = OMIT,
        language: typing.Optional[typing.List[ParserLanguages]] = OMIT,
        extract_layout: typing.Optional[bool] = OMIT,
        max_pages: typing.Optional[int] = OMIT,
        output_pdf_of_document: typing.Optional[bool] = OMIT,
        output_s_3_path_prefix: typing.Optional[str] = OMIT,
        output_s_3_region: typing.Optional[str] = OMIT,
        page_prefix: typing.Optional[str] = OMIT,
        page_separator: typing.Optional[str] = OMIT,
        page_suffix: typing.Optional[str] = OMIT,
        parsing_instruction: typing.Optional[str] = OMIT,
        premium_mode: typing.Optional[bool] = OMIT,
        skip_diagonal_text: typing.Optional[bool] = OMIT,
        spreadsheet_extract_sub_tables: typing.Optional[bool] = OMIT,
        structured_output: typing.Optional[bool] = OMIT,
        structured_output_json_schema: typing.Optional[str] = OMIT,
        structured_output_json_schema_name: typing.Optional[str] = OMIT,
        take_screenshot: typing.Optional[bool] = OMIT,
        target_pages: typing.Optional[str] = OMIT,
        use_vendor_multimodal_model: typing.Optional[bool] = OMIT,
        vendor_multimodal_api_key: typing.Optional[str] = OMIT,
        vendor_multimodal_model_name: typing.Optional[str] = OMIT,
        webhook_url: typing.Optional[str] = OMIT,
        bounding_box: typing.Optional[str] = OMIT,
        gpt_4_o_mode: typing.Optional[bool] = OMIT,
        gpt_4_o_api_key: typing.Optional[str] = OMIT,
        job_timeout_in_seconds: typing.Optional[float] = OMIT,
        job_timeout_extra_time_per_page_in_seconds: typing.Optional[float] = OMIT,
        strict_mode_image_extraction: typing.Optional[bool] = OMIT,
        strict_mode_image_ocr: typing.Optional[bool] = OMIT,
        strict_mode_reconstruction: typing.Optional[bool] = OMIT,
        strict_mode_buggy_font: typing.Optional[bool] = OMIT,
        ignore_document_elements_for_layout_detection: typing.Optional[bool] = OMIT,
        output_tables_as_html: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ParsingJob:
        """
        Upload a file to s3 and create a job. return a job id

        Parameters
        ----------
        organization_id : typing.Optional[str]

        project_id : typing.Optional[str]

        file : typing.Optional[str]

        annotate_links : typing.Optional[bool]

        auto_mode : typing.Optional[bool]

        auto_mode_trigger_on_image_in_page : typing.Optional[bool]

        auto_mode_trigger_on_table_in_page : typing.Optional[bool]

        auto_mode_trigger_on_text_in_page : typing.Optional[str]

        auto_mode_trigger_on_regexp_in_page : typing.Optional[str]

        azure_openai_api_version : typing.Optional[str]

        azure_openai_deployment_name : typing.Optional[str]

        azure_openai_endpoint : typing.Optional[str]

        azure_openai_key : typing.Optional[str]

        bbox_bottom : typing.Optional[float]

        bbox_left : typing.Optional[float]

        bbox_right : typing.Optional[float]

        bbox_top : typing.Optional[float]

        complemental_formatting_instruction : typing.Optional[str]

        content_guideline_instruction : typing.Optional[str]

        continuous_mode : typing.Optional[bool]

        disable_ocr : typing.Optional[bool]

        disable_reconstruction : typing.Optional[bool]

        disable_image_extraction : typing.Optional[bool]

        do_not_cache : typing.Optional[bool]

        do_not_unroll_columns : typing.Optional[bool]

        extract_charts : typing.Optional[bool]

        fast_mode : typing.Optional[bool]

        formatting_instruction : typing.Optional[str]

        guess_xlsx_sheet_name : typing.Optional[bool]

        html_make_all_elements_visible : typing.Optional[bool]

        html_remove_fixed_elements : typing.Optional[bool]

        html_remove_navigation_elements : typing.Optional[bool]

        http_proxy : typing.Optional[str]

        input_s_3_path : typing.Optional[str]

        input_s_3_region : typing.Optional[str]

        input_url : typing.Optional[str]

        invalidate_cache : typing.Optional[bool]

        is_formatting_instruction : typing.Optional[bool]

        language : typing.Optional[typing.List[ParserLanguages]]

        extract_layout : typing.Optional[bool]

        max_pages : typing.Optional[int]

        output_pdf_of_document : typing.Optional[bool]

        output_s_3_path_prefix : typing.Optional[str]

        output_s_3_region : typing.Optional[str]

        page_prefix : typing.Optional[str]

        page_separator : typing.Optional[str]

        page_suffix : typing.Optional[str]

        parsing_instruction : typing.Optional[str]

        premium_mode : typing.Optional[bool]

        skip_diagonal_text : typing.Optional[bool]

        spreadsheet_extract_sub_tables : typing.Optional[bool]

        structured_output : typing.Optional[bool]

        structured_output_json_schema : typing.Optional[str]

        structured_output_json_schema_name : typing.Optional[str]

        take_screenshot : typing.Optional[bool]

        target_pages : typing.Optional[str]

        use_vendor_multimodal_model : typing.Optional[bool]

        vendor_multimodal_api_key : typing.Optional[str]

        vendor_multimodal_model_name : typing.Optional[str]

        webhook_url : typing.Optional[str]

        bounding_box : typing.Optional[str]

        gpt_4_o_mode : typing.Optional[bool]

        gpt_4_o_api_key : typing.Optional[str]

        job_timeout_in_seconds : typing.Optional[float]

        job_timeout_extra_time_per_page_in_seconds : typing.Optional[float]

        strict_mode_image_extraction : typing.Optional[bool]

        strict_mode_image_ocr : typing.Optional[bool]

        strict_mode_reconstruction : typing.Optional[bool]

        strict_mode_buggy_font : typing.Optional[bool]

        ignore_document_elements_for_layout_detection : typing.Optional[bool]

        output_tables_as_html : typing.Optional[bool]

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

        Returns
        -------
        ParsingJob
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.upload_file()


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/v1/parsing/upload",
            method="POST",
            params={
                "organization_id": organization_id,
                "project_id": project_id,
            },
            data={
                "file": file,
                "annotate_links": annotate_links,
                "auto_mode": auto_mode,
                "auto_mode_trigger_on_image_in_page": auto_mode_trigger_on_image_in_page,
                "auto_mode_trigger_on_table_in_page": auto_mode_trigger_on_table_in_page,
                "auto_mode_trigger_on_text_in_page": auto_mode_trigger_on_text_in_page,
                "auto_mode_trigger_on_regexp_in_page": auto_mode_trigger_on_regexp_in_page,
                "azure_openai_api_version": azure_openai_api_version,
                "azure_openai_deployment_name": azure_openai_deployment_name,
                "azure_openai_endpoint": azure_openai_endpoint,
                "azure_openai_key": azure_openai_key,
                "bbox_bottom": bbox_bottom,
                "bbox_left": bbox_left,
                "bbox_right": bbox_right,
                "bbox_top": bbox_top,
                "complemental_formatting_instruction": complemental_formatting_instruction,
                "content_guideline_instruction": content_guideline_instruction,
                "continuous_mode": continuous_mode,
                "disable_ocr": disable_ocr,
                "disable_reconstruction": disable_reconstruction,
                "disable_image_extraction": disable_image_extraction,
                "do_not_cache": do_not_cache,
                "do_not_unroll_columns": do_not_unroll_columns,
                "extract_charts": extract_charts,
                "fast_mode": fast_mode,
                "formatting_instruction": formatting_instruction,
                "guess_xlsx_sheet_name": guess_xlsx_sheet_name,
                "html_make_all_elements_visible": html_make_all_elements_visible,
                "html_remove_fixed_elements": html_remove_fixed_elements,
                "html_remove_navigation_elements": html_remove_navigation_elements,
                "http_proxy": http_proxy,
                "input_s3_path": input_s_3_path,
                "input_s3_region": input_s_3_region,
                "input_url": input_url,
                "invalidate_cache": invalidate_cache,
                "is_formatting_instruction": is_formatting_instruction,
                "language": language,
                "extract_layout": extract_layout,
                "max_pages": max_pages,
                "output_pdf_of_document": output_pdf_of_document,
                "output_s3_path_prefix": output_s_3_path_prefix,
                "output_s3_region": output_s_3_region,
                "page_prefix": page_prefix,
                "page_separator": page_separator,
                "page_suffix": page_suffix,
                "parsing_instruction": parsing_instruction,
                "premium_mode": premium_mode,
                "skip_diagonal_text": skip_diagonal_text,
                "spreadsheet_extract_sub_tables": spreadsheet_extract_sub_tables,
                "structured_output": structured_output,
                "structured_output_json_schema": structured_output_json_schema,
                "structured_output_json_schema_name": structured_output_json_schema_name,
                "take_screenshot": take_screenshot,
                "target_pages": target_pages,
                "use_vendor_multimodal_model": use_vendor_multimodal_model,
                "vendor_multimodal_api_key": vendor_multimodal_api_key,
                "vendor_multimodal_model_name": vendor_multimodal_model_name,
                "webhook_url": webhook_url,
                "bounding_box": bounding_box,
                "gpt4o_mode": gpt_4_o_mode,
                "gpt4o_api_key": gpt_4_o_api_key,
                "job_timeout_in_seconds": job_timeout_in_seconds,
                "job_timeout_extra_time_per_page_in_seconds": job_timeout_extra_time_per_page_in_seconds,
                "strict_mode_image_extraction": strict_mode_image_extraction,
                "strict_mode_image_ocr": strict_mode_image_ocr,
                "strict_mode_reconstruction": strict_mode_reconstruction,
                "strict_mode_buggy_font": strict_mode_buggy_font,
                "ignore_document_elements_for_layout_detection": ignore_document_elements_for_layout_detection,
                "output_tables_as_HTML": output_tables_as_html,
            },
            files={},
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingJob,
                    parse_obj_as(
                        type_=ParsingJob,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def usage(
        self, *, organization_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> ParsingUsage:
        """
        DEPRECATED: use either /organizations/{organization_id}/usage or /projects/{project_id}/usage instead
        Get parsing usage for user

        Parameters
        ----------
        organization_id : typing.Optional[str]

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

        Returns
        -------
        ParsingUsage
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.usage()


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/v1/parsing/usage",
            method="GET",
            params={
                "organization_id": organization_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingUsage,
                    parse_obj_as(
                        type_=ParsingUsage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_job(self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ParsingJob:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

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

        Returns
        -------
        ParsingJob
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.get_job(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingJob,
                    parse_obj_as(
                        type_=ParsingJob,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_parsing_job_details(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.get_parsing_job_details(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/details",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.Optional[typing.Any],
                    parse_obj_as(
                        type_=typing.Optional[typing.Any],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_job_text_result(
        self,
        job_id: str,
        *,
        organization_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ParsingJobTextResult:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

        organization_id : typing.Optional[str]

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

        Returns
        -------
        ParsingJobTextResult
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.get_job_text_result(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/text",
            method="GET",
            params={
                "organization_id": organization_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingJobTextResult,
                    parse_obj_as(
                        type_=ParsingJobTextResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_job_raw_text_result(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.get_job_raw_text_result(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/raw/pdf",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.Optional[typing.Any],
                    parse_obj_as(
                        type_=typing.Optional[typing.Any],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_job_structured_result(
        self,
        job_id: str,
        *,
        organization_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ParsingJobStructuredResult:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

        organization_id : typing.Optional[str]

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

        Returns
        -------
        ParsingJobStructuredResult
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.get_job_structured_result(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/structured",
            method="GET",
            params={
                "organization_id": organization_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingJobStructuredResult,
                    parse_obj_as(
                        type_=ParsingJobStructuredResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_job_raw_structured_result(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.get_job_raw_structured_result(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/raw/structured",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.Optional[typing.Any],
                    parse_obj_as(
                        type_=typing.Optional[typing.Any],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_job_raw_xlsx_result(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.get_job_raw_xlsx_result(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/raw/xlsx",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.Optional[typing.Any],
                    parse_obj_as(
                        type_=typing.Optional[typing.Any],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_job_result(
        self,
        job_id: str,
        *,
        organization_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ParsingJobMarkdownResult:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

        organization_id : typing.Optional[str]

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

        Returns
        -------
        ParsingJobMarkdownResult
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.get_job_result(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/markdown",
            method="GET",
            params={
                "organization_id": organization_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingJobMarkdownResult,
                    parse_obj_as(
                        type_=ParsingJobMarkdownResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_job_raw_md_result(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.get_job_raw_md_result(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/raw/markdown",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.Optional[typing.Any],
                    parse_obj_as(
                        type_=typing.Optional[typing.Any],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_job_json_result(
        self,
        job_id: str,
        *,
        organization_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ParsingJobJsonResult:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

        organization_id : typing.Optional[str]

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

        Returns
        -------
        ParsingJobJsonResult
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.get_job_json_result(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/json",
            method="GET",
            params={
                "organization_id": organization_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ParsingJobJsonResult,
                    parse_obj_as(
                        type_=ParsingJobJsonResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_job_json_raw_result(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Get a job by id

        Parameters
        ----------
        job_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.get_job_json_raw_result(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/result/raw/json",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.Optional[typing.Any],
                    parse_obj_as(
                        type_=typing.Optional[typing.Any],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_parsing_history_result(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[ParsingHistoryItem]:
        """
        Get parsing history for user

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

        Returns
        -------
        typing.List[ParsingHistoryItem]
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.get_parsing_history_result()


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/v1/parsing/history",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[ParsingHistoryItem],
                    parse_obj_as(
                        type_=typing.List[ParsingHistoryItem],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def generate_presigned_url(
        self, job_id: str, filename: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PresignedUrl:
        """
        Generate a presigned URL for a job

        Parameters
        ----------
        job_id : str

        filename : str

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

        Returns
        -------
        PresignedUrl
            Successful Response

        Examples
        --------
        import asyncio

        from llama_index import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.parsing.generate_presigned_url(
                job_id="job_id",
                filename="filename",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/v1/parsing/job/{jsonable_encoder(job_id)}/read/{jsonable_encoder(filename)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    PresignedUrl,
                    parse_obj_as(
                        type_=PresignedUrl,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)
