From 3c23e9229cd39380dee949589b76179457fe18a9 Mon Sep 17 00:00:00 2001 From: Nelson Kopliku Date: Tue, 24 May 2022 09:00:43 +0200 Subject: [PATCH] Add SapSystems Health overview OpenApi spec (#579) --- .../controllers/health_overview_controller.ex | 16 ++++++++++ lib/trento_web/openapi/schema/sap_system.ex | 29 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/lib/trento_web/controllers/health_overview_controller.ex b/lib/trento_web/controllers/health_overview_controller.ex index 844d6da22c..53e2481eb8 100644 --- a/lib/trento_web/controllers/health_overview_controller.ex +++ b/lib/trento_web/controllers/health_overview_controller.ex @@ -1,8 +1,24 @@ defmodule TrentoWeb.HealthOverviewController do use TrentoWeb, :controller + alias TrentoWeb.OpenApi.Schema + alias Trento.SapSystems.HealthSummaryService + use OpenApiSpex.ControllerSpecs + + operation(:overview, + summary: "Health overview of the disovered SAP Systems", + tags: ["Landscape"], + description: + "Provide an aggregated overview of the health of the discovered SAP Systems (and their components) on the target infrastructure", + responses: [ + ok: + {"An overview of the health of the disovered SAP Systems and their components", + "application/json", Schema.SAPSystem.HealthOverview} + ] + ) + @spec overview(Plug.Conn.t(), any) :: Plug.Conn.t() def overview(conn, _) do summary = HealthSummaryService.get_health_summary() diff --git a/lib/trento_web/openapi/schema/sap_system.ex b/lib/trento_web/openapi/schema/sap_system.ex index 1d18d4fd5a..3eab08abe2 100644 --- a/lib/trento_web/openapi/schema/sap_system.ex +++ b/lib/trento_web/openapi/schema/sap_system.ex @@ -67,4 +67,33 @@ defmodule TrentoWeb.OpenApi.Schema.SAPSystem do items: SAPSystemItem }) end + + defmodule SAPSystemHealthOverview do + @moduledoc false + + OpenApiSpex.schema(%{ + title: "SAPSystemHealthOverview", + description: "An overview of the health of a discovered SAP System and its components", + type: :object, + properties: %{ + id: %Schema{type: :string, description: "SAP System ID", format: :uuid}, + sid: %Schema{type: :string, description: "SID"}, + sapsystem_health: ResourceHealth, + database_health: ResourceHealth, + hosts_health: ResourceHealth, + clusters_health: ResourceHealth + } + }) + end + + defmodule HealthOverview do + @moduledoc false + + OpenApiSpex.schema(%{ + title: "HealthOverview", + description: "A list of health summaries for the discovered SAP Systems", + type: :array, + items: SAPSystemHealthOverview + }) + end end