Class ExecuteSystemCommandRequest
- java.lang.Object
-
- io.openems.common.jsonrpc.base.JsonrpcMessage
-
- io.openems.common.jsonrpc.base.AbstractJsonrpcRequest
-
- io.openems.common.jsonrpc.base.JsonrpcRequest
-
- io.openems.edge.core.host.jsonrpc.ExecuteSystemCommandRequest
-
public class ExecuteSystemCommandRequest extends JsonrpcRequest
Represents a JSON-RPC Request to execute a system command on OpenEMS Edge.{ "jsonrpc": "2.0", "id": "UUID", "method": "executeSystemCommand", "params": { "command": string, "runInBackground"?: boolean = false, // run the command in background (true) or in foreground (false) "timeoutSeconds"?: number = 5, // interrupt the command after ... seconds "username"?: string, "password"?: string, } }
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEFAULT_RUN_IN_BACKGROUND
static int
DEFAULT_TIMEOUT_SECONDS
static java.lang.String
METHOD
-
Fields inherited from class io.openems.common.jsonrpc.base.JsonrpcRequest
id, NO_TIMEOUT, timeoutOpt
-
Fields inherited from class io.openems.common.jsonrpc.base.JsonrpcMessage
JSONRPC_VERSION
-
-
Constructor Summary
Constructors Constructor Description ExecuteSystemCommandRequest(java.lang.String command, boolean runInBackground, int timeoutSeconds, java.util.Optional<java.lang.String> username, java.util.Optional<java.lang.String> password)
ExecuteSystemCommandRequest(java.util.UUID id, java.lang.String command, boolean runInBackground, int timeoutSeconds, java.util.Optional<java.lang.String> username, java.util.Optional<java.lang.String> password)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ExecuteSystemCommandRequest
from(JsonrpcRequest r)
Parses a genericJsonrpcRequest
to aExecuteSystemCommandRequest
.java.lang.String
getCommand()
Gets the request command.com.google.gson.JsonObject
getParams()
Gets the paramsJsonObject
of theJsonrpcRequest
.java.util.Optional<java.lang.String>
getPassword()
Gets the request password.int
getTimeoutSeconds()
Gets the request timeout.java.util.Optional<java.lang.String>
getUsername()
Gets the request username.boolean
isRunInBackground()
Gets the request isRunInBackground option.static ExecuteSystemCommandRequest
runInBackgroundWithoutAuthentication(java.lang.String command)
Factory without Username + Password; run in background without timeout.static ExecuteSystemCommandRequest
withoutAuthentication(java.lang.String command, boolean runInBackground, int timeoutSeconds)
Factory without Username + Password.-
Methods inherited from class io.openems.common.jsonrpc.base.JsonrpcRequest
getId, getTimeout, toJsonObject
-
Methods inherited from class io.openems.common.jsonrpc.base.AbstractJsonrpcRequest
getFullyQualifiedMethod, getMethod
-
Methods inherited from class io.openems.common.jsonrpc.base.JsonrpcMessage
from, from, toString
-
-
-
-
Field Detail
-
METHOD
public static final java.lang.String METHOD
- See Also:
- Constant Field Values
-
DEFAULT_RUN_IN_BACKGROUND
public static final boolean DEFAULT_RUN_IN_BACKGROUND
- See Also:
- Constant Field Values
-
DEFAULT_TIMEOUT_SECONDS
public static final int DEFAULT_TIMEOUT_SECONDS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ExecuteSystemCommandRequest
public ExecuteSystemCommandRequest(java.lang.String command, boolean runInBackground, int timeoutSeconds, java.util.Optional<java.lang.String> username, java.util.Optional<java.lang.String> password)
-
ExecuteSystemCommandRequest
public ExecuteSystemCommandRequest(java.util.UUID id, java.lang.String command, boolean runInBackground, int timeoutSeconds, java.util.Optional<java.lang.String> username, java.util.Optional<java.lang.String> password)
-
-
Method Detail
-
from
public static ExecuteSystemCommandRequest from(JsonrpcRequest r) throws OpenemsError.OpenemsNamedException
Parses a genericJsonrpcRequest
to aExecuteSystemCommandRequest
.- Parameters:
r
- theJsonrpcRequest
- Returns:
- the
ExecuteSystemCommandRequest
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
runInBackgroundWithoutAuthentication
public static ExecuteSystemCommandRequest runInBackgroundWithoutAuthentication(java.lang.String command)
Factory without Username + Password; run in background without timeout.- Parameters:
command
- the command- Returns:
- the
ExecuteSystemCommandRequest
-
withoutAuthentication
public static ExecuteSystemCommandRequest withoutAuthentication(java.lang.String command, boolean runInBackground, int timeoutSeconds)
Factory without Username + Password.- Parameters:
command
- the commandrunInBackground
- run the command in background (true) or in foreground (false)timeoutSeconds
- interrupt the command after ... seconds- Returns:
- the
ExecuteSystemCommandRequest
-
getParams
public com.google.gson.JsonObject getParams()
Description copied from class:AbstractJsonrpcRequest
Gets the paramsJsonObject
of theJsonrpcRequest
.- Specified by:
getParams
in classAbstractJsonrpcRequest
- Returns:
- the params as
JsonObject
-
getCommand
public java.lang.String getCommand()
Gets the request command.- Returns:
- the command
-
isRunInBackground
public boolean isRunInBackground()
Gets the request isRunInBackground option.- Returns:
- the isRunInBackground option
-
getTimeoutSeconds
public int getTimeoutSeconds()
Gets the request timeout.- Returns:
- the timeout in seconds
-
getUsername
public java.util.Optional<java.lang.String> getUsername()
Gets the request username.- Returns:
- the username
-
getPassword
public java.util.Optional<java.lang.String> getPassword()
Gets the request password.- Returns:
- the password
-
-