"""
RCABench API

RCABench - A comprehensive root cause analysis benchmarking platform for microservices

The version of the OpenAPI document: 1.1.51
Contact: team@rcabench.com
Generated by OpenAPI Generator (https://rcabench.openapi-generator.tech)

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

from typing import Annotated, Any

from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call

from rcabench.openapi.api_client import ApiClient, RequestSerialized
from rcabench.openapi.api_response import ApiResponse
from rcabench.openapi.models.execution_state import ExecutionState
from rcabench.openapi.models.generic_response_array_label_item import GenericResponseArrayLabelItem
from rcabench.openapi.models.generic_response_execution_detail_resp import GenericResponseExecutionDetailResp
from rcabench.openapi.models.generic_response_list_execution_resp import GenericResponseListExecutionResp
from rcabench.openapi.models.generic_response_submit_execution_resp import GenericResponseSubmitExecutionResp
from rcabench.openapi.models.generic_response_upload_execution_result_resp import (
    GenericResponseUploadExecutionResultResp,
)
from rcabench.openapi.models.status_type import StatusType
from rcabench.openapi.models.submit_execution_req import SubmitExecutionReq
from rcabench.openapi.models.upload_detector_result_req import UploadDetectorResultReq
from rcabench.openapi.models.upload_granularity_result_req import UploadGranularityResultReq
from rcabench.openapi.rest import RESTResponse, RESTResponseType


class ExecutionsApi:
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://rcabench.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_execution_by_id(
        self,
        id: Annotated[StrictInt, Field(description="Execution ID")],
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> GenericResponseExecutionDetailResp:
        """Get execution by ID

        Get detailed information about a specific execution

        :param id: Execution ID (required)
        :type id: int
        :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_execution_by_id_serialize(
            id=id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseExecutionDetailResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "404": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data  # type: ignore

    @validate_call
    def get_execution_by_id_with_http_info(
        self,
        id: Annotated[StrictInt, Field(description="Execution ID")],
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[GenericResponseExecutionDetailResp]:
        """Get execution by ID

        Get detailed information about a specific execution

        :param id: Execution ID (required)
        :type id: int
        :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_execution_by_id_serialize(
            id=id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseExecutionDetailResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "404": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )  # type: ignore

    @validate_call
    def get_execution_by_id_without_preload_content(
        self,
        id: Annotated[StrictInt, Field(description="Execution ID")],
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Get execution by ID

        Get detailed information about a specific execution

        :param id: Execution ID (required)
        :type id: int
        :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_execution_by_id_serialize(
            id=id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseExecutionDetailResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "404": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        return response_data.response

    def _get_execution_by_id_serialize(
        self,
        id,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:
        _host = None

        _collection_formats: dict[str, str] = {}

        _path_params: dict[str, str] = {}
        _query_params: list[tuple[str, str]] = []
        _header_params: dict[str, str | None] = _headers or {}
        _form_params: list[tuple[str, str]] = []
        _files: dict[str, str | bytes | list[str] | list[bytes] | list[tuple[str, bytes]]] = {}
        _body_params: bytes | None = None

        # process the path parameters
        if id is not None:
            _path_params["id"] = id
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter

        # set the HTTP header `Accept`
        if "Accept" not in _header_params:
            _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="/api/v2/executions/{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_execution_labels(
        self,
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> GenericResponseArrayLabelItem:
        """List execution labels

        List all available label keys for executions

        :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_execution_labels_serialize(
            _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseArrayLabelItem",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data  # type: ignore

    @validate_call
    def list_execution_labels_with_http_info(
        self,
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[GenericResponseArrayLabelItem]:
        """List execution labels

        List all available label keys for executions

        :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_execution_labels_serialize(
            _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseArrayLabelItem",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )  # type: ignore

    @validate_call
    def list_execution_labels_without_preload_content(
        self,
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """List execution labels

        List all available label keys for executions

        :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_execution_labels_serialize(
            _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseArrayLabelItem",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        return response_data.response

    def _list_execution_labels_serialize(
        self,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:
        _host = None

        _collection_formats: dict[str, str] = {}

        _path_params: dict[str, str] = {}
        _query_params: list[tuple[str, str]] = []
        _header_params: dict[str, str | None] = _headers or {}
        _form_params: list[tuple[str, str]] = []
        _files: dict[str, str | bytes | list[str] | list[bytes] | list[tuple[str, bytes]]] = {}
        _body_params: bytes | None = None

        # process the path parameters
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter

        # set the HTTP header `Accept`
        if "Accept" not in _header_params:
            _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="/api/v2/executions/labels",
            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_executions(
        self,
        page: Annotated[StrictInt | None, Field(description="Page number")] = None,
        size: Annotated[StrictInt | None, Field(description="Page size")] = None,
        state: Annotated[ExecutionState | None, Field(description="Filter by execution state")] = None,
        status: Annotated[StatusType | None, Field(description="Filter by status")] = None,
        labels: Annotated[
            list[StrictStr] | None,
            Field(description="Filter by labels (array of key:value strings, e.g., 'type:test')"),
        ] = None,
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> GenericResponseListExecutionResp:
        """List executions

        Get a paginated list of executions with pagination and filtering

        :param page: Page number
        :type page: int
        :param size: Page size
        :type size: int
        :param state: Filter by execution state
        :type state: ExecutionState
        :param status: Filter by status
        :type status: StatusType
        :param labels: Filter by labels (array of key:value strings, e.g., 'type:test')
        :type labels: List[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_executions_serialize(
            page=page,
            size=size,
            state=state,
            status=status,
            labels=labels,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseListExecutionResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data  # type: ignore

    @validate_call
    def list_executions_with_http_info(
        self,
        page: Annotated[StrictInt | None, Field(description="Page number")] = None,
        size: Annotated[StrictInt | None, Field(description="Page size")] = None,
        state: Annotated[ExecutionState | None, Field(description="Filter by execution state")] = None,
        status: Annotated[StatusType | None, Field(description="Filter by status")] = None,
        labels: Annotated[
            list[StrictStr] | None,
            Field(description="Filter by labels (array of key:value strings, e.g., 'type:test')"),
        ] = None,
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[GenericResponseListExecutionResp]:
        """List executions

        Get a paginated list of executions with pagination and filtering

        :param page: Page number
        :type page: int
        :param size: Page size
        :type size: int
        :param state: Filter by execution state
        :type state: ExecutionState
        :param status: Filter by status
        :type status: StatusType
        :param labels: Filter by labels (array of key:value strings, e.g., 'type:test')
        :type labels: List[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_executions_serialize(
            page=page,
            size=size,
            state=state,
            status=status,
            labels=labels,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseListExecutionResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )  # type: ignore

    @validate_call
    def list_executions_without_preload_content(
        self,
        page: Annotated[StrictInt | None, Field(description="Page number")] = None,
        size: Annotated[StrictInt | None, Field(description="Page size")] = None,
        state: Annotated[ExecutionState | None, Field(description="Filter by execution state")] = None,
        status: Annotated[StatusType | None, Field(description="Filter by status")] = None,
        labels: Annotated[
            list[StrictStr] | None,
            Field(description="Filter by labels (array of key:value strings, e.g., 'type:test')"),
        ] = None,
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """List executions

        Get a paginated list of executions with pagination and filtering

        :param page: Page number
        :type page: int
        :param size: Page size
        :type size: int
        :param state: Filter by execution state
        :type state: ExecutionState
        :param status: Filter by status
        :type status: StatusType
        :param labels: Filter by labels (array of key:value strings, e.g., 'type:test')
        :type labels: List[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_executions_serialize(
            page=page,
            size=size,
            state=state,
            status=status,
            labels=labels,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseListExecutionResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        return response_data.response

    def _list_executions_serialize(
        self,
        page,
        size,
        state,
        status,
        labels,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:
        _host = None

        _collection_formats: dict[str, str] = {
            "labels": "csv",
        }

        _path_params: dict[str, str] = {}
        _query_params: list[tuple[str, str]] = []
        _header_params: dict[str, str | None] = _headers or {}
        _form_params: list[tuple[str, str]] = []
        _files: dict[str, str | bytes | list[str] | list[bytes] | list[tuple[str, bytes]]] = {}
        _body_params: bytes | None = None

        # process the path parameters
        # process the query parameters
        if page is not None:
            _query_params.append(("page", page))

        if size is not None:
            _query_params.append(("size", size))

        if state is not None:
            _query_params.append(("state", state.value))

        if status is not None:
            _query_params.append(("status", status.value))

        if labels is not None:
            _query_params.append(("labels", labels))

        # process the header parameters
        # process the form parameters
        # process the body parameter

        # set the HTTP header `Accept`
        if "Accept" not in _header_params:
            _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="/api/v2/executions",
            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_algorithm(
        self,
        request: Annotated[SubmitExecutionReq, Field(description="Algorithm execution request")],
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> GenericResponseSubmitExecutionResp:
        """Submit batch algorithm execution

        Submit multiple algorithm execution tasks in batch. Supports mixing datapack (v1 compatible) and dataset (v2 feature) executions.

        :param request: Algorithm execution request (required)
        :type request: SubmitExecutionReq
        :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_algorithm_serialize(
            request=request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseSubmitExecutionResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "404": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data  # type: ignore

    @validate_call
    def run_algorithm_with_http_info(
        self,
        request: Annotated[SubmitExecutionReq, Field(description="Algorithm execution request")],
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[GenericResponseSubmitExecutionResp]:
        """Submit batch algorithm execution

        Submit multiple algorithm execution tasks in batch. Supports mixing datapack (v1 compatible) and dataset (v2 feature) executions.

        :param request: Algorithm execution request (required)
        :type request: SubmitExecutionReq
        :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_algorithm_serialize(
            request=request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseSubmitExecutionResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "404": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )  # type: ignore

    @validate_call
    def run_algorithm_without_preload_content(
        self,
        request: Annotated[SubmitExecutionReq, Field(description="Algorithm execution request")],
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Submit batch algorithm execution

        Submit multiple algorithm execution tasks in batch. Supports mixing datapack (v1 compatible) and dataset (v2 feature) executions.

        :param request: Algorithm execution request (required)
        :type request: SubmitExecutionReq
        :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_algorithm_serialize(
            request=request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseSubmitExecutionResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "404": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        return response_data.response

    def _run_algorithm_serialize(
        self,
        request,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:
        _host = None

        _collection_formats: dict[str, str] = {}

        _path_params: dict[str, str] = {}
        _query_params: list[tuple[str, str]] = []
        _header_params: dict[str, str | None] = _headers or {}
        _form_params: list[tuple[str, str]] = []
        _files: dict[str, str | bytes | list[str] | list[bytes] | list[tuple[str, bytes]]] = {}
        _body_params: bytes | None = None

        # process the path parameters
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter
        if request is not None:
            _body_params = request

        # set the HTTP header `Accept`
        if "Accept" not in _header_params:
            _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="/api/v2/executions/execute",
            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 upload_detection_results(
        self,
        execution_id: Annotated[StrictInt, Field(description="Execution ID")],
        request: Annotated[UploadDetectorResultReq, Field(description="Detector results")],
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> GenericResponseUploadExecutionResultResp:
        """Upload detector results

        Upload detection results for detector algorithm via API instead of file collection

        :param execution_id: Execution ID (required)
        :type execution_id: int
        :param request: Detector results (required)
        :type request: UploadDetectorResultReq
        :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._upload_detection_results_serialize(
            execution_id=execution_id,
            request=request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseUploadExecutionResultResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "404": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data  # type: ignore

    @validate_call
    def upload_detection_results_with_http_info(
        self,
        execution_id: Annotated[StrictInt, Field(description="Execution ID")],
        request: Annotated[UploadDetectorResultReq, Field(description="Detector results")],
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[GenericResponseUploadExecutionResultResp]:
        """Upload detector results

        Upload detection results for detector algorithm via API instead of file collection

        :param execution_id: Execution ID (required)
        :type execution_id: int
        :param request: Detector results (required)
        :type request: UploadDetectorResultReq
        :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._upload_detection_results_serialize(
            execution_id=execution_id,
            request=request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseUploadExecutionResultResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "404": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )  # type: ignore

    @validate_call
    def upload_detection_results_without_preload_content(
        self,
        execution_id: Annotated[StrictInt, Field(description="Execution ID")],
        request: Annotated[UploadDetectorResultReq, Field(description="Detector results")],
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Upload detector results

        Upload detection results for detector algorithm via API instead of file collection

        :param execution_id: Execution ID (required)
        :type execution_id: int
        :param request: Detector results (required)
        :type request: UploadDetectorResultReq
        :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._upload_detection_results_serialize(
            execution_id=execution_id,
            request=request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseUploadExecutionResultResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "404": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        return response_data.response

    def _upload_detection_results_serialize(
        self,
        execution_id,
        request,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:
        _host = None

        _collection_formats: dict[str, str] = {}

        _path_params: dict[str, str] = {}
        _query_params: list[tuple[str, str]] = []
        _header_params: dict[str, str | None] = _headers or {}
        _form_params: list[tuple[str, str]] = []
        _files: dict[str, str | bytes | list[str] | list[bytes] | list[tuple[str, bytes]]] = {}
        _body_params: bytes | None = None

        # process the path parameters
        if execution_id is not None:
            _path_params["execution_id"] = execution_id
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter
        if request is not None:
            _body_params = request

        # set the HTTP header `Accept`
        if "Accept" not in _header_params:
            _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="/api/v2/executions/{execution_id}/detector_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 upload_localization_results(
        self,
        execution_id: Annotated[StrictInt, Field(description="Execution ID")],
        request: Annotated[UploadGranularityResultReq, Field(description="Granularity results")],
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> GenericResponseUploadExecutionResultResp:
        """Upload granularity results

        Upload granularity results for regular algorithms via API instead of file collection

        :param execution_id: Execution ID (required)
        :type execution_id: int
        :param request: Granularity results (required)
        :type request: UploadGranularityResultReq
        :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._upload_localization_results_serialize(
            execution_id=execution_id,
            request=request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseUploadExecutionResultResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "404": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data  # type: ignore

    @validate_call
    def upload_localization_results_with_http_info(
        self,
        execution_id: Annotated[StrictInt, Field(description="Execution ID")],
        request: Annotated[UploadGranularityResultReq, Field(description="Granularity results")],
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[GenericResponseUploadExecutionResultResp]:
        """Upload granularity results

        Upload granularity results for regular algorithms via API instead of file collection

        :param execution_id: Execution ID (required)
        :type execution_id: int
        :param request: Granularity results (required)
        :type request: UploadGranularityResultReq
        :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._upload_localization_results_serialize(
            execution_id=execution_id,
            request=request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseUploadExecutionResultResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "404": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )  # type: ignore

    @validate_call
    def upload_localization_results_without_preload_content(
        self,
        execution_id: Annotated[StrictInt, Field(description="Execution ID")],
        request: Annotated[UploadGranularityResultReq, Field(description="Granularity results")],
        _request_timeout: None
        | Annotated[StrictFloat, Field(gt=0)]
        | tuple[Annotated[StrictStr, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]] = None,
        _request_auth: dict[StrictStr, Any] | None = None,
        _content_type: StrictStr | None = None,
        _headers: dict[StrictStr, Any] | None = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Upload granularity results

        Upload granularity results for regular algorithms via API instead of file collection

        :param execution_id: Execution ID (required)
        :type execution_id: int
        :param request: Granularity results (required)
        :type request: UploadGranularityResultReq
        :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._upload_localization_results_serialize(
            execution_id=execution_id,
            request=request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: dict[str, str | None] = {
            "200": "GenericResponseUploadExecutionResultResp",
            "400": "GenericResponseAny",
            "401": "GenericResponseAny",
            "403": "GenericResponseAny",
            "404": "GenericResponseAny",
            "500": "GenericResponseAny",
        }
        response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

        assert response_data is not None and isinstance(response_data, RESTResponse), (
            "Response data must be of type RESTResponse"
        )
        return response_data.response

    def _upload_localization_results_serialize(
        self,
        execution_id,
        request,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:
        _host = None

        _collection_formats: dict[str, str] = {}

        _path_params: dict[str, str] = {}
        _query_params: list[tuple[str, str]] = []
        _header_params: dict[str, str | None] = _headers or {}
        _form_params: list[tuple[str, str]] = []
        _files: dict[str, str | bytes | list[str] | list[bytes] | list[tuple[str, bytes]]] = {}
        _body_params: bytes | None = None

        # process the path parameters
        if execution_id is not None:
            _path_params["execution_id"] = execution_id
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter
        if request is not None:
            _body_params = request

        # set the HTTP header `Accept`
        if "Accept" not in _header_params:
            _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="/api/v2/executions/{execution_id}/granularity_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,
        )
