# coding: utf-8

"""
Root Signals API

Root Signals JSON API provides a way to access Root Signals using provisioned API token

The version of the OpenAPI document: 1.0.0 (latest)
Generated by OpenAPI Generator (https://openapi-generator.tech)

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

import warnings
from typing import Any, Dict, List, Optional, Tuple, Union

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

from root.generated.openapi_client.api_client import ApiClient, RequestSerialized
from root.generated.openapi_client.api_response import ApiResponse
from root.generated.openapi_client.models.execution_log_details import ExecutionLogDetails
from root.generated.openapi_client.models.paginated_execution_log_list_list import PaginatedExecutionLogListList
from root.generated.openapi_client.rest import RESTResponseType


class ExecutionLogsApi:
    """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 execution_logs_list(
        self,
        cursor: Annotated[Optional[StrictStr], Field(description="The pagination cursor value.")] = None,
        execution_type: Annotated[
            Optional[StrictStr], Field(description="* `runtime` - runtime * `test` - test")
        ] = None,
        include: Annotated[
            Optional[StrictStr],
            Field(
                description="Comma-separated list of additional fields to include in the response. Supports: llm_output, variables, evaluation_context"
            ),
        ] = None,
        max_score: Annotated[
            Optional[Union[StrictFloat, StrictInt]],
            Field(description="Filter logs by maximum score, inclusive, excludes null scores"),
        ] = None,
        min_score: Annotated[
            Optional[Union[StrictFloat, StrictInt]],
            Field(description="Filter logs by minimum score, inclusive, excludes null scores"),
        ] = None,
        ordering: Annotated[
            Optional[StrictStr], Field(description="Which field to use when ordering the results.")
        ] = None,
        page_size: Annotated[Optional[StrictInt], Field(description="Number of results to return per page.")] = None,
        search: Annotated[Optional[StrictStr], Field(description="Filter with skill name or id")] = None,
        skill_data_id: Optional[StrictStr] = None,
        tags: Annotated[Optional[StrictStr], Field(description="Filter logs by tag names (comma-separated)")] = None,
        unique_skills: Annotated[Optional[StrictBool], Field(description="Return only unique skills")] = 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,
    ) -> PaginatedExecutionLogListList:
        """execution_logs_list

        Get a list of execution logs. An execution log is created every time a skill or an evaluator is executed.

        :param cursor: The pagination cursor value.
        :type cursor: str
        :param execution_type: * `runtime` - runtime * `test` - test
        :type execution_type: str
        :param include: Comma-separated list of additional fields to include in the response. Supports: llm_output, variables, evaluation_context
        :type include: str
        :param max_score: Filter logs by maximum score, inclusive, excludes null scores
        :type max_score: float
        :param min_score: Filter logs by minimum score, inclusive, excludes null scores
        :type min_score: float
        :param ordering: Which field to use when ordering the results.
        :type ordering: str
        :param page_size: Number of results to return per page.
        :type page_size: int
        :param search: Filter with skill name or id
        :type search: str
        :param skill_data_id:
        :type skill_data_id: str
        :param tags: Filter logs by tag names (comma-separated)
        :type tags: str
        :param unique_skills: Return only unique skills
        :type unique_skills: bool
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._execution_logs_list_serialize(
            cursor=cursor,
            execution_type=execution_type,
            include=include,
            max_score=max_score,
            min_score=min_score,
            ordering=ordering,
            page_size=page_size,
            search=search,
            skill_data_id=skill_data_id,
            tags=tags,
            unique_skills=unique_skills,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "PaginatedExecutionLogListList",
        }
        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 execution_logs_list_with_http_info(
        self,
        cursor: Annotated[Optional[StrictStr], Field(description="The pagination cursor value.")] = None,
        execution_type: Annotated[
            Optional[StrictStr], Field(description="* `runtime` - runtime * `test` - test")
        ] = None,
        include: Annotated[
            Optional[StrictStr],
            Field(
                description="Comma-separated list of additional fields to include in the response. Supports: llm_output, variables, evaluation_context"
            ),
        ] = None,
        max_score: Annotated[
            Optional[Union[StrictFloat, StrictInt]],
            Field(description="Filter logs by maximum score, inclusive, excludes null scores"),
        ] = None,
        min_score: Annotated[
            Optional[Union[StrictFloat, StrictInt]],
            Field(description="Filter logs by minimum score, inclusive, excludes null scores"),
        ] = None,
        ordering: Annotated[
            Optional[StrictStr], Field(description="Which field to use when ordering the results.")
        ] = None,
        page_size: Annotated[Optional[StrictInt], Field(description="Number of results to return per page.")] = None,
        search: Annotated[Optional[StrictStr], Field(description="Filter with skill name or id")] = None,
        skill_data_id: Optional[StrictStr] = None,
        tags: Annotated[Optional[StrictStr], Field(description="Filter logs by tag names (comma-separated)")] = None,
        unique_skills: Annotated[Optional[StrictBool], Field(description="Return only unique skills")] = 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[PaginatedExecutionLogListList]:
        """execution_logs_list

        Get a list of execution logs. An execution log is created every time a skill or an evaluator is executed.

        :param cursor: The pagination cursor value.
        :type cursor: str
        :param execution_type: * `runtime` - runtime * `test` - test
        :type execution_type: str
        :param include: Comma-separated list of additional fields to include in the response. Supports: llm_output, variables, evaluation_context
        :type include: str
        :param max_score: Filter logs by maximum score, inclusive, excludes null scores
        :type max_score: float
        :param min_score: Filter logs by minimum score, inclusive, excludes null scores
        :type min_score: float
        :param ordering: Which field to use when ordering the results.
        :type ordering: str
        :param page_size: Number of results to return per page.
        :type page_size: int
        :param search: Filter with skill name or id
        :type search: str
        :param skill_data_id:
        :type skill_data_id: str
        :param tags: Filter logs by tag names (comma-separated)
        :type tags: str
        :param unique_skills: Return only unique skills
        :type unique_skills: bool
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._execution_logs_list_serialize(
            cursor=cursor,
            execution_type=execution_type,
            include=include,
            max_score=max_score,
            min_score=min_score,
            ordering=ordering,
            page_size=page_size,
            search=search,
            skill_data_id=skill_data_id,
            tags=tags,
            unique_skills=unique_skills,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "PaginatedExecutionLogListList",
        }
        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 execution_logs_list_without_preload_content(
        self,
        cursor: Annotated[Optional[StrictStr], Field(description="The pagination cursor value.")] = None,
        execution_type: Annotated[
            Optional[StrictStr], Field(description="* `runtime` - runtime * `test` - test")
        ] = None,
        include: Annotated[
            Optional[StrictStr],
            Field(
                description="Comma-separated list of additional fields to include in the response. Supports: llm_output, variables, evaluation_context"
            ),
        ] = None,
        max_score: Annotated[
            Optional[Union[StrictFloat, StrictInt]],
            Field(description="Filter logs by maximum score, inclusive, excludes null scores"),
        ] = None,
        min_score: Annotated[
            Optional[Union[StrictFloat, StrictInt]],
            Field(description="Filter logs by minimum score, inclusive, excludes null scores"),
        ] = None,
        ordering: Annotated[
            Optional[StrictStr], Field(description="Which field to use when ordering the results.")
        ] = None,
        page_size: Annotated[Optional[StrictInt], Field(description="Number of results to return per page.")] = None,
        search: Annotated[Optional[StrictStr], Field(description="Filter with skill name or id")] = None,
        skill_data_id: Optional[StrictStr] = None,
        tags: Annotated[Optional[StrictStr], Field(description="Filter logs by tag names (comma-separated)")] = None,
        unique_skills: Annotated[Optional[StrictBool], Field(description="Return only unique skills")] = 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:
        """execution_logs_list

        Get a list of execution logs. An execution log is created every time a skill or an evaluator is executed.

        :param cursor: The pagination cursor value.
        :type cursor: str
        :param execution_type: * `runtime` - runtime * `test` - test
        :type execution_type: str
        :param include: Comma-separated list of additional fields to include in the response. Supports: llm_output, variables, evaluation_context
        :type include: str
        :param max_score: Filter logs by maximum score, inclusive, excludes null scores
        :type max_score: float
        :param min_score: Filter logs by minimum score, inclusive, excludes null scores
        :type min_score: float
        :param ordering: Which field to use when ordering the results.
        :type ordering: str
        :param page_size: Number of results to return per page.
        :type page_size: int
        :param search: Filter with skill name or id
        :type search: str
        :param skill_data_id:
        :type skill_data_id: str
        :param tags: Filter logs by tag names (comma-separated)
        :type tags: str
        :param unique_skills: Return only unique skills
        :type unique_skills: bool
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._execution_logs_list_serialize(
            cursor=cursor,
            execution_type=execution_type,
            include=include,
            max_score=max_score,
            min_score=min_score,
            ordering=ordering,
            page_size=page_size,
            search=search,
            skill_data_id=skill_data_id,
            tags=tags,
            unique_skills=unique_skills,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

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

    def _execution_logs_list_serialize(
        self,
        cursor,
        execution_type,
        include,
        max_score,
        min_score,
        ordering,
        page_size,
        search,
        skill_data_id,
        tags,
        unique_skills,
        _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, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[str, str] = {}
        _body_params: Optional[bytes] = None

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

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

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

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

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

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

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

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

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

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

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

        # process the header parameters
        # 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] = ["publicApiKey"]

        return self.api_client.param_serialize(
            method="GET",
            resource_path="/v1/execution-logs/",
            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 execution_logs_retrieve(
        self,
        log_id: StrictStr,
        _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,
    ) -> ExecutionLogDetails:
        """execution_logs_retrieve

        Get the full details of a single execution log.

        :param log_id: (required)
        :type log_id: 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._execution_logs_retrieve_serialize(
            log_id=log_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "ExecutionLogDetails",
        }
        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 execution_logs_retrieve_with_http_info(
        self,
        log_id: StrictStr,
        _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[ExecutionLogDetails]:
        """execution_logs_retrieve

        Get the full details of a single execution log.

        :param log_id: (required)
        :type log_id: 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._execution_logs_retrieve_serialize(
            log_id=log_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "ExecutionLogDetails",
        }
        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 execution_logs_retrieve_without_preload_content(
        self,
        log_id: StrictStr,
        _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:
        """execution_logs_retrieve

        Get the full details of a single execution log.

        :param log_id: (required)
        :type log_id: 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._execution_logs_retrieve_serialize(
            log_id=log_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

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

    def _execution_logs_retrieve_serialize(
        self,
        log_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, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[str, str] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if log_id is not None:
            _path_params["log_id"] = log_id
        # process the query parameters
        # process the header parameters
        # 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] = ["publicApiKey"]

        return self.api_client.param_serialize(
            method="GET",
            resource_path="/v1/execution-logs/{log_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,
        )
