Package io.openems.edge.bridge.http.api
Interface BridgeHttp
- All Superinterfaces:
BridgeHttpCycle
,BridgeHttpTime
- All Known Implementing Classes:
BridgeHttpImpl
,DummyBridgeHttp
HttpBridge to handle requests to a
BridgeHttp.Endpoint
.
To get a reference to a bridge object include this in your component:
@Reference
private BridgeHttpFactory httpBridgeFactory; private BridgeHttp httpBridge;@Activate
private void activate() { this.httpBridge = this.httpBridgeFactory.get(); }@Deactivate
private void deactivate() { this.httpBridgeFactory.unget(this.httpBridge); this.httpBridge = null; }
A simple example to subscribe to an endpoint every cycle would be:
this.httpBridge.subscribeEveryCycle("http://127.0.0.1/status", t -> { // process data }, t -> { // handle error });
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.openems.edge.bridge.http.api.BridgeHttpCycle
BridgeHttpCycle.CycleEndpoint
Nested classes/interfaces inherited from interface io.openems.edge.bridge.http.api.BridgeHttpTime
BridgeHttpTime.TimeEndpoint
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
Default empty error handler. -
Method Summary
Modifier and TypeMethodDescriptiondefault CompletableFuture
<String> Fetches the url once withHttpMethod.DELETE
.default CompletableFuture
<com.google.gson.JsonElement> deleteJson
(String url) Fetches the url once withHttpMethod.DELETE
and expects the result to be in json format.default CompletableFuture
<String> Fetches the url once withHttpMethod.GET
.default CompletableFuture
<com.google.gson.JsonElement> Fetches the url once withHttpMethod.GET
and expects the result to be in json format.default CompletableFuture
<String> Fetches the url once withHttpMethod.POST
.default CompletableFuture
<com.google.gson.JsonElement> Fetches the url once withHttpMethod.POST
and expects the result to be in json format.default CompletableFuture
<String> Fetches the url once withHttpMethod.PUT
.default CompletableFuture
<com.google.gson.JsonElement> Fetches the url once withHttpMethod.PUT
and expects the result to be in json format.request
(BridgeHttp.Endpoint endpoint) Fetches the url once.default CompletableFuture
<com.google.gson.JsonElement> requestJson
(BridgeHttp.Endpoint endpoint) Fetches the url once and expects the result to be in json format.Methods inherited from interface io.openems.edge.bridge.http.api.BridgeHttpCycle
subscribeCycle, subscribeCycle, subscribeCycle, subscribeCycle, subscribeEveryCycle, subscribeEveryCycle, subscribeEveryCycle, subscribeJsonCycle, subscribeJsonCycle, subscribeJsonEveryCycle, subscribeJsonEveryCycle
Methods inherited from interface io.openems.edge.bridge.http.api.BridgeHttpTime
subscribeJsonTime, subscribeJsonTime, subscribeTime, subscribeTime, subscribeTime, subscribeTime, subscribeTime, subscribeTime
-
Field Details
-
DEFAULT_CONNECT_TIMEOUT
static final int DEFAULT_CONNECT_TIMEOUT- See Also:
-
DEFAULT_READ_TIMEOUT
static final int DEFAULT_READ_TIMEOUT- See Also:
-
EMPTY_ERROR_HANDLER
Default empty error handler.
-
-
Method Details
-
get
Fetches the url once withHttpMethod.GET
.- Parameters:
url
- the url to fetch- Returns:
- the result response future
-
getJson
Fetches the url once withHttpMethod.GET
and expects the result to be in json format.- Parameters:
url
- the url to fetch- Returns:
- the result response future
-
put
Fetches the url once withHttpMethod.PUT
.- Parameters:
url
- the url to fetch- Returns:
- the result response future
-
putJson
Fetches the url once withHttpMethod.PUT
and expects the result to be in json format.- Parameters:
url
- the url to fetch- Returns:
- the result response future
-
post
Fetches the url once withHttpMethod.POST
.- Parameters:
url
- the url to fetchbody
- the request body to send- Returns:
- the result response future
-
postJson
default CompletableFuture<com.google.gson.JsonElement> postJson(String url, com.google.gson.JsonElement body) Fetches the url once withHttpMethod.POST
and expects the result to be in json format.- Parameters:
url
- the url to fetchbody
- the request body to send- Returns:
- the result response future
-
delete
Fetches the url once withHttpMethod.DELETE
.- Parameters:
url
- the url to fetch- Returns:
- the result response future
-
deleteJson
Fetches the url once withHttpMethod.DELETE
and expects the result to be in json format.- Parameters:
url
- the url to fetch- Returns:
- the result response future
-
request
Fetches the url once.- Parameters:
endpoint
- theBridgeHttp.Endpoint
to fetch- Returns:
- the result response future
-
requestJson
Fetches the url once and expects the result to be in json format.- Parameters:
endpoint
- theBridgeHttp.Endpoint
to fetch- Returns:
- the result response future
-