Package io.openems.common.jsonrpc.base
Class JsonrpcRequest
- java.lang.Object
-
- io.openems.common.jsonrpc.base.JsonrpcMessage
-
- io.openems.common.jsonrpc.base.AbstractJsonrpcRequest
-
- io.openems.common.jsonrpc.base.JsonrpcRequest
-
- Direct Known Subclasses:
AddAppInstance.Request
,AddEdgeToUserRequest
,AuthenticatedRpcRequest
,AuthenticateWithPasswordRequest
,AuthenticateWithTokenRequest
,ChannelExportXlsxRequest
,ComponentJsonApiRequest
,CreateComponentConfigRequest
,DeleteAppInstance.Request
,DeleteComponentConfigRequest
,EdgeRpcRequest
,ExecuteSimulationRequest
,ExecuteSystemCommandRequest
,ExecuteSystemUpdateRequest
,GenericJsonrpcRequest
,Get24HoursPredictionRequest
,GetApp.Request
,GetAppAssistant.Request
,GetAppDescriptor.Request
,GetAppInstances.Request
,GetApps.Request
,GetDevicesRequest
,GetEdgeConfigRequest
,GetEdgeRequest
,GetEdgesChannelsValuesRequest
,GetEdgesRequest
,GetEdgesStatusRequest
,GetFieldNamesRequest
,GetMetersRequest
,GetModbusProtocolExportXlsxRequest
,GetModbusProtocolRequest
,GetNetworkConfigRequest
,GetSetupProtocolDataRequest
,GetSetupProtocolRequest
,GetSystemUpdateStateRequest
,GetUserAlertingConfigsRequest
,GetUserInformationRequest
,LogoutRequest
,QueryHistoricTimeseriesDataRequest
,QueryHistoricTimeseriesEnergyPerPeriodRequest
,QueryHistoricTimeseriesEnergyRequest
,QueryHistoricTimeseriesExportXlxsRequest
,RegisterUserRequest
,SetChannelValueRequest
,SetGridConnScheduleRequest
,SetNetworkConfigRequest
,SetUserAlertingConfigsRequest
,SetUserInformationRequest
,SubmitSetupProtocolRequest
,SubscribeChannelsRequest
,SubscribeEdgesChannelsRequest
,SubscribeEdgesRequest
,SubscribeEdgesRequest
,SubscribeSystemLogRequest
,SystemUpdateRequest
,UpdateAppInstance.Request
,UpdateComponentConfigRequest
,UpdateUserLanguageRequest
public abstract class JsonrpcRequest extends AbstractJsonrpcRequest
Represents a JSON-RPC Request.{ "jsonrpc": "2.0", "id": "UUID", "method": string, "params": {}, "timeout"?: number, defaults to 60 seconds; negative or zero to disable timeout }
- See Also:
- JSON-RPC specification
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_TIMEOUT_SECONDS
java.util.UUID
id
static int
NO_TIMEOUT
java.util.Optional<java.lang.Integer>
timeoutOpt
-
Fields inherited from class io.openems.common.jsonrpc.base.JsonrpcMessage
JSONRPC_VERSION
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
JsonrpcRequest(JsonrpcRequest request, java.lang.String method)
Creates aJsonrpcRequest
by copying and validating header information.JsonrpcRequest(java.lang.String method)
JsonrpcRequest(java.lang.String method, int timeout)
Creates aJsonrpcRequest
with randomUUID
as id.JsonrpcRequest(java.lang.String method, java.util.Optional<java.lang.Integer> timeout)
Creates aJsonrpcRequest
with randomUUID
as id.JsonrpcRequest(java.util.UUID id, java.lang.String method, int timeout)
Creates aJsonrpcRequest
.JsonrpcRequest(java.util.UUID id, java.lang.String method, java.util.Optional<java.lang.Integer> timeoutOpt)
Creates aJsonrpcRequest
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.UUID
getId()
Gets the JSON-RPC id.java.util.Optional<java.lang.Integer>
getTimeout()
Gets the max time in seconds to wait for theJsonrpcResponse
, negative or zero to disable timeout.com.google.gson.JsonObject
toJsonObject()
Gets theJsonObject
representation of thisJsonrpcMessage
.-
Methods inherited from class io.openems.common.jsonrpc.base.AbstractJsonrpcRequest
getFullyQualifiedMethod, getMethod, getParams
-
Methods inherited from class io.openems.common.jsonrpc.base.JsonrpcMessage
from, from, toString
-
-
-
-
Field Detail
-
DEFAULT_TIMEOUT_SECONDS
public static final int DEFAULT_TIMEOUT_SECONDS
- See Also:
- Constant Field Values
-
NO_TIMEOUT
public static final int NO_TIMEOUT
- See Also:
- Constant Field Values
-
id
public final java.util.UUID id
-
timeoutOpt
public final java.util.Optional<java.lang.Integer> timeoutOpt
-
-
Constructor Detail
-
JsonrpcRequest
public JsonrpcRequest(java.lang.String method)
- Parameters:
method
- the JSON-RPC method
-
JsonrpcRequest
public JsonrpcRequest(java.lang.String method, int timeout)
Creates aJsonrpcRequest
with randomUUID
as id.- Parameters:
method
- the JSON-RPC methodtimeout
- max time in seconds to wait for theJsonrpcResponse
, negative or zero to disable timeout
-
JsonrpcRequest
public JsonrpcRequest(java.lang.String method, java.util.Optional<java.lang.Integer> timeout)
Creates aJsonrpcRequest
with randomUUID
as id.- Parameters:
method
- the JSON-RPC methodtimeout
- max time in seconds to wait for theJsonrpcResponse
, negative or zero to disable timeout, empty forDEFAULT_TIMEOUT_SECONDS
timeout
-
JsonrpcRequest
public JsonrpcRequest(java.util.UUID id, java.lang.String method, java.util.Optional<java.lang.Integer> timeoutOpt)
Creates aJsonrpcRequest
.- Parameters:
id
- the JSON-RPC idmethod
- the JSON-RPC methodtimeoutOpt
- max time in seconds to wait for theJsonrpcResponse
, negative or zero to disable timeout, empty forDEFAULT_TIMEOUT_SECONDS
timeout
-
JsonrpcRequest
protected JsonrpcRequest(JsonrpcRequest request, java.lang.String method)
Creates aJsonrpcRequest
by copying and validating header information.- copies id and timeout
- validates that the method names match
- Parameters:
request
- the template JSON-RPC Requestmethod
- the JSON-RPC method
-
JsonrpcRequest
public JsonrpcRequest(java.util.UUID id, java.lang.String method, int timeout)
Creates aJsonrpcRequest
.- Parameters:
id
- the JSON-RPC idmethod
- the JSON-RPC methodtimeout
- max time in seconds to wait for theJsonrpcResponse
, negative or zero to disable timeout
-
-
Method Detail
-
getId
public java.util.UUID getId()
Gets the JSON-RPC id.- Returns:
- the
UUID
id
-
getTimeout
public java.util.Optional<java.lang.Integer> getTimeout()
Gets the max time in seconds to wait for theJsonrpcResponse
, negative or zero to disable timeout.- Returns:
- the timeout in seconds
-
toJsonObject
public com.google.gson.JsonObject toJsonObject()
Description copied from class:JsonrpcMessage
Gets theJsonObject
representation of thisJsonrpcMessage
.- Overrides:
toJsonObject
in classAbstractJsonrpcRequest
- Returns:
- a
JsonObject
-
-