# coding: utf-8

"""
    AI Hub API

    The AI Hub REST API. See https://docs.instabase.com/api-sdk/ for more details.

    The version of the OpenAPI document: 0.1
    Contact: support@instabase.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


import io
import warnings

from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Dict, List, Optional, Tuple, Union, Any

try:
    from typing import Annotated
except ImportError:
    from typing_extensions import Annotated

from pydantic import Field
from typing_extensions import Annotated
from pydantic import StrictBool, StrictInt, StrictStr, field_validator

from typing import List, Optional

from aihub.models.delete_run202_response import DeleteRun202Response
from aihub.models.list_runs200_response import ListRuns200Response
from aihub.models.results_response import ResultsResponse
from aihub.models.run import Run
from aihub.models.run_app_request import RunAppRequest
from aihub.models.run_deployment_request import RunDeploymentRequest

from aihub.api_client import ApiClient
from aihub.api_response import ApiResponse
from aihub.rest import RESTResponseType


class RunsApi:
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None) -> None:
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client


    @validate_call
    def delete_run(
        self,
        run_id: Annotated[StrictStr, Field(description="The run ID.")],
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        delete_db_data: Annotated[Optional[StrictBool], Field(description="Delete the run's database data.")] = None,
        delete_input: Annotated[Optional[StrictBool], Field(description="Delete the run's input files.")] = None,
        delete_output: Annotated[Optional[StrictBool], Field(description="Delete the run's output files.")] = None,
        delete_logs: Annotated[Optional[StrictBool], Field(description="Delete the run's logs.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> DeleteRun202Response:
        """Delete run

        Deletes a specified run and optionally its associated database data, input files, output files, and logs. This is an asynchronous operation that must be [checked for completion.](/api-sdk/api-reference/jobs/job-status)

        :param run_id: The run ID. (required)
        :type run_id: str
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param delete_db_data: Delete the run's database data.
        :type delete_db_data: bool
        :param delete_input: Delete the run's input files.
        :type delete_input: bool
        :param delete_output: Delete the run's output files.
        :type delete_output: bool
        :param delete_logs: Delete the run's logs.
        :type delete_logs: bool
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._delete_run_serialize(
            run_id=run_id,
            ib_context=ib_context,
            delete_db_data=delete_db_data,
            delete_input=delete_input,
            delete_output=delete_output,
            delete_logs=delete_logs,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '202': "DeleteRun202Response",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def delete_run_with_http_info(
        self,
        run_id: Annotated[StrictStr, Field(description="The run ID.")],
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        delete_db_data: Annotated[Optional[StrictBool], Field(description="Delete the run's database data.")] = None,
        delete_input: Annotated[Optional[StrictBool], Field(description="Delete the run's input files.")] = None,
        delete_output: Annotated[Optional[StrictBool], Field(description="Delete the run's output files.")] = None,
        delete_logs: Annotated[Optional[StrictBool], Field(description="Delete the run's logs.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[DeleteRun202Response]:
        """Delete run

        Deletes a specified run and optionally its associated database data, input files, output files, and logs. This is an asynchronous operation that must be [checked for completion.](/api-sdk/api-reference/jobs/job-status)

        :param run_id: The run ID. (required)
        :type run_id: str
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param delete_db_data: Delete the run's database data.
        :type delete_db_data: bool
        :param delete_input: Delete the run's input files.
        :type delete_input: bool
        :param delete_output: Delete the run's output files.
        :type delete_output: bool
        :param delete_logs: Delete the run's logs.
        :type delete_logs: bool
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._delete_run_serialize(
            run_id=run_id,
            ib_context=ib_context,
            delete_db_data=delete_db_data,
            delete_input=delete_input,
            delete_output=delete_output,
            delete_logs=delete_logs,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '202': "DeleteRun202Response",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def delete_run_without_preload_content(
        self,
        run_id: Annotated[StrictStr, Field(description="The run ID.")],
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        delete_db_data: Annotated[Optional[StrictBool], Field(description="Delete the run's database data.")] = None,
        delete_input: Annotated[Optional[StrictBool], Field(description="Delete the run's input files.")] = None,
        delete_output: Annotated[Optional[StrictBool], Field(description="Delete the run's output files.")] = None,
        delete_logs: Annotated[Optional[StrictBool], Field(description="Delete the run's logs.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Delete run

        Deletes a specified run and optionally its associated database data, input files, output files, and logs. This is an asynchronous operation that must be [checked for completion.](/api-sdk/api-reference/jobs/job-status)

        :param run_id: The run ID. (required)
        :type run_id: str
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param delete_db_data: Delete the run's database data.
        :type delete_db_data: bool
        :param delete_input: Delete the run's input files.
        :type delete_input: bool
        :param delete_output: Delete the run's output files.
        :type delete_output: bool
        :param delete_logs: Delete the run's logs.
        :type delete_logs: bool
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._delete_run_serialize(
            run_id=run_id,
            ib_context=ib_context,
            delete_db_data=delete_db_data,
            delete_input=delete_input,
            delete_output=delete_output,
            delete_logs=delete_logs,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '202': "DeleteRun202Response",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _delete_run_serialize(
        self,
        run_id,
        ib_context,
        delete_db_data,
        delete_input,
        delete_output,
        delete_logs,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> Tuple:

        _host = None

        _collection_formats: Dict[str, str] = {
            
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[str, str] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if run_id is not None:
            _path_params['run_id'] = run_id
        # process the query parameters
        if delete_db_data is not None:
            
            _query_params.append(('delete_db_data', delete_db_data))
            
        if delete_input is not None:
            
            _query_params.append(('delete_input', delete_input))
            
        if delete_output is not None:
            
            _query_params.append(('delete_output', delete_output))
            
        if delete_logs is not None:
            
            _query_params.append(('delete_logs', delete_logs))
            
        # process the header parameters
        if ib_context is not None:
            _header_params['IB-Context'] = ib_context
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            [
                'application/json'
            ]
        )


        # authentication setting
        _auth_settings: List[str] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='DELETE',
            resource_path='/v2/apps/runs/{run_id}',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def get_run_results(
        self,
        run_id: Annotated[StrictStr, Field(description="The run ID.")],
        include_review_results: Annotated[Optional[StrictBool], Field(description="Whether to include human review details in the results. When set to `true`, details such as review status and edits at the run or document level and at the extracted field level are included.  The following values are returned at the run or document level:  - `review_completed` - `files/documents/review_completed` - `files/documents/class_edit_history` - `files/documents/class_edit_history/timestamp` - `files/documents/class_edit_history/user_id` - `files/documents/class_edit_history/modifications` - `files/documents/class_edit_history/modifications/message`  The following values are returned at the extracted field level:  - `edit_history` - `files/edit_history/timestamp` - `files/edit_history/user_id` - `files/edit_history/modifications` - `files/edit_history/modifications/message`  See the response schema for details and descriptions.  <Note>The review process can include manually correcting values. This endpoint doesn't support returning the original and corrected values.</Note> ")] = None,
        include_confidence_scores: Annotated[Optional[StrictBool], Field(description="Whether to include confidence scores in the results. When set to `true`, classification confidence scores at the run or document level and extraction confidence scores at the extracted field level are included.  The following values are returned at the run or document level:  - `files/documents/classification_confidence/ocr`  The following values are returned at the extracted field level:  - `confidence/model`  See the response schema for details and descriptions. ")] = None,
        include_validation_results: Annotated[Optional[StrictBool], Field(description="Whether to include validation status in the results. When set to `true`, validation results at the run or document level and extracted field level are included.  The following values are returned at the run or document level:  - `files/validations/final_result_pass`  The following values are returned at the extracted field level:  - `validations/valid` - `validations/alerts`  See the response schema for details and descriptions. ")] = None,
        include_source_info: Annotated[Optional[StrictBool], Field(description="Whether to include source information in the results. When set to `true`, source details such as the image path of the generated image are included in the results.  The following values are returned at the run or document level:  - `files/documents/post_processed_paths`  The following values are returned at the extracted field level:  - `source_coordinates/top_x` - `source_coordinates/top_y` - `source_coordinates/bottom_x` - `source_coordinates/bottom_y` - `source_coordinates/page_number`  See the response schema for details and descriptions. ")] = None,
        file_offset: Annotated[Optional[StrictInt], Field(description="The initial file index to start returning results from. Defaults to `0`.")] = None,
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ResultsResponse:
        """Get run results

        Get the results of a completed run.  <Info>  This API operation might return field names that differ from those in the Build project.  The operation converts field names to valid Python variable names by:  * Allowing only letters, numbers, and underscores * Requiring names to start with a letter or underscore * Replacing invalid characters with underscores * Converting single underscores to double underscores  Examples: * `due date` → `due_date` * `driver's license` → `driver_s_license` * `3rd category` → `_3rd_category` * `secret_id` → `secret__id`  These changes apply only to field names in the API response. The field names in the Build project are not changed.  </Info> 

        :param run_id: The run ID. (required)
        :type run_id: str
        :param include_review_results: Whether to include human review details in the results. When set to `true`, details such as review status and edits at the run or document level and at the extracted field level are included.  The following values are returned at the run or document level:  - `review_completed` - `files/documents/review_completed` - `files/documents/class_edit_history` - `files/documents/class_edit_history/timestamp` - `files/documents/class_edit_history/user_id` - `files/documents/class_edit_history/modifications` - `files/documents/class_edit_history/modifications/message`  The following values are returned at the extracted field level:  - `edit_history` - `files/edit_history/timestamp` - `files/edit_history/user_id` - `files/edit_history/modifications` - `files/edit_history/modifications/message`  See the response schema for details and descriptions.  <Note>The review process can include manually correcting values. This endpoint doesn't support returning the original and corrected values.</Note> 
        :type include_review_results: bool
        :param include_confidence_scores: Whether to include confidence scores in the results. When set to `true`, classification confidence scores at the run or document level and extraction confidence scores at the extracted field level are included.  The following values are returned at the run or document level:  - `files/documents/classification_confidence/ocr`  The following values are returned at the extracted field level:  - `confidence/model`  See the response schema for details and descriptions. 
        :type include_confidence_scores: bool
        :param include_validation_results: Whether to include validation status in the results. When set to `true`, validation results at the run or document level and extracted field level are included.  The following values are returned at the run or document level:  - `files/validations/final_result_pass`  The following values are returned at the extracted field level:  - `validations/valid` - `validations/alerts`  See the response schema for details and descriptions. 
        :type include_validation_results: bool
        :param include_source_info: Whether to include source information in the results. When set to `true`, source details such as the image path of the generated image are included in the results.  The following values are returned at the run or document level:  - `files/documents/post_processed_paths`  The following values are returned at the extracted field level:  - `source_coordinates/top_x` - `source_coordinates/top_y` - `source_coordinates/bottom_x` - `source_coordinates/bottom_y` - `source_coordinates/page_number`  See the response schema for details and descriptions. 
        :type include_source_info: bool
        :param file_offset: The initial file index to start returning results from. Defaults to `0`.
        :type file_offset: int
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_run_results_serialize(
            run_id=run_id,
            include_review_results=include_review_results,
            include_confidence_scores=include_confidence_scores,
            include_validation_results=include_validation_results,
            include_source_info=include_source_info,
            file_offset=file_offset,
            ib_context=ib_context,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "ResultsResponse",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def get_run_results_with_http_info(
        self,
        run_id: Annotated[StrictStr, Field(description="The run ID.")],
        include_review_results: Annotated[Optional[StrictBool], Field(description="Whether to include human review details in the results. When set to `true`, details such as review status and edits at the run or document level and at the extracted field level are included.  The following values are returned at the run or document level:  - `review_completed` - `files/documents/review_completed` - `files/documents/class_edit_history` - `files/documents/class_edit_history/timestamp` - `files/documents/class_edit_history/user_id` - `files/documents/class_edit_history/modifications` - `files/documents/class_edit_history/modifications/message`  The following values are returned at the extracted field level:  - `edit_history` - `files/edit_history/timestamp` - `files/edit_history/user_id` - `files/edit_history/modifications` - `files/edit_history/modifications/message`  See the response schema for details and descriptions.  <Note>The review process can include manually correcting values. This endpoint doesn't support returning the original and corrected values.</Note> ")] = None,
        include_confidence_scores: Annotated[Optional[StrictBool], Field(description="Whether to include confidence scores in the results. When set to `true`, classification confidence scores at the run or document level and extraction confidence scores at the extracted field level are included.  The following values are returned at the run or document level:  - `files/documents/classification_confidence/ocr`  The following values are returned at the extracted field level:  - `confidence/model`  See the response schema for details and descriptions. ")] = None,
        include_validation_results: Annotated[Optional[StrictBool], Field(description="Whether to include validation status in the results. When set to `true`, validation results at the run or document level and extracted field level are included.  The following values are returned at the run or document level:  - `files/validations/final_result_pass`  The following values are returned at the extracted field level:  - `validations/valid` - `validations/alerts`  See the response schema for details and descriptions. ")] = None,
        include_source_info: Annotated[Optional[StrictBool], Field(description="Whether to include source information in the results. When set to `true`, source details such as the image path of the generated image are included in the results.  The following values are returned at the run or document level:  - `files/documents/post_processed_paths`  The following values are returned at the extracted field level:  - `source_coordinates/top_x` - `source_coordinates/top_y` - `source_coordinates/bottom_x` - `source_coordinates/bottom_y` - `source_coordinates/page_number`  See the response schema for details and descriptions. ")] = None,
        file_offset: Annotated[Optional[StrictInt], Field(description="The initial file index to start returning results from. Defaults to `0`.")] = None,
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[ResultsResponse]:
        """Get run results

        Get the results of a completed run.  <Info>  This API operation might return field names that differ from those in the Build project.  The operation converts field names to valid Python variable names by:  * Allowing only letters, numbers, and underscores * Requiring names to start with a letter or underscore * Replacing invalid characters with underscores * Converting single underscores to double underscores  Examples: * `due date` → `due_date` * `driver's license` → `driver_s_license` * `3rd category` → `_3rd_category` * `secret_id` → `secret__id`  These changes apply only to field names in the API response. The field names in the Build project are not changed.  </Info> 

        :param run_id: The run ID. (required)
        :type run_id: str
        :param include_review_results: Whether to include human review details in the results. When set to `true`, details such as review status and edits at the run or document level and at the extracted field level are included.  The following values are returned at the run or document level:  - `review_completed` - `files/documents/review_completed` - `files/documents/class_edit_history` - `files/documents/class_edit_history/timestamp` - `files/documents/class_edit_history/user_id` - `files/documents/class_edit_history/modifications` - `files/documents/class_edit_history/modifications/message`  The following values are returned at the extracted field level:  - `edit_history` - `files/edit_history/timestamp` - `files/edit_history/user_id` - `files/edit_history/modifications` - `files/edit_history/modifications/message`  See the response schema for details and descriptions.  <Note>The review process can include manually correcting values. This endpoint doesn't support returning the original and corrected values.</Note> 
        :type include_review_results: bool
        :param include_confidence_scores: Whether to include confidence scores in the results. When set to `true`, classification confidence scores at the run or document level and extraction confidence scores at the extracted field level are included.  The following values are returned at the run or document level:  - `files/documents/classification_confidence/ocr`  The following values are returned at the extracted field level:  - `confidence/model`  See the response schema for details and descriptions. 
        :type include_confidence_scores: bool
        :param include_validation_results: Whether to include validation status in the results. When set to `true`, validation results at the run or document level and extracted field level are included.  The following values are returned at the run or document level:  - `files/validations/final_result_pass`  The following values are returned at the extracted field level:  - `validations/valid` - `validations/alerts`  See the response schema for details and descriptions. 
        :type include_validation_results: bool
        :param include_source_info: Whether to include source information in the results. When set to `true`, source details such as the image path of the generated image are included in the results.  The following values are returned at the run or document level:  - `files/documents/post_processed_paths`  The following values are returned at the extracted field level:  - `source_coordinates/top_x` - `source_coordinates/top_y` - `source_coordinates/bottom_x` - `source_coordinates/bottom_y` - `source_coordinates/page_number`  See the response schema for details and descriptions. 
        :type include_source_info: bool
        :param file_offset: The initial file index to start returning results from. Defaults to `0`.
        :type file_offset: int
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_run_results_serialize(
            run_id=run_id,
            include_review_results=include_review_results,
            include_confidence_scores=include_confidence_scores,
            include_validation_results=include_validation_results,
            include_source_info=include_source_info,
            file_offset=file_offset,
            ib_context=ib_context,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "ResultsResponse",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def get_run_results_without_preload_content(
        self,
        run_id: Annotated[StrictStr, Field(description="The run ID.")],
        include_review_results: Annotated[Optional[StrictBool], Field(description="Whether to include human review details in the results. When set to `true`, details such as review status and edits at the run or document level and at the extracted field level are included.  The following values are returned at the run or document level:  - `review_completed` - `files/documents/review_completed` - `files/documents/class_edit_history` - `files/documents/class_edit_history/timestamp` - `files/documents/class_edit_history/user_id` - `files/documents/class_edit_history/modifications` - `files/documents/class_edit_history/modifications/message`  The following values are returned at the extracted field level:  - `edit_history` - `files/edit_history/timestamp` - `files/edit_history/user_id` - `files/edit_history/modifications` - `files/edit_history/modifications/message`  See the response schema for details and descriptions.  <Note>The review process can include manually correcting values. This endpoint doesn't support returning the original and corrected values.</Note> ")] = None,
        include_confidence_scores: Annotated[Optional[StrictBool], Field(description="Whether to include confidence scores in the results. When set to `true`, classification confidence scores at the run or document level and extraction confidence scores at the extracted field level are included.  The following values are returned at the run or document level:  - `files/documents/classification_confidence/ocr`  The following values are returned at the extracted field level:  - `confidence/model`  See the response schema for details and descriptions. ")] = None,
        include_validation_results: Annotated[Optional[StrictBool], Field(description="Whether to include validation status in the results. When set to `true`, validation results at the run or document level and extracted field level are included.  The following values are returned at the run or document level:  - `files/validations/final_result_pass`  The following values are returned at the extracted field level:  - `validations/valid` - `validations/alerts`  See the response schema for details and descriptions. ")] = None,
        include_source_info: Annotated[Optional[StrictBool], Field(description="Whether to include source information in the results. When set to `true`, source details such as the image path of the generated image are included in the results.  The following values are returned at the run or document level:  - `files/documents/post_processed_paths`  The following values are returned at the extracted field level:  - `source_coordinates/top_x` - `source_coordinates/top_y` - `source_coordinates/bottom_x` - `source_coordinates/bottom_y` - `source_coordinates/page_number`  See the response schema for details and descriptions. ")] = None,
        file_offset: Annotated[Optional[StrictInt], Field(description="The initial file index to start returning results from. Defaults to `0`.")] = None,
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Get run results

        Get the results of a completed run.  <Info>  This API operation might return field names that differ from those in the Build project.  The operation converts field names to valid Python variable names by:  * Allowing only letters, numbers, and underscores * Requiring names to start with a letter or underscore * Replacing invalid characters with underscores * Converting single underscores to double underscores  Examples: * `due date` → `due_date` * `driver's license` → `driver_s_license` * `3rd category` → `_3rd_category` * `secret_id` → `secret__id`  These changes apply only to field names in the API response. The field names in the Build project are not changed.  </Info> 

        :param run_id: The run ID. (required)
        :type run_id: str
        :param include_review_results: Whether to include human review details in the results. When set to `true`, details such as review status and edits at the run or document level and at the extracted field level are included.  The following values are returned at the run or document level:  - `review_completed` - `files/documents/review_completed` - `files/documents/class_edit_history` - `files/documents/class_edit_history/timestamp` - `files/documents/class_edit_history/user_id` - `files/documents/class_edit_history/modifications` - `files/documents/class_edit_history/modifications/message`  The following values are returned at the extracted field level:  - `edit_history` - `files/edit_history/timestamp` - `files/edit_history/user_id` - `files/edit_history/modifications` - `files/edit_history/modifications/message`  See the response schema for details and descriptions.  <Note>The review process can include manually correcting values. This endpoint doesn't support returning the original and corrected values.</Note> 
        :type include_review_results: bool
        :param include_confidence_scores: Whether to include confidence scores in the results. When set to `true`, classification confidence scores at the run or document level and extraction confidence scores at the extracted field level are included.  The following values are returned at the run or document level:  - `files/documents/classification_confidence/ocr`  The following values are returned at the extracted field level:  - `confidence/model`  See the response schema for details and descriptions. 
        :type include_confidence_scores: bool
        :param include_validation_results: Whether to include validation status in the results. When set to `true`, validation results at the run or document level and extracted field level are included.  The following values are returned at the run or document level:  - `files/validations/final_result_pass`  The following values are returned at the extracted field level:  - `validations/valid` - `validations/alerts`  See the response schema for details and descriptions. 
        :type include_validation_results: bool
        :param include_source_info: Whether to include source information in the results. When set to `true`, source details such as the image path of the generated image are included in the results.  The following values are returned at the run or document level:  - `files/documents/post_processed_paths`  The following values are returned at the extracted field level:  - `source_coordinates/top_x` - `source_coordinates/top_y` - `source_coordinates/bottom_x` - `source_coordinates/bottom_y` - `source_coordinates/page_number`  See the response schema for details and descriptions. 
        :type include_source_info: bool
        :param file_offset: The initial file index to start returning results from. Defaults to `0`.
        :type file_offset: int
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_run_results_serialize(
            run_id=run_id,
            include_review_results=include_review_results,
            include_confidence_scores=include_confidence_scores,
            include_validation_results=include_validation_results,
            include_source_info=include_source_info,
            file_offset=file_offset,
            ib_context=ib_context,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "ResultsResponse",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _get_run_results_serialize(
        self,
        run_id,
        include_review_results,
        include_confidence_scores,
        include_validation_results,
        include_source_info,
        file_offset,
        ib_context,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> Tuple:

        _host = None

        _collection_formats: Dict[str, str] = {
            
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[str, str] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if run_id is not None:
            _path_params['run_id'] = run_id
        # process the query parameters
        if include_review_results is not None:
            
            _query_params.append(('include_review_results', include_review_results))
            
        if include_confidence_scores is not None:
            
            _query_params.append(('include_confidence_scores', include_confidence_scores))
            
        if include_validation_results is not None:
            
            _query_params.append(('include_validation_results', include_validation_results))
            
        if include_source_info is not None:
            
            _query_params.append(('include_source_info', include_source_info))
            
        if file_offset is not None:
            
            _query_params.append(('file_offset', file_offset))
            
        # process the header parameters
        if ib_context is not None:
            _header_params['IB-Context'] = ib_context
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            [
                'application/json'
            ]
        )


        # authentication setting
        _auth_settings: List[str] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/v2/apps/runs/{run_id}/results',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def get_run_status(
        self,
        run_id: Annotated[StrictStr, Field(description="The run ID.")],
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> Run:
        """Get run status

        Get the status of a run.

        :param run_id: The run ID. (required)
        :type run_id: str
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_run_status_serialize(
            run_id=run_id,
            ib_context=ib_context,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "Run",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def get_run_status_with_http_info(
        self,
        run_id: Annotated[StrictStr, Field(description="The run ID.")],
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[Run]:
        """Get run status

        Get the status of a run.

        :param run_id: The run ID. (required)
        :type run_id: str
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_run_status_serialize(
            run_id=run_id,
            ib_context=ib_context,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "Run",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def get_run_status_without_preload_content(
        self,
        run_id: Annotated[StrictStr, Field(description="The run ID.")],
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Get run status

        Get the status of a run.

        :param run_id: The run ID. (required)
        :type run_id: str
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_run_status_serialize(
            run_id=run_id,
            ib_context=ib_context,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "Run",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _get_run_status_serialize(
        self,
        run_id,
        ib_context,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> Tuple:

        _host = None

        _collection_formats: Dict[str, str] = {
            
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[str, str] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if run_id is not None:
            _path_params['run_id'] = run_id
        # process the query parameters
        # process the header parameters
        if ib_context is not None:
            _header_params['IB-Context'] = ib_context
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            [
                'application/json'
            ]
        )


        # authentication setting
        _auth_settings: List[str] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/v2/apps/runs/{run_id}',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def list_runs(
        self,
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        app_id: Annotated[Optional[StrictStr], Field(description="Filter runs by app ID.")] = None,
        app_name: Annotated[Optional[StrictStr], Field(description="Filter runs by app name.")] = None,
        deployment_id: Annotated[Optional[StrictStr], Field(description="Filter runs by app deployment ID.")] = None,
        username: Annotated[Optional[StrictStr], Field(description="Filter runs initiated by the specified user (username).")] = None,
        run_id: Annotated[Optional[StrictStr], Field(description="Filter specific run by run ID.")] = None,
        status: Annotated[Optional[List[StrictStr]], Field(description="Filter jobs by status, such as COMPLETE, RUNNING, or FAILED.")] = None,
        output_repo: Annotated[Optional[List[StrictStr]], Field(description="Filter runs by the output repo.")] = None,
        from_timestamp: Annotated[Optional[StrictInt], Field(description="Filter runs starting from this timestamp. Defaults to one week before the current time.")] = None,
        to_timestamp: Annotated[Optional[StrictInt], Field(description="Filter runs up to this timestamp. Defaults to the current time.")] = None,
        limit: Annotated[Optional[StrictInt], Field(description="Number of results to return.")] = None,
        offset: Annotated[Optional[StrictInt], Field(description="Offset of the first result to return.")] = None,
        sort_by: Annotated[Optional[StrictStr], Field(description="Field to sort results by.")] = None,
        order: Annotated[Optional[StrictStr], Field(description="Order of sorting, such as ASCENDING or DESCENDING.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ListRuns200Response:
        """List runs

        Return a list of runs. Use query parameters to filter results.

        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param app_id: Filter runs by app ID.
        :type app_id: str
        :param app_name: Filter runs by app name.
        :type app_name: str
        :param deployment_id: Filter runs by app deployment ID.
        :type deployment_id: str
        :param username: Filter runs initiated by the specified user (username).
        :type username: str
        :param run_id: Filter specific run by run ID.
        :type run_id: str
        :param status: Filter jobs by status, such as COMPLETE, RUNNING, or FAILED.
        :type status: List[str]
        :param output_repo: Filter runs by the output repo.
        :type output_repo: List[str]
        :param from_timestamp: Filter runs starting from this timestamp. Defaults to one week before the current time.
        :type from_timestamp: int
        :param to_timestamp: Filter runs up to this timestamp. Defaults to the current time.
        :type to_timestamp: int
        :param limit: Number of results to return.
        :type limit: int
        :param offset: Offset of the first result to return.
        :type offset: int
        :param sort_by: Field to sort results by.
        :type sort_by: str
        :param order: Order of sorting, such as ASCENDING or DESCENDING.
        :type order: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._list_runs_serialize(
            ib_context=ib_context,
            app_id=app_id,
            app_name=app_name,
            deployment_id=deployment_id,
            username=username,
            run_id=run_id,
            status=status,
            output_repo=output_repo,
            from_timestamp=from_timestamp,
            to_timestamp=to_timestamp,
            limit=limit,
            offset=offset,
            sort_by=sort_by,
            order=order,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "ListRuns200Response",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def list_runs_with_http_info(
        self,
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        app_id: Annotated[Optional[StrictStr], Field(description="Filter runs by app ID.")] = None,
        app_name: Annotated[Optional[StrictStr], Field(description="Filter runs by app name.")] = None,
        deployment_id: Annotated[Optional[StrictStr], Field(description="Filter runs by app deployment ID.")] = None,
        username: Annotated[Optional[StrictStr], Field(description="Filter runs initiated by the specified user (username).")] = None,
        run_id: Annotated[Optional[StrictStr], Field(description="Filter specific run by run ID.")] = None,
        status: Annotated[Optional[List[StrictStr]], Field(description="Filter jobs by status, such as COMPLETE, RUNNING, or FAILED.")] = None,
        output_repo: Annotated[Optional[List[StrictStr]], Field(description="Filter runs by the output repo.")] = None,
        from_timestamp: Annotated[Optional[StrictInt], Field(description="Filter runs starting from this timestamp. Defaults to one week before the current time.")] = None,
        to_timestamp: Annotated[Optional[StrictInt], Field(description="Filter runs up to this timestamp. Defaults to the current time.")] = None,
        limit: Annotated[Optional[StrictInt], Field(description="Number of results to return.")] = None,
        offset: Annotated[Optional[StrictInt], Field(description="Offset of the first result to return.")] = None,
        sort_by: Annotated[Optional[StrictStr], Field(description="Field to sort results by.")] = None,
        order: Annotated[Optional[StrictStr], Field(description="Order of sorting, such as ASCENDING or DESCENDING.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[ListRuns200Response]:
        """List runs

        Return a list of runs. Use query parameters to filter results.

        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param app_id: Filter runs by app ID.
        :type app_id: str
        :param app_name: Filter runs by app name.
        :type app_name: str
        :param deployment_id: Filter runs by app deployment ID.
        :type deployment_id: str
        :param username: Filter runs initiated by the specified user (username).
        :type username: str
        :param run_id: Filter specific run by run ID.
        :type run_id: str
        :param status: Filter jobs by status, such as COMPLETE, RUNNING, or FAILED.
        :type status: List[str]
        :param output_repo: Filter runs by the output repo.
        :type output_repo: List[str]
        :param from_timestamp: Filter runs starting from this timestamp. Defaults to one week before the current time.
        :type from_timestamp: int
        :param to_timestamp: Filter runs up to this timestamp. Defaults to the current time.
        :type to_timestamp: int
        :param limit: Number of results to return.
        :type limit: int
        :param offset: Offset of the first result to return.
        :type offset: int
        :param sort_by: Field to sort results by.
        :type sort_by: str
        :param order: Order of sorting, such as ASCENDING or DESCENDING.
        :type order: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._list_runs_serialize(
            ib_context=ib_context,
            app_id=app_id,
            app_name=app_name,
            deployment_id=deployment_id,
            username=username,
            run_id=run_id,
            status=status,
            output_repo=output_repo,
            from_timestamp=from_timestamp,
            to_timestamp=to_timestamp,
            limit=limit,
            offset=offset,
            sort_by=sort_by,
            order=order,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "ListRuns200Response",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def list_runs_without_preload_content(
        self,
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        app_id: Annotated[Optional[StrictStr], Field(description="Filter runs by app ID.")] = None,
        app_name: Annotated[Optional[StrictStr], Field(description="Filter runs by app name.")] = None,
        deployment_id: Annotated[Optional[StrictStr], Field(description="Filter runs by app deployment ID.")] = None,
        username: Annotated[Optional[StrictStr], Field(description="Filter runs initiated by the specified user (username).")] = None,
        run_id: Annotated[Optional[StrictStr], Field(description="Filter specific run by run ID.")] = None,
        status: Annotated[Optional[List[StrictStr]], Field(description="Filter jobs by status, such as COMPLETE, RUNNING, or FAILED.")] = None,
        output_repo: Annotated[Optional[List[StrictStr]], Field(description="Filter runs by the output repo.")] = None,
        from_timestamp: Annotated[Optional[StrictInt], Field(description="Filter runs starting from this timestamp. Defaults to one week before the current time.")] = None,
        to_timestamp: Annotated[Optional[StrictInt], Field(description="Filter runs up to this timestamp. Defaults to the current time.")] = None,
        limit: Annotated[Optional[StrictInt], Field(description="Number of results to return.")] = None,
        offset: Annotated[Optional[StrictInt], Field(description="Offset of the first result to return.")] = None,
        sort_by: Annotated[Optional[StrictStr], Field(description="Field to sort results by.")] = None,
        order: Annotated[Optional[StrictStr], Field(description="Order of sorting, such as ASCENDING or DESCENDING.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """List runs

        Return a list of runs. Use query parameters to filter results.

        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param app_id: Filter runs by app ID.
        :type app_id: str
        :param app_name: Filter runs by app name.
        :type app_name: str
        :param deployment_id: Filter runs by app deployment ID.
        :type deployment_id: str
        :param username: Filter runs initiated by the specified user (username).
        :type username: str
        :param run_id: Filter specific run by run ID.
        :type run_id: str
        :param status: Filter jobs by status, such as COMPLETE, RUNNING, or FAILED.
        :type status: List[str]
        :param output_repo: Filter runs by the output repo.
        :type output_repo: List[str]
        :param from_timestamp: Filter runs starting from this timestamp. Defaults to one week before the current time.
        :type from_timestamp: int
        :param to_timestamp: Filter runs up to this timestamp. Defaults to the current time.
        :type to_timestamp: int
        :param limit: Number of results to return.
        :type limit: int
        :param offset: Offset of the first result to return.
        :type offset: int
        :param sort_by: Field to sort results by.
        :type sort_by: str
        :param order: Order of sorting, such as ASCENDING or DESCENDING.
        :type order: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._list_runs_serialize(
            ib_context=ib_context,
            app_id=app_id,
            app_name=app_name,
            deployment_id=deployment_id,
            username=username,
            run_id=run_id,
            status=status,
            output_repo=output_repo,
            from_timestamp=from_timestamp,
            to_timestamp=to_timestamp,
            limit=limit,
            offset=offset,
            sort_by=sort_by,
            order=order,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "ListRuns200Response",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _list_runs_serialize(
        self,
        ib_context,
        app_id,
        app_name,
        deployment_id,
        username,
        run_id,
        status,
        output_repo,
        from_timestamp,
        to_timestamp,
        limit,
        offset,
        sort_by,
        order,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> Tuple:

        _host = None

        _collection_formats: Dict[str, str] = {
            
            'status': 'multi',
            'output_repo': 'multi',
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[str, str] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        # process the query parameters
        if app_id is not None:
            
            _query_params.append(('app_id', app_id))
            
        if app_name is not None:
            
            _query_params.append(('app_name', app_name))
            
        if deployment_id is not None:
            
            _query_params.append(('deployment_id', deployment_id))
            
        if username is not None:
            
            _query_params.append(('username', username))
            
        if run_id is not None:
            
            _query_params.append(('run_id', run_id))
            
        if status is not None:
            
            _query_params.append(('status', status))
            
        if output_repo is not None:
            
            _query_params.append(('output_repo', output_repo))
            
        if from_timestamp is not None:
            
            _query_params.append(('from_timestamp', from_timestamp))
            
        if to_timestamp is not None:
            
            _query_params.append(('to_timestamp', to_timestamp))
            
        if limit is not None:
            
            _query_params.append(('limit', limit))
            
        if offset is not None:
            
            _query_params.append(('offset', offset))
            
        if sort_by is not None:
            
            _query_params.append(('sort_by', sort_by))
            
        if order is not None:
            
            _query_params.append(('order', order))
            
        # process the header parameters
        if ib_context is not None:
            _header_params['IB-Context'] = ib_context
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            [
                'application/json'
            ]
        )


        # authentication setting
        _auth_settings: List[str] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/v2/apps/runs',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def run_app(
        self,
        run_app_request: RunAppRequest,
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> Run:
        """Run app

        Run an app by its name or app ID. The input for the run can be a batch ID or an input file path.  To run deployments by API, use the [Run deployment endpoint.](/api-sdk/api-reference/runs/run-deployment/)  <Note>Any specified input or output is validated against the context set by the `IB-Context` header. For example, if the context is set to your community account, but the batch ID used as input for the run is stored in your organization, the call fails.</Note> 

        :param run_app_request: (required)
        :type run_app_request: RunAppRequest
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._run_app_serialize(
            run_app_request=run_app_request,
            ib_context=ib_context,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "Run",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def run_app_with_http_info(
        self,
        run_app_request: RunAppRequest,
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[Run]:
        """Run app

        Run an app by its name or app ID. The input for the run can be a batch ID or an input file path.  To run deployments by API, use the [Run deployment endpoint.](/api-sdk/api-reference/runs/run-deployment/)  <Note>Any specified input or output is validated against the context set by the `IB-Context` header. For example, if the context is set to your community account, but the batch ID used as input for the run is stored in your organization, the call fails.</Note> 

        :param run_app_request: (required)
        :type run_app_request: RunAppRequest
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._run_app_serialize(
            run_app_request=run_app_request,
            ib_context=ib_context,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "Run",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def run_app_without_preload_content(
        self,
        run_app_request: RunAppRequest,
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Run app

        Run an app by its name or app ID. The input for the run can be a batch ID or an input file path.  To run deployments by API, use the [Run deployment endpoint.](/api-sdk/api-reference/runs/run-deployment/)  <Note>Any specified input or output is validated against the context set by the `IB-Context` header. For example, if the context is set to your community account, but the batch ID used as input for the run is stored in your organization, the call fails.</Note> 

        :param run_app_request: (required)
        :type run_app_request: RunAppRequest
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._run_app_serialize(
            run_app_request=run_app_request,
            ib_context=ib_context,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "Run",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _run_app_serialize(
        self,
        run_app_request,
        ib_context,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> Tuple:

        _host = None

        _collection_formats: Dict[str, str] = {
            
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[str, str] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        # process the query parameters
        # process the header parameters
        if ib_context is not None:
            _header_params['IB-Context'] = ib_context
        # process the form parameters
        # process the body parameter
        if run_app_request is not None:
            _body_params = run_app_request


        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            [
                'application/json'
            ]
        )

        # set the HTTP header `Content-Type`
        if _content_type:
            _header_params['Content-Type'] = _content_type
        else:
            _default_content_type = (
                self.api_client.select_header_content_type(
                    [
                        'application/json'
                    ]
                )
            )
            if _default_content_type is not None:
                _header_params['Content-Type'] = _default_content_type

        # authentication setting
        _auth_settings: List[str] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='POST',
            resource_path='/v2/apps/runs',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def run_deployment(
        self,
        deployment_id: Annotated[StrictStr, Field(description="The deployment ID.  <Tip>You can find the deployment ID by opening the deployment in AI Hub and looking at the site URL, such as https<span>://</span>aihub.instabase.com/deployments/**01902d6f-bb35-74cb-bd27-c09b38bbf20a**/runs.</Tip> ")],
        run_deployment_request: RunDeploymentRequest,
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> Run:
        """Run deployment

        Run an AI Hub deployment by its deployment ID. The input for the run is specified using a batch ID or file path.  <Note>Any specified input or output is validated against the context set by the `IB-Context` header. For example, if the context is set to your community account, but the batch ID used as input for the run is stored in your organization, the call fails.</Note> 

        :param deployment_id: The deployment ID.  <Tip>You can find the deployment ID by opening the deployment in AI Hub and looking at the site URL, such as https<span>://</span>aihub.instabase.com/deployments/**01902d6f-bb35-74cb-bd27-c09b38bbf20a**/runs.</Tip>  (required)
        :type deployment_id: str
        :param run_deployment_request: (required)
        :type run_deployment_request: RunDeploymentRequest
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._run_deployment_serialize(
            deployment_id=deployment_id,
            run_deployment_request=run_deployment_request,
            ib_context=ib_context,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '202': "Run",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def run_deployment_with_http_info(
        self,
        deployment_id: Annotated[StrictStr, Field(description="The deployment ID.  <Tip>You can find the deployment ID by opening the deployment in AI Hub and looking at the site URL, such as https<span>://</span>aihub.instabase.com/deployments/**01902d6f-bb35-74cb-bd27-c09b38bbf20a**/runs.</Tip> ")],
        run_deployment_request: RunDeploymentRequest,
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[Run]:
        """Run deployment

        Run an AI Hub deployment by its deployment ID. The input for the run is specified using a batch ID or file path.  <Note>Any specified input or output is validated against the context set by the `IB-Context` header. For example, if the context is set to your community account, but the batch ID used as input for the run is stored in your organization, the call fails.</Note> 

        :param deployment_id: The deployment ID.  <Tip>You can find the deployment ID by opening the deployment in AI Hub and looking at the site URL, such as https<span>://</span>aihub.instabase.com/deployments/**01902d6f-bb35-74cb-bd27-c09b38bbf20a**/runs.</Tip>  (required)
        :type deployment_id: str
        :param run_deployment_request: (required)
        :type run_deployment_request: RunDeploymentRequest
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._run_deployment_serialize(
            deployment_id=deployment_id,
            run_deployment_request=run_deployment_request,
            ib_context=ib_context,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '202': "Run",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def run_deployment_without_preload_content(
        self,
        deployment_id: Annotated[StrictStr, Field(description="The deployment ID.  <Tip>You can find the deployment ID by opening the deployment in AI Hub and looking at the site URL, such as https<span>://</span>aihub.instabase.com/deployments/**01902d6f-bb35-74cb-bd27-c09b38bbf20a**/runs.</Tip> ")],
        run_deployment_request: RunDeploymentRequest,
        ib_context: Annotated[Optional[StrictStr], Field(description="Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Run deployment

        Run an AI Hub deployment by its deployment ID. The input for the run is specified using a batch ID or file path.  <Note>Any specified input or output is validated against the context set by the `IB-Context` header. For example, if the context is set to your community account, but the batch ID used as input for the run is stored in your organization, the call fails.</Note> 

        :param deployment_id: The deployment ID.  <Tip>You can find the deployment ID by opening the deployment in AI Hub and looking at the site URL, such as https<span>://</span>aihub.instabase.com/deployments/**01902d6f-bb35-74cb-bd27-c09b38bbf20a**/runs.</Tip>  (required)
        :type deployment_id: str
        :param run_deployment_request: (required)
        :type run_deployment_request: RunDeploymentRequest
        :param ib_context: Specify whether to use your community account or organization account to complete the request. To use your community account, define as your user ID. To use your organization account, define as your organization ID. If unspecified, defaults to community account context. See [Authorization and context identification](/api-sdk/authorization/#ib-context-header) for details.
        :type ib_context: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._run_deployment_serialize(
            deployment_id=deployment_id,
            run_deployment_request=run_deployment_request,
            ib_context=ib_context,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '202': "Run",
            
            
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _run_deployment_serialize(
        self,
        deployment_id,
        run_deployment_request,
        ib_context,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> Tuple:

        _host = None

        _collection_formats: Dict[str, str] = {
            
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[str, str] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if deployment_id is not None:
            _path_params['deployment-id'] = deployment_id
        # process the query parameters
        # process the header parameters
        if ib_context is not None:
            _header_params['IB-Context'] = ib_context
        # process the form parameters
        # process the body parameter
        if run_deployment_request is not None:
            _body_params = run_deployment_request


        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            [
                'application/json'
            ]
        )

        # set the HTTP header `Content-Type`
        if _content_type:
            _header_params['Content-Type'] = _content_type
        else:
            _default_content_type = (
                self.api_client.select_header_content_type(
                    [
                        'application/json'
                    ]
                )
            )
            if _default_content_type is not None:
                _header_params['Content-Type'] = _default_content_type

        # authentication setting
        _auth_settings: List[str] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='POST',
            resource_path='/v2/apps/deployments/{deployment-id}/runs',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )


