You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
3.1 KiB
Python
86 lines
3.1 KiB
Python
from admin_app.core import AdminCredentialStrategy, AdminSecurityService
|
|
from admin_app.core.settings import AdminSettings
|
|
|
|
|
|
class SystemService:
|
|
def __init__(
|
|
self,
|
|
settings: AdminSettings,
|
|
security_service: AdminSecurityService | None = None,
|
|
):
|
|
self.settings = settings
|
|
self.security_service = security_service or AdminSecurityService(settings)
|
|
|
|
def build_root_payload(self) -> dict:
|
|
return {
|
|
"service": "orquestrador-admin",
|
|
"status": "ok",
|
|
"message": "Servico administrativo inicializado.",
|
|
"environment": self.settings.admin_environment,
|
|
}
|
|
|
|
def build_health_payload(self) -> dict:
|
|
return {
|
|
"service": "orquestrador-admin",
|
|
"status": "ok",
|
|
"version": self.settings.admin_version,
|
|
}
|
|
|
|
def build_system_info_payload(self) -> dict:
|
|
return {
|
|
"service": "orquestrador-admin",
|
|
"app_name": self.settings.admin_app_name,
|
|
"environment": self.settings.admin_environment,
|
|
"version": self.settings.admin_version,
|
|
"api_prefix": self.settings.admin_api_prefix,
|
|
"debug": self.settings.admin_debug,
|
|
}
|
|
|
|
def build_runtime_configuration_payload(self) -> dict:
|
|
return {
|
|
"application": {
|
|
"app_name": self.settings.admin_app_name,
|
|
"environment": self.settings.admin_environment,
|
|
"version": self.settings.admin_version,
|
|
"api_prefix": self.settings.admin_api_prefix,
|
|
"debug": self.settings.admin_debug,
|
|
},
|
|
"database": {
|
|
"host": self.settings.admin_db_host,
|
|
"port": self.settings.admin_db_port,
|
|
"name": self.settings.admin_db_name,
|
|
"cloud_sql_configured": bool(self.settings.admin_db_cloud_sql_connection_name),
|
|
},
|
|
}
|
|
|
|
def build_security_configuration_payload(self) -> AdminCredentialStrategy:
|
|
return self.security_service.build_credential_strategy()
|
|
|
|
def build_configuration_sources_payload(self) -> list[dict]:
|
|
return [
|
|
{
|
|
"key": "application",
|
|
"source": "env",
|
|
"mutable": False,
|
|
"description": "Metadados principais do admin runtime vindos de AdminSettings.",
|
|
},
|
|
{
|
|
"key": "database",
|
|
"source": "env",
|
|
"mutable": False,
|
|
"description": "Conexao administrativa derivada das variaveis de ambiente do servico.",
|
|
},
|
|
{
|
|
"key": "security",
|
|
"source": "env",
|
|
"mutable": False,
|
|
"description": "Politicas de senha, token e bootstrap lidas do runtime administrativo.",
|
|
},
|
|
{
|
|
"key": "panel_session",
|
|
"source": "runtime",
|
|
"mutable": False,
|
|
"description": "Cookies e sessao web do painel derivam da configuracao ativa do admin.",
|
|
},
|
|
]
|