Class AuthenticatedRpcRequest<USER extends AbstractUser>
java.lang.Object
io.openems.common.jsonrpc.base.JsonrpcMessage
io.openems.common.jsonrpc.base.AbstractJsonrpcRequest
io.openems.common.jsonrpc.base.JsonrpcRequest
io.openems.common.jsonrpc.request.AuthenticatedRpcRequest<USER>
Wraps a JSON-RPC Request from an authenticated User.
{
"jsonrpc": "2.0",
"id": "UUID",
"method": "authenticatedRpc",
"params": {
"user": {
"id": string,
"name: string,
"role": string
},
"payload": JsonrpcRequest
}
}
-
Field Summary
FieldsFields inherited from class io.openems.common.jsonrpc.base.JsonrpcRequest
DEFAULT_TIMEOUT_SECONDS, id, NO_TIMEOUT, timeoutOpt
Fields inherited from class io.openems.common.jsonrpc.base.JsonrpcMessage
JSONRPC_VERSION
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <USER extends AbstractUser>
AuthenticatedRpcRequest<USER>from
(JsonrpcRequest r, ThrowingFunction<com.google.gson.JsonObject, USER, OpenemsError.OpenemsNamedException> userFactory) CreateAuthenticatedRpcRequest
from a templateJsonrpcRequest
.com.google.gson.JsonObject
This method is called in OpenEMS Backend and formats theAuthenticatedRpcRequest
, especially the `user` property so, that it contains only the required information for OpenEMS Edge and can be parsed viafrom(JsonrpcRequest, ThrowingFunction)
.Gets the PayloadJsonrpcRequest
.getUser()
Gets theAbstractUser
.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 Details
-
METHOD
- See Also:
-
-
Constructor Details
-
AuthenticatedRpcRequest
-
-
Method Details
-
from
public static <USER extends AbstractUser> AuthenticatedRpcRequest<USER> from(JsonrpcRequest r, ThrowingFunction<com.google.gson.JsonObject, USER, throws OpenemsError.OpenemsNamedExceptionOpenemsError.OpenemsNamedException> userFactory) CreateAuthenticatedRpcRequest
from a templateJsonrpcRequest
.This method is called by OpenEMS Edge after it receives a message from OpenEMS Backend. As such the `edgeId` is empty here.
- Type Parameters:
USER
- the type of User- Parameters:
r
- the templateJsonrpcRequest
userFactory
- aThrowingFunction
that parses the followingJsonObject
structure to aAbstractUser
{ "id": string, "name": string, "role":
Role
}- Returns:
- the
AuthenticatedRpcRequest
- Throws:
OpenemsError.OpenemsNamedException
- on parse error
-
getUser
Gets theAbstractUser
.- Returns:
- User
-
getPayload
Gets the PayloadJsonrpcRequest
.- Returns:
- Payload
-
getParams
public com.google.gson.JsonObject getParams()This method is called in OpenEMS Backend and formats theAuthenticatedRpcRequest
, especially the `user` property so, that it contains only the required information for OpenEMS Edge and can be parsed viafrom(JsonrpcRequest, ThrowingFunction)
.- Specified by:
getParams
in classAbstractJsonrpcRequest
- Returns:
- the params as
JsonObject
-