# 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

from typing import Optional

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 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.

        :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.

        :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.

        :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 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
        )


