Skip to content

Commit

Permalink
Issue #424: Add CLI options for specific query execution - SNMP
Browse files Browse the repository at this point in the history
* Added missing Javadoc.
  • Loading branch information
CherfaElyes committed Dec 3, 2024
1 parent ec37eba commit e436a2f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class SnmpCli implements IQuery, Callable<Integer> {
@Option(names = "-v", order = 7, description = "Verbose mode (repeat the option to increase verbosity)")
boolean[] verbose;

@Override
public JsonNode getQuery() {
final ObjectNode queryNode = JsonNodeFactory.instance.objectNode();
String action;
Expand All @@ -93,6 +94,11 @@ public JsonNode getQuery() {
return queryNode;
}

/**
* Validates SNMP configuration and ensures exactly one query type (--snmp-get, --snmp-getnext, or --snmp-walk) is specified.
*
* @throws ParameterException if SNMP is not configured, no query is specified, or multiple queries are specified.
*/
void validate() throws ParameterException {
if (snmpConfigCli == null) {
throw new ParameterException(spec.commandLine(), "SNMP protocol must be configured: --snmp.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.sentrysoftware.metricshub.engine.common;

import com.fasterxml.jackson.databind.JsonNode;

/*-
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
* MetricsHub Engine
Expand All @@ -20,4 +22,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
*/
public interface IQuery {}
public interface IQuery {
JsonNode getQuery();
}

0 comments on commit e436a2f

Please sign in to comment.