-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Extracted SupportedProviders schema * Added Cluster and Checks openapi schema * Wired openapi operation to cluster controller * Polish schema imports
- Loading branch information
1 parent
ec5f9d3
commit 2a660e1
Showing
5 changed files
with
301 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
defmodule TrentoWeb.OpenApi.Schema.Checks do | ||
@moduledoc false | ||
|
||
require OpenApiSpex | ||
alias OpenApiSpex.Schema | ||
|
||
defmodule HostChecksExecution do | ||
@moduledoc false | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "HostChecksExecution", | ||
description: | ||
"Representation of the current check execution on a specific host of a Cluster", | ||
type: :object, | ||
properties: %{ | ||
cluster_id: %Schema{ | ||
type: :string, | ||
description: "Cluster's ID", | ||
format: :uuid | ||
}, | ||
host_id: %Schema{ | ||
type: :string, | ||
description: "Host's ID", | ||
format: :uuid | ||
}, | ||
reachable: %Schema{ | ||
type: :boolean, | ||
description: | ||
"Indicates whether the host was reachable during the connection to run selected checks" | ||
}, | ||
msg: %Schema{ | ||
type: :string, | ||
description: "A message" | ||
} | ||
} | ||
}) | ||
end | ||
|
||
defmodule CheckResult do | ||
@moduledoc false | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "CheckResult", | ||
description: "Representation of the result of a spectific check on a host of a cluster", | ||
type: :object, | ||
properties: %{ | ||
cluster_id: %Schema{ | ||
type: :string, | ||
description: "Cluster's ID", | ||
format: :uuid | ||
}, | ||
host_id: %Schema{ | ||
type: :string, | ||
description: "Host's ID", | ||
format: :uuid | ||
}, | ||
check_id: %Schema{ | ||
type: :string, | ||
description: "The identifier of the executed check" | ||
}, | ||
result: %Schema{ | ||
type: :string, | ||
description: "Host's last heartbeat status", | ||
enum: [:passing, :warning, :critical, :skipped, :unknown] | ||
}, | ||
inserted_at: %Schema{ | ||
type: :string, | ||
description: "Creation timestamp", | ||
format: :"date-time" | ||
}, | ||
updated_at: %Schema{type: :string, description: "Update timestamp", format: :"date-time"} | ||
} | ||
}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
defmodule TrentoWeb.OpenApi.Schema.Cluster do | ||
@moduledoc false | ||
|
||
require OpenApiSpex | ||
alias OpenApiSpex.Schema | ||
|
||
alias TrentoWeb.OpenApi.Schema.{Checks, Provider, Tag} | ||
|
||
defmodule ClusterResource do | ||
@moduledoc false | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "ClusterResource", | ||
description: "A Cluster Resource", | ||
type: :object, | ||
properties: %{ | ||
id: %Schema{type: :string}, | ||
type: %Schema{type: :string}, | ||
role: %Schema{type: :string}, | ||
status: %Schema{type: :string}, | ||
fail_count: %Schema{type: :integer} | ||
} | ||
}) | ||
end | ||
|
||
defmodule ClusterNode do | ||
@moduledoc false | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "ClusterNode", | ||
description: "A Cluster Node", | ||
type: :object, | ||
properties: %{ | ||
name: %Schema{type: :string}, | ||
site: %Schema{type: :string}, | ||
hana_status: %Schema{type: :string}, | ||
attributes: %Schema{ | ||
title: "ClusterNodeAttributes", | ||
type: :array, | ||
items: %Schema{type: :string} | ||
}, | ||
virtual_ip: %Schema{type: :string}, | ||
resources: %Schema{ | ||
title: "ClustrNodeResources", | ||
description: "A list of ClusterNodes", | ||
type: :array, | ||
items: ClusterResource | ||
} | ||
} | ||
}) | ||
end | ||
|
||
defmodule SbdDevice do | ||
@moduledoc false | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "SbdDevice", | ||
description: "Ad Sbd Device", | ||
type: :object, | ||
properties: %{ | ||
device: %Schema{type: :string}, | ||
status: %Schema{type: :string} | ||
} | ||
}) | ||
end | ||
|
||
defmodule HanaClusterDetails do | ||
@moduledoc false | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "HanaClusterDetails", | ||
description: "Details of a HANA Pacemaker Cluster", | ||
type: :object, | ||
properties: %{ | ||
system_replication_mode: %Schema{type: :string, description: "System Replication Mode"}, | ||
system_replication_operation_mode: %Schema{ | ||
type: :string, | ||
description: "System Replication Operation Mode" | ||
}, | ||
secondary_sync_state: %Schema{type: :string, description: "Secondary Sync State"}, | ||
sr_health_state: %Schema{type: :string, description: "SR health state"}, | ||
fencing_type: %Schema{type: :string, description: "Fencing Type"}, | ||
stopped_resources: %Schema{ | ||
title: "ClusterResource", | ||
description: "A list of the stopped resources on this HANA Cluster", | ||
type: :array, | ||
items: ClusterResource | ||
}, | ||
nodes: %Schema{ | ||
title: "HanaClusterNodes", | ||
type: :array, | ||
items: ClusterNode | ||
}, | ||
sbd_devices: %Schema{ | ||
title: "SbdDevice", | ||
type: :array, | ||
items: SbdDevice | ||
} | ||
} | ||
}) | ||
end | ||
|
||
defmodule Details do | ||
@moduledoc false | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "PacemakerClusterDetail", | ||
description: "Details of the detected PacemakerCluster", | ||
oneOf: [ | ||
HanaClusterDetails | ||
] | ||
}) | ||
end | ||
|
||
defmodule PacemakerCluster do | ||
@moduledoc false | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "PacemakerCluster", | ||
description: "A discovered Pacemaker Cluster on the target infrastructure", | ||
type: :object, | ||
properties: %{ | ||
id: %Schema{type: :integer, description: "Cluster ID"}, | ||
name: %Schema{type: :string, description: "Cluster name"}, | ||
sid: %Schema{type: :string, description: "SID"}, | ||
provider: Provider.SupportedProviders, | ||
type: %Schema{ | ||
type: :string, | ||
description: "Detected type of the cluster", | ||
enum: [:hana_scale_up, :hana_scale_out, :unknown] | ||
}, | ||
selected_checks: %Schema{ | ||
title: "SelectedChecks", | ||
description: "A list ids of the checks selected for execution on this cluster", | ||
type: :array, | ||
items: %Schema{type: :string} | ||
}, | ||
health: %Schema{ | ||
type: :string, | ||
description: "Detected health of the cluster", | ||
enum: [:passing, :warning, :critical, :unknown] | ||
}, | ||
resources_number: %Schema{type: :integer, description: "Resource number"}, | ||
hosts_number: %Schema{type: :integer, description: "Hosts number"}, | ||
details: Details, | ||
checks_execution: %Schema{ | ||
type: :string, | ||
description: "Current status of the checks execution for this cluster", | ||
enum: [:not_running, :requested, :running] | ||
}, | ||
hosts_executions: %Schema{ | ||
title: "HostChecksExecutions", | ||
description: "A list of tags attached to a resource", | ||
type: :array, | ||
items: Checks.HostChecksExecution | ||
}, | ||
checks_results: %Schema{ | ||
title: "CheckResults", | ||
description: "A list of tags attached to a resource", | ||
type: :array, | ||
items: Checks.CheckResult | ||
}, | ||
tags: %Schema{ | ||
title: "Tags", | ||
description: "A list of tags attached to a resource", | ||
type: :array, | ||
items: Tag | ||
} | ||
} | ||
}) | ||
end | ||
|
||
defmodule PacemakerClustersCollection do | ||
@moduledoc false | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "PacemakerClustersCollection", | ||
description: "A list of the discovered Pacemaker Clusters", | ||
type: :array, | ||
items: PacemakerCluster | ||
}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.