"""
BackendStatisticTag automatically generated by SDKgen please do not edit this file manually
https://sdkgen.app
"""

import requests
import sdkgen
from requests import RequestException
from typing import List

from .backend_statistic_chart import BackendStatisticChart
from .backend_statistic_count import BackendStatisticCount
from .common_message_exception import CommonMessageException

class BackendStatisticTag(sdkgen.TagAbstract):
    def __init__(self, http_client: requests.Session, parser: sdkgen.Parser):
        super().__init__(http_client, parser)


    def get_used_points(self, start_index: int, count: int, search: str, from_: str, to: str, operation_id: int, app_id: int, user_id: int, ip: str, user_agent: str, method: str, path: str, header: str, body: str) -> BackendStatisticChart:
        try:
            path_params = {}

            query_params = {}
            query_params["startIndex"] = start_index
            query_params["count"] = count
            query_params["search"] = search
            query_params["from"] = from_
            query_params["to"] = to
            query_params["operationId"] = operation_id
            query_params["appId"] = app_id
            query_params["userId"] = user_id
            query_params["ip"] = ip
            query_params["userAgent"] = user_agent
            query_params["method"] = method
            query_params["path"] = path
            query_params["header"] = header
            query_params["body"] = body

            query_struct_names = []

            url = self.parser.url("/backend/statistic/used_points", path_params)

            headers = {}

            response = self.http_client.get(url, headers=headers, params=self.parser.query(query_params, query_struct_names))

            if response.status_code >= 200 and response.status_code < 300:
                return BackendStatisticChart.model_validate_json(json_data=response.content)

            if response.status_code == 401:
                raise CommonMessageException(response.content)
            if response.status_code == 500:
                raise CommonMessageException(response.content)

            raise sdkgen.UnknownStatusCodeException("The server returned an unknown status code")
        except RequestException as e:
            raise sdkgen.ClientException("An unknown error occurred: " + str(e))

    def get_time_per_operation(self, start_index: int, count: int, search: str, from_: str, to: str, operation_id: int, app_id: int, user_id: int, ip: str, user_agent: str, method: str, path: str, header: str, body: str) -> BackendStatisticChart:
        try:
            path_params = {}

            query_params = {}
            query_params["startIndex"] = start_index
            query_params["count"] = count
            query_params["search"] = search
            query_params["from"] = from_
            query_params["to"] = to
            query_params["operationId"] = operation_id
            query_params["appId"] = app_id
            query_params["userId"] = user_id
            query_params["ip"] = ip
            query_params["userAgent"] = user_agent
            query_params["method"] = method
            query_params["path"] = path
            query_params["header"] = header
            query_params["body"] = body

            query_struct_names = []

            url = self.parser.url("/backend/statistic/time_per_operation", path_params)

            headers = {}

            response = self.http_client.get(url, headers=headers, params=self.parser.query(query_params, query_struct_names))

            if response.status_code >= 200 and response.status_code < 300:
                return BackendStatisticChart.model_validate_json(json_data=response.content)

            if response.status_code == 401:
                raise CommonMessageException(response.content)
            if response.status_code == 500:
                raise CommonMessageException(response.content)

            raise sdkgen.UnknownStatusCodeException("The server returned an unknown status code")
        except RequestException as e:
            raise sdkgen.ClientException("An unknown error occurred: " + str(e))

    def get_time_average(self, start_index: int, count: int, search: str, from_: str, to: str, operation_id: int, app_id: int, user_id: int, ip: str, user_agent: str, method: str, path: str, header: str, body: str) -> BackendStatisticChart:
        try:
            path_params = {}

            query_params = {}
            query_params["startIndex"] = start_index
            query_params["count"] = count
            query_params["search"] = search
            query_params["from"] = from_
            query_params["to"] = to
            query_params["operationId"] = operation_id
            query_params["appId"] = app_id
            query_params["userId"] = user_id
            query_params["ip"] = ip
            query_params["userAgent"] = user_agent
            query_params["method"] = method
            query_params["path"] = path
            query_params["header"] = header
            query_params["body"] = body

            query_struct_names = []

            url = self.parser.url("/backend/statistic/time_average", path_params)

            headers = {}

            response = self.http_client.get(url, headers=headers, params=self.parser.query(query_params, query_struct_names))

            if response.status_code >= 200 and response.status_code < 300:
                return BackendStatisticChart.model_validate_json(json_data=response.content)

            if response.status_code == 401:
                raise CommonMessageException(response.content)
            if response.status_code == 500:
                raise CommonMessageException(response.content)

            raise sdkgen.UnknownStatusCodeException("The server returned an unknown status code")
        except RequestException as e:
            raise sdkgen.ClientException("An unknown error occurred: " + str(e))

    def get_test_coverage(self) -> BackendStatisticChart:
        try:
            path_params = {}

            query_params = {}

            query_struct_names = []

            url = self.parser.url("/backend/statistic/test_coverage", path_params)

            headers = {}

            response = self.http_client.get(url, headers=headers, params=self.parser.query(query_params, query_struct_names))

            if response.status_code >= 200 and response.status_code < 300:
                return BackendStatisticChart.model_validate_json(json_data=response.content)

            if response.status_code == 401:
                raise CommonMessageException(response.content)
            if response.status_code == 500:
                raise CommonMessageException(response.content)

            raise sdkgen.UnknownStatusCodeException("The server returned an unknown status code")
        except RequestException as e:
            raise sdkgen.ClientException("An unknown error occurred: " + str(e))

    def get_most_used_operations(self, start_index: int, count: int, search: str, from_: str, to: str, operation_id: int, app_id: int, user_id: int, ip: str, user_agent: str, method: str, path: str, header: str, body: str) -> BackendStatisticChart:
        try:
            path_params = {}

            query_params = {}
            query_params["startIndex"] = start_index
            query_params["count"] = count
            query_params["search"] = search
            query_params["from"] = from_
            query_params["to"] = to
            query_params["operationId"] = operation_id
            query_params["appId"] = app_id
            query_params["userId"] = user_id
            query_params["ip"] = ip
            query_params["userAgent"] = user_agent
            query_params["method"] = method
            query_params["path"] = path
            query_params["header"] = header
            query_params["body"] = body

            query_struct_names = []

            url = self.parser.url("/backend/statistic/most_used_operations", path_params)

            headers = {}

            response = self.http_client.get(url, headers=headers, params=self.parser.query(query_params, query_struct_names))

            if response.status_code >= 200 and response.status_code < 300:
                return BackendStatisticChart.model_validate_json(json_data=response.content)

            if response.status_code == 401:
                raise CommonMessageException(response.content)
            if response.status_code == 500:
                raise CommonMessageException(response.content)

            raise sdkgen.UnknownStatusCodeException("The server returned an unknown status code")
        except RequestException as e:
            raise sdkgen.ClientException("An unknown error occurred: " + str(e))

    def get_most_used_apps(self, start_index: int, count: int, search: str, from_: str, to: str, operation_id: int, app_id: int, user_id: int, ip: str, user_agent: str, method: str, path: str, header: str, body: str) -> BackendStatisticChart:
        try:
            path_params = {}

            query_params = {}
            query_params["startIndex"] = start_index
            query_params["count"] = count
            query_params["search"] = search
            query_params["from"] = from_
            query_params["to"] = to
            query_params["operationId"] = operation_id
            query_params["appId"] = app_id
            query_params["userId"] = user_id
            query_params["ip"] = ip
            query_params["userAgent"] = user_agent
            query_params["method"] = method
            query_params["path"] = path
            query_params["header"] = header
            query_params["body"] = body

            query_struct_names = []

            url = self.parser.url("/backend/statistic/most_used_apps", path_params)

            headers = {}

            response = self.http_client.get(url, headers=headers, params=self.parser.query(query_params, query_struct_names))

            if response.status_code >= 200 and response.status_code < 300:
                return BackendStatisticChart.model_validate_json(json_data=response.content)

            if response.status_code == 401:
                raise CommonMessageException(response.content)
            if response.status_code == 500:
                raise CommonMessageException(response.content)

            raise sdkgen.UnknownStatusCodeException("The server returned an unknown status code")
        except RequestException as e:
            raise sdkgen.ClientException("An unknown error occurred: " + str(e))

    def get_issued_tokens(self, start_index: int, count: int, search: str, from_: str, to: str, operation_id: int, app_id: int, user_id: int, ip: str, user_agent: str, method: str, path: str, header: str, body: str) -> BackendStatisticChart:
        try:
            path_params = {}

            query_params = {}
            query_params["startIndex"] = start_index
            query_params["count"] = count
            query_params["search"] = search
            query_params["from"] = from_
            query_params["to"] = to
            query_params["operationId"] = operation_id
            query_params["appId"] = app_id
            query_params["userId"] = user_id
            query_params["ip"] = ip
            query_params["userAgent"] = user_agent
            query_params["method"] = method
            query_params["path"] = path
            query_params["header"] = header
            query_params["body"] = body

            query_struct_names = []

            url = self.parser.url("/backend/statistic/issued_tokens", path_params)

            headers = {}

            response = self.http_client.get(url, headers=headers, params=self.parser.query(query_params, query_struct_names))

            if response.status_code >= 200 and response.status_code < 300:
                return BackendStatisticChart.model_validate_json(json_data=response.content)

            if response.status_code == 401:
                raise CommonMessageException(response.content)
            if response.status_code == 500:
                raise CommonMessageException(response.content)

            raise sdkgen.UnknownStatusCodeException("The server returned an unknown status code")
        except RequestException as e:
            raise sdkgen.ClientException("An unknown error occurred: " + str(e))

    def get_incoming_transactions(self, start_index: int, count: int, search: str, from_: str, to: str, operation_id: int, app_id: int, user_id: int, ip: str, user_agent: str, method: str, path: str, header: str, body: str) -> BackendStatisticChart:
        try:
            path_params = {}

            query_params = {}
            query_params["startIndex"] = start_index
            query_params["count"] = count
            query_params["search"] = search
            query_params["from"] = from_
            query_params["to"] = to
            query_params["operationId"] = operation_id
            query_params["appId"] = app_id
            query_params["userId"] = user_id
            query_params["ip"] = ip
            query_params["userAgent"] = user_agent
            query_params["method"] = method
            query_params["path"] = path
            query_params["header"] = header
            query_params["body"] = body

            query_struct_names = []

            url = self.parser.url("/backend/statistic/incoming_transactions", path_params)

            headers = {}

            response = self.http_client.get(url, headers=headers, params=self.parser.query(query_params, query_struct_names))

            if response.status_code >= 200 and response.status_code < 300:
                return BackendStatisticChart.model_validate_json(json_data=response.content)

            if response.status_code == 401:
                raise CommonMessageException(response.content)
            if response.status_code == 500:
                raise CommonMessageException(response.content)

            raise sdkgen.UnknownStatusCodeException("The server returned an unknown status code")
        except RequestException as e:
            raise sdkgen.ClientException("An unknown error occurred: " + str(e))

    def get_incoming_requests(self, start_index: int, count: int, search: str, from_: str, to: str, operation_id: int, app_id: int, user_id: int, ip: str, user_agent: str, method: str, path: str, header: str, body: str) -> BackendStatisticChart:
        try:
            path_params = {}

            query_params = {}
            query_params["startIndex"] = start_index
            query_params["count"] = count
            query_params["search"] = search
            query_params["from"] = from_
            query_params["to"] = to
            query_params["operationId"] = operation_id
            query_params["appId"] = app_id
            query_params["userId"] = user_id
            query_params["ip"] = ip
            query_params["userAgent"] = user_agent
            query_params["method"] = method
            query_params["path"] = path
            query_params["header"] = header
            query_params["body"] = body

            query_struct_names = []

            url = self.parser.url("/backend/statistic/incoming_requests", path_params)

            headers = {}

            response = self.http_client.get(url, headers=headers, params=self.parser.query(query_params, query_struct_names))

            if response.status_code >= 200 and response.status_code < 300:
                return BackendStatisticChart.model_validate_json(json_data=response.content)

            if response.status_code == 401:
                raise CommonMessageException(response.content)
            if response.status_code == 500:
                raise CommonMessageException(response.content)

            raise sdkgen.UnknownStatusCodeException("The server returned an unknown status code")
        except RequestException as e:
            raise sdkgen.ClientException("An unknown error occurred: " + str(e))

    def get_errors_per_operation(self, start_index: int, count: int, search: str, from_: str, to: str, operation_id: int, app_id: int, user_id: int, ip: str, user_agent: str, method: str, path: str, header: str, body: str) -> BackendStatisticChart:
        try:
            path_params = {}

            query_params = {}
            query_params["startIndex"] = start_index
            query_params["count"] = count
            query_params["search"] = search
            query_params["from"] = from_
            query_params["to"] = to
            query_params["operationId"] = operation_id
            query_params["appId"] = app_id
            query_params["userId"] = user_id
            query_params["ip"] = ip
            query_params["userAgent"] = user_agent
            query_params["method"] = method
            query_params["path"] = path
            query_params["header"] = header
            query_params["body"] = body

            query_struct_names = []

            url = self.parser.url("/backend/statistic/errors_per_operation", path_params)

            headers = {}

            response = self.http_client.get(url, headers=headers, params=self.parser.query(query_params, query_struct_names))

            if response.status_code >= 200 and response.status_code < 300:
                return BackendStatisticChart.model_validate_json(json_data=response.content)

            if response.status_code == 401:
                raise CommonMessageException(response.content)
            if response.status_code == 500:
                raise CommonMessageException(response.content)

            raise sdkgen.UnknownStatusCodeException("The server returned an unknown status code")
        except RequestException as e:
            raise sdkgen.ClientException("An unknown error occurred: " + str(e))

    def get_count_requests(self, start_index: int, count: int, search: str, from_: str, to: str, operation_id: int, app_id: int, user_id: int, ip: str, user_agent: str, method: str, path: str, header: str, body: str) -> BackendStatisticCount:
        try:
            path_params = {}

            query_params = {}
            query_params["startIndex"] = start_index
            query_params["count"] = count
            query_params["search"] = search
            query_params["from"] = from_
            query_params["to"] = to
            query_params["operationId"] = operation_id
            query_params["appId"] = app_id
            query_params["userId"] = user_id
            query_params["ip"] = ip
            query_params["userAgent"] = user_agent
            query_params["method"] = method
            query_params["path"] = path
            query_params["header"] = header
            query_params["body"] = body

            query_struct_names = []

            url = self.parser.url("/backend/statistic/count_requests", path_params)

            headers = {}

            response = self.http_client.get(url, headers=headers, params=self.parser.query(query_params, query_struct_names))

            if response.status_code >= 200 and response.status_code < 300:
                return BackendStatisticCount.model_validate_json(json_data=response.content)

            if response.status_code == 401:
                raise CommonMessageException(response.content)
            if response.status_code == 500:
                raise CommonMessageException(response.content)

            raise sdkgen.UnknownStatusCodeException("The server returned an unknown status code")
        except RequestException as e:
            raise sdkgen.ClientException("An unknown error occurred: " + str(e))


