Interface RestApi
- All Known Implementing Classes:
RestApiBase,VaultRestApi
public interface RestApi
JSON based REST API operations.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classRestApi.Builder<B extends RestApi.Builder<B,T>, T extends RestApi> Base builder for REST APIs. -
Method Summary
Modifier and TypeMethodDescriptiondefault <T extends ApiResponse>
Single<T>delete(String path, ApiRequest<?> request, ApiResponse.Builder<?, T> responseBuilder) Delete without a response entity.default <R,T extends ApiOptionalResponse<R>>
Single<T>get(String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?, T, JsonObject, R> responseBuilder) Get with an optional response.default <R,T extends ApiOptionalResponse<R>>
Single<T>getBytes(String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?, T, byte[], R> responseBuilder) Get bytes with an optional response.default <R,T extends ApiOptionalResponse<R>>
Single<T>getPublisher(String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?, T, Multi<DataChunk>, R> responseBuilder) Get with a response consisting of a stream.<T extends ApiResponse>
Single<T>invoke(Http.RequestMethod method, String path, ApiRequest<?> request, ApiResponse.Builder<?, T> responseBuilder) Invoke a request that is not expected to yield an entity.<T extends ApiResponse>
Single<T>invokeBytesRequest(Http.RequestMethod method, String path, ApiRequest<?> request, Flow.Publisher<DataChunk> byteRequest, ApiResponse.Builder<?, T> responseBuilder) The request media type should be provided in request, falls back toMediaType.APPLICATION_OCTET_STREAM.<R,T extends ApiOptionalResponse<R>>
Single<T>invokeBytesResponse(Http.RequestMethod method, String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?, T, byte[], R> responseBuilder) Invoke API call that is expected to return bytes.<R,T extends ApiOptionalResponse<R>>
Single<T>invokeOptional(Http.RequestMethod method, String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?, T, JsonObject, R> responseBuilder) Invoke a request that may yield an entity.<R,T extends ApiOptionalResponse<R>>
Single<T>invokePublisherResponse(Http.RequestMethod method, String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?, T, Multi<DataChunk>, R> responseBuilder) Invoke API call that is expected to return bytes as a publisher.<T extends ApiEntityResponse>
Single<T>invokeWithResponse(Http.RequestMethod method, String path, ApiRequest<?> request, ApiEntityResponse.Builder<?, T, JsonObject> responseBuilder) Invoke a request that is expected to yield an entity.default <T extends ApiResponse>
Single<T>post(String path, ApiRequest<?> request, ApiResponse.Builder<?, T> responseBuilder) Post without a response entity.default <T extends ApiResponse>
Single<T>put(String path, ApiRequest<?> request, ApiResponse.Builder<?, T> responseBuilder) Put without a response entity.
-
Method Details
-
get
default <R,T extends ApiOptionalResponse<R>> Single<T> get(String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?, T, JsonObject, R> responseBuilder) Get with an optional response. In case the call returnsHttp.Status.NOT_FOUND_404this would return an empty optional entity, rather than fail. This may also be the case for requests that useIf-Modified-Sincethat return aHttp.Status.NOT_MODIFIED_304response code.- Type Parameters:
R- type of the optional part of the responseT- type of the response- Parameters:
path- path to invokerequest- request to useresponseBuilder- builder with appropriate response processor- Returns:
- future with response if successful or not found, future with error otherwise
-
getPublisher
default <R,T extends ApiOptionalResponse<R>> Single<T> getPublisher(String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?, T, Multi<DataChunk>, R> responseBuilder) Get with a response consisting of a stream.- Type Parameters:
R- type of the optional part of the responseT- type of the response- Parameters:
path- path to invokerequest- request to useresponseBuilder- builder with appropriate response processor- Returns:
- future with response if successful or not found, future with error otherwise
-
getBytes
default <R,T extends ApiOptionalResponse<R>> Single<T> getBytes(String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?, T, byte[], R> responseBuilder) Get bytes with an optional response.- Type Parameters:
R- type of the optional part of the responseT- type of the response- Parameters:
path- path to invokerequest- request to useresponseBuilder- builder with appropriateApiOptionalResponse.BuilderBase.entityProcessor(java.util.function.Function)- Returns:
- future with the response, that may or may not contain an entity (for 404 the entity would be empty)
-
post
default <T extends ApiResponse> Single<T> post(String path, ApiRequest<?> request, ApiResponse.Builder<?, T> responseBuilder) Post without a response entity.- Type Parameters:
T- type of the response- Parameters:
path- path to invokerequest- request to use, should be an instance ofApiJsonRequestif an entity is desiredresponseBuilder- builder to construct response from API call- Returns:
- future with metadata if successful, future with error otherwise
-
put
default <T extends ApiResponse> Single<T> put(String path, ApiRequest<?> request, ApiResponse.Builder<?, T> responseBuilder) Put without a response entity.- Type Parameters:
T- type of the response- Parameters:
path- path to invokerequest- request to use, should be an instance ofApiJsonRequestif an entity is desiredresponseBuilder- builder to construct response from API call- Returns:
- future with metadata if successful, future with error otherwise
-
delete
default <T extends ApiResponse> Single<T> delete(String path, ApiRequest<?> request, ApiResponse.Builder<?, T> responseBuilder) Delete without a response entity.- Type Parameters:
T- type of the response- Parameters:
path- path to invokerequest- request to use, should be an instance ofApiJsonRequestif an entity is desiredresponseBuilder- builder to construct response from API call- Returns:
- future with metadata if successful, future with error otherwise
-
invoke
<T extends ApiResponse> Single<T> invoke(Http.RequestMethod method, String path, ApiRequest<?> request, ApiResponse.Builder<?, T> responseBuilder) Invoke a request that is not expected to yield an entity.- Type Parameters:
T- type of the response- Parameters:
method- HTTP method to invokepath- path to invokerequest- request to use, should be an instance ofApiJsonRequestif and entity is desiredresponseBuilder- builder to construct response from API call- Returns:
- future with metadata if successful. future with error otherwise
-
invokeWithResponse
<T extends ApiEntityResponse> Single<T> invokeWithResponse(Http.RequestMethod method, String path, ApiRequest<?> request, ApiEntityResponse.Builder<?, T, JsonObject> responseBuilder) Invoke a request that is expected to yield an entity.- Type Parameters:
T- type of the response- Parameters:
method- HTTP method to invokepath- path to invokerequest- request to use, should be an instance ofApiJsonRequestif and entity is desiredresponseBuilder- builder to construct response from API call- Returns:
- future with entity and metadata if successful, future with error otherwise
-
invokeBytesRequest
<T extends ApiResponse> Single<T> invokeBytesRequest(Http.RequestMethod method, String path, ApiRequest<?> request, Flow.Publisher<DataChunk> byteRequest, ApiResponse.Builder<?, T> responseBuilder) The request media type should be provided in request, falls back toMediaType.APPLICATION_OCTET_STREAM.- Type Parameters:
T- type of the response- Parameters:
method- method to invokepath- path to invokerequest- request used to configure query parameters and headersbyteRequest- bytes of the entityresponseBuilder- builder to construct response from API call- Returns:
- future with the response or error
-
invokePublisherResponse
<R,T extends ApiOptionalResponse<R>> Single<T> invokePublisherResponse(Http.RequestMethod method, String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?, T, Multi<DataChunk>, R> responseBuilder) Invoke API call that is expected to return bytes as a publisher. The accepted media type must be provided in request, falls back toMediaType.APPLICATION_OCTET_STREAM.- Type Parameters:
R- type of the optional part of the responseT- type of the response- Parameters:
method- method to invokepath- path to invokerequest- request used to configure query parameters and headersresponseBuilder- builder to construct response from API call with appropriate processor to handle the returned publisher- Returns:
- future with the response
-
invokeBytesResponse
<R,T extends ApiOptionalResponse<R>> Single<T> invokeBytesResponse(Http.RequestMethod method, String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?, T, byte[], R> responseBuilder) Invoke API call that is expected to return bytes. This method collects all bytes in memory, so it cannot be used for large data. SeeinvokePublisherResponse(io.helidon.common.http.Http.RequestMethod, String, ApiRequest, io.helidon.integrations.common.rest.ApiOptionalResponse.BuilderBase). The accepted media type must be provided in request, falls back toMediaType.APPLICATION_OCTET_STREAM.- Type Parameters:
R- type of the optional part of the responseT- type of the response- Parameters:
method- method to invokepath- path to invokerequest- request used to configure query parameters and headersresponseBuilder- builder to construct response from API call with appropriate processor to handle the returned bytes- Returns:
- future with the response
-
invokeOptional
<R,T extends ApiOptionalResponse<R>> Single<T> invokeOptional(Http.RequestMethod method, String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?, T, JsonObject, R> responseBuilder) Invoke a request that may yield an entity. The entity is expected to be missing ifHttp.Status.NOT_FOUND_404is returned by the API call (and for some other cases, such as not modified).- Type Parameters:
R- type of the optional part of the responseT- type of the response- Parameters:
method- HTTP method to invokepath- path to invokerequest- request to use, should be an instance ofApiJsonRequestif and entity is desiredresponseBuilder- response builder with appropriate processor to create the optional part- Returns:
- future with optional entity, and metadata if successful; future with error otherwise
-