-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clusters list openapi doc #522
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,181 @@ | ||
defmodule TrentoWeb.OpenApi.Schema.Cluster do | ||
@moduledoc false | ||
|
||
require OpenApiSpex | ||
alias OpenApiSpex.Schema | ||
|
||
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: TrentoWeb.OpenApi.Schema.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: TrentoWeb.OpenApi.Schema.Checks.HostChecksExecution | ||
}, | ||
checks_results: %Schema{ | ||
title: "CheckResults", | ||
description: "A list of tags attached to a resource", | ||
type: :array, | ||
items: TrentoWeb.OpenApi.Schema.Checks.CheckResult | ||
}, | ||
tags: %Schema{ | ||
title: "Tags", | ||
description: "A list of tags attached to a resource", | ||
type: :array, | ||
items: TrentoWeb.OpenApi.Schema.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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we use aliases for this long module names (maybe just aliasing TrentoWeb.OpenApi.Schema)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, made some polishing here f372b79