public class RestClient extends Object
| Constructor and Description |
|---|
RestClient(YamcsConnectionProperties connectionProperties)
Creates a rest client that communications using protobuf
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCookie(io.netty.handler.codec.http.cookie.Cookie c) |
List<YamcsManagement.YamcsInstance> |
blockingGetYamcsInstances()
Retrieve the list of yamcs instances from the server.
|
void |
close() |
CompletableFuture<Void> |
doBulkGetRequest(String resource,
BulkRestDataReceiver receiver)
Performs a bulk request and provides the result piece by piece to the receiver.
|
CompletableFuture<Void> |
doBulkGetRequest(String resource,
byte[] body,
BulkRestDataReceiver receiver) |
CompletableFuture<BulkRestDataSender> |
doBulkSendRequest(String resource,
io.netty.handler.codec.http.HttpMethod method) |
CompletableFuture<byte[]> |
doRequest(String resource,
io.netty.handler.codec.http.HttpMethod method)
Performs a request with an empty body.
|
CompletableFuture<byte[]> |
doRequest(String resource,
io.netty.handler.codec.http.HttpMethod method,
byte[] body)
Perform asynchronously the request indicated by the HTTP method and return the result as a future providing byte array.
|
CompletableFuture<String> |
doRequest(String resource,
io.netty.handler.codec.http.HttpMethod method,
String body)
Perform asynchronously the request indicated by the HTTP method and return the result as a future providing byte array.
|
List<io.netty.handler.codec.http.cookie.Cookie> |
getCookies() |
CompletableFuture<List<YamcsManagement.YamcsInstance>> |
getYamcsInstances() |
boolean |
isAutoclose() |
static int |
readVarInt32(ByteBuffer bb) |
void |
setAcceptMediaType(MediaType acceptMediaType) |
void |
setAutoclose(boolean autoclose)
if autoclose is set, the httpClient will be automatically closed at the end of the request, so the netty eventgroup is shutdown.
|
void |
setMaxResponseLength(int size) |
void |
setSendMediaType(MediaType sendMediaType) |
public RestClient(YamcsConnectionProperties connectionProperties)
connectionProperties - public List<YamcsManagement.YamcsInstance> blockingGetYamcsInstances() throws Exception
Exceptionpublic CompletableFuture<List<YamcsManagement.YamcsInstance>> getYamcsInstances()
public CompletableFuture<byte[]> doRequest(String resource, io.netty.handler.codec.http.HttpMethod method)
resource - method - public CompletableFuture<String> doRequest(String resource, io.netty.handler.codec.http.HttpMethod method, String body)
resource - - the url and query parameters after the "/api" part.method - - http method to usebody - - the body of the request. Can be used even for the GET requests although strictly not allowed by the HTTP standard.IllegalArgumentException - thrown in case the resource specification is invalidpublic CompletableFuture<byte[]> doRequest(String resource, io.netty.handler.codec.http.HttpMethod method, byte[] body)
resource - method - body - protobuf encoded data.public CompletableFuture<Void> doBulkGetRequest(String resource, BulkRestDataReceiver receiver)
resource - receiver - RuntimeException - - thrown if the uri + resource does not form a correct URLpublic CompletableFuture<Void> doBulkGetRequest(String resource, byte[] body, BulkRestDataReceiver receiver)
public static int readVarInt32(ByteBuffer bb) throws YamcsApiException
YamcsApiExceptionpublic void setSendMediaType(MediaType sendMediaType)
public void setAcceptMediaType(MediaType acceptMediaType)
public void setMaxResponseLength(int size)
public void close()
public boolean isAutoclose()
public void setAutoclose(boolean autoclose)
autoclose - public void addCookie(io.netty.handler.codec.http.cookie.Cookie c)
public List<io.netty.handler.codec.http.cookie.Cookie> getCookies()
public CompletableFuture<BulkRestDataSender> doBulkSendRequest(String resource, io.netty.handler.codec.http.HttpMethod method)
Copyright © 2018 Space Applications Services. All rights reserved.