"""
SystemMetaTag 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 .common_message_exception import CommonMessageException
from .passthru import Passthru
from .system_about import SystemAbout
from .system_health_check import SystemHealthCheck
from .system_o_auth_configuration import SystemOAuthConfiguration
from .system_route import SystemRoute
from .system_schema import SystemSchema

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


    def get_schema(self, name: str) -> SystemSchema:
        try:
            path_params = {}
            path_params["name"] = name

            query_params = {}

            query_struct_names = []

            url = self.parser.url("/system/schema/:name", 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 SystemSchema.model_validate_json(json_data=response.content)

            if response.status_code == 404:
                raise CommonMessageException(response.content)
            if response.status_code == 410:
                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_routes(self) -> SystemRoute:
        try:
            path_params = {}

            query_params = {}

            query_struct_names = []

            url = self.parser.url("/system/route", 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 SystemRoute.model_validate_json(json_data=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_o_auth_configuration(self) -> SystemOAuthConfiguration:
        try:
            path_params = {}

            query_params = {}

            query_struct_names = []

            url = self.parser.url("/system/oauth-authorization-server", 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 SystemOAuthConfiguration.model_validate_json(json_data=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_health(self) -> SystemHealthCheck:
        try:
            path_params = {}

            query_params = {}

            query_struct_names = []

            url = self.parser.url("/system/health", 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 SystemHealthCheck.model_validate_json(json_data=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_debug(self, payload: Passthru) -> Passthru:
        try:
            path_params = {}

            query_params = {}

            query_struct_names = []

            url = self.parser.url("/system/debug", path_params)

            headers = {}
            headers["Content-Type"] = "application/json"

            response = self.http_client.post(url, headers=headers, params=self.parser.query(query_params, query_struct_names), json=payload.model_dump(by_alias=True))

            if response.status_code >= 200 and response.status_code < 300:
                return Passthru.model_validate_json(json_data=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_about(self) -> SystemAbout:
        try:
            path_params = {}

            query_params = {}

            query_struct_names = []

            url = self.parser.url("/system/about", 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 SystemAbout.model_validate_json(json_data=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))


