Class ConnectorJsonNodeReader
This class provides methods to extract various fields and information from a
JsonNode
representing a connector. It serves as an utility
for reading data associated with a connector. Various methods are available
to retrieve specific attributes such as supersedes, detection, criteria or
other relevant details.
Instances of this class are typically created with a JsonNode
containing connector information, and the provided methods can then be used
to access and extract specific details from the JSON structure.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final String
extractMetricName
(String name) This method removes attribute parts from the metric namegetAndCompleteTags
(boolean isEnterprise) Retrieves and adds a specified tag to the detection JSON node's "tags" list.Retrieves the list of appliesTo (OS) values from the connector's detection property, if available.Retrieves a set of connection types specified in the connector's detection.List<com.fasterxml.jackson.databind.JsonNode>
Retrieves the detection criteria as a list ofJsonNode
objects from the connector's detection section.Retrieves the default connector variables declared in the connector.Retrieves the display name property of the connector located under the connector JSON node.getInformationOrDefault
(String defaultValue) Retrieves the information property of the connector, if available.getMonitorAttributes
(com.fasterxml.jackson.databind.JsonNode monitor) Retrieves the attribute keys from the specified monitor node.com.fasterxml.jackson.databind.JsonNode[]
getMonitorJobs
(com.fasterxml.jackson.databind.JsonNode monitor) Retrieves the monitor's jobs from the specified monitor node.getMonitorMetrics
(com.fasterxml.jackson.databind.JsonNode monitor) Retrieves the metric keys from the specified monitor node.Optional<com.fasterxml.jackson.databind.JsonNode>
Gets the monitors from the connector.Retrieves the "onLastResort" configuration value from the connector's detection section.getPlatformsOrDefault
(String defaultValue) Retrieves the platforms property of the connector, if available.Retrieves the relative path of the connector that was saved during parsing.getReliesOnOrDefault
(String defaultValue) Retrieves the reliesOn property of the connector, if available.Retrieves the required MetricsHub version from the connector's detection criteria.Retrieves a list of sudo commands configured in the connector.Retrieves the list of supersedes values from the connector's detection property, if available.getTags()
Retrieves a list of tags from the detection JSON node.Retrieves the set ofTechnologyType
s used by the monitor jobs in the connector.Retrieves all variable names from the connector template.boolean
Checks if there is a blade monitor job with mapping directives.boolean
Checks if auto-detection is disabled for the connector.
-
Constructor Details
-
ConnectorJsonNodeReader
public ConnectorJsonNodeReader()
-
-
Method Details
-
getDisplayName
Retrieves the display name property of the connector located under the connector JSON node.- Returns:
- The display name as a String.
-
getInformationOrDefault
Retrieves the information property of the connector, if available.- Parameters:
defaultValue
- The default value to return if the information property is null or represents a JSON null.- Returns:
- The information property as a String, or the specified default value if not present.
-
getPlatformsOrDefault
Retrieves the platforms property of the connector, if available.- Parameters:
defaultValue
- The default value to return if the platforms property is null or represents a JSON null.- Returns:
- The platforms property as a String, or the specified default value if not present.
-
getSupersedes
Retrieves the list of supersedes values from the connector's detection property, if available.- Returns:
- A list of strings representing the supersedes values, or an empty list if not present.
-
getAppliesTo
Retrieves the list of appliesTo (OS) values from the connector's detection property, if available.- Returns:
- A list of strings representing the OS values, or an empty list if not present.
-
getRequiredMetricsHubVersion
Retrieves the required MetricsHub version from the connector's detection criteria.This method retrieves the required MetricsHub version by extracting the detection criteria obtained from the connector. It looks for criteria of type "productRequirements" and extracts the associated engine version. If no matching criteria are found or the necessary information is not available, the method returns
null
.- Returns:
- The required MetricsHub version, or null if the information is not available.
-
getReliesOnOrDefault
Retrieves the reliesOn property of the connector, if available.- Parameters:
defaultValue
- The default value to return if the reliesOn property is null or represents a JSON null.- Returns:
- The reliesOn property as a String, or the specified default value if not present.
-
getTechnologies
Retrieves the set ofTechnologyType
s used by the monitor jobs in the connector.This method iterates through the monitors defined in the connector and collects the
TechnologyType
s associated with their discovery, collect, and simple jobs. The result is a set of unique technology types.- Returns:
- A
Set
ofTechnologyType
s used by monitors in the connector.
-
getMonitors
Gets the monitors from the connector.- Returns:
- The monitors as an Optional of
JsonNode
.
-
getSudoCommands
Retrieves a list of sudo commands configured in the connector.This method retrieves the sudo commands defined in the "sudoCommands" section of the connector. The commands are returned as a
List
of strings. If the "sudoCommands" section is not present or is not of the expected type, an empty list is returned.- Returns:
- A
List
of strings representing the sudo commands set in the connector.
-
getConnectionTypes
Retrieves a set of connection types specified in the connector's detection.This method looks for the "connectionTypes" field within the "detection" section of the connector configuration. If the "detection" section is present and contains the "connectionTypes" field, the method returns a
Set
of case-insensitive strings representing the connection types. If the "detection" section or the "connectionTypes" field is not present or is not of the expected type, an empty set is returned.- Returns:
- A case-insensitive
Set
of strings representing the connection types (local and/or remote).
-
isAutoDetectionDisabled
public boolean isAutoDetectionDisabled()Checks if auto-detection is disabled for the connector.This method looks for the presence of the "disableAutoDetection" field within the "detection" section of the connector. If the field is present and is a boolean value, the method returns its boolean value. If the "detection" section or the "disableAutoDetection" field is not present or is not a boolean, the method assumes auto-detection is enabled and returns false.
- Returns:
true
if auto-detection is explicitly disabled,false
if explicitly enabled, orfalse
if the configuration is not present.
-
getOnLastResort
Retrieves the "onLastResort" configuration value from the connector's detection section.- Returns:
- The "onLastResort" configuration value as a string, or
null
if not configured.
-
getCriteria
Retrieves the detection criteria as a list ofJsonNode
objects from the connector's detection section.- Returns:
- A list of
JsonNode
objects representing the detection criteria, or an empty list if not configured.
-
getMonitorMetrics
Retrieves the metric keys from the specified monitor node.- Parameters:
monitor
- The monitor node as aJsonNode
.- Returns:
- A
Set
containing the metric keys.
-
getMonitorAttributes
Retrieves the attribute keys from the specified monitor node.- Parameters:
monitor
- The monitor node as aJsonNode
.- Returns:
- A
Set
containing the attribute keys.
-
getMonitorJobs
public com.fasterxml.jackson.databind.JsonNode[] getMonitorJobs(com.fasterxml.jackson.databind.JsonNode monitor) Retrieves the monitor's jobs from the specified monitor node.- Parameters:
monitor
- The monitor node as aJsonNode
.- Returns:
- An array containing the monitor's jobs
-
extractMetricName
This method removes attribute parts from the metric name- Parameters:
name
- metric name with or without attributes- Returns:
- metric name without attributes
-
hasBladeMonitorJob
public boolean hasBladeMonitorJob()Checks if there is a blade monitor job with mapping directives.- Returns:
true
if there is a blade monitor job with mapping directives, otherwisefalse
.
-
getAndCompleteTags
Retrieves and adds a specified tag to the detection JSON node's "tags" list.Adds either "enterprise" or "community" to the "tags" field based on the
isEnterprise
parameter. If the "tags" field is absent or null, it initializes a new array with the specified tag.- Parameters:
isEnterprise
-true
to add "enterprise" to the tags;false
to add "community".- Returns:
- a list of tags as strings, including the added tag, or an empty list if the detection node is null.
-
getTags
Retrieves a list of tags from the detection JSON node.- Returns:
- a list of tags as strings, or an empty list if no tags are found.
-
getVariablesNames
Retrieves all variable names from the connector template. Variables are expected to be in the format: ${var::variableName}.- Returns:
- a set of unique variable names found within the connector template.
-
getDefaultVariables
Retrieves the default connector variables declared in the connector. These variables include their descriptions and default values.- Returns:
- a map of variable names to their corresponding
ConnectorDefaultVariable
objects, each containing a description and a default value. Returns an empty map if no variables are declared.
-
getRelativePath
Retrieves the relative path of the connector that was saved during parsing. This path is used to generate a link to the connector's source code.- Returns:
- The saved relative path as a string.
-