Class SimpleEndpoint<RequestT,ResponseT>
java.lang.Object
co.elastic.clients.transport.endpoints.SimpleEndpoint<RequestT,ResponseT>
- All Implemented Interfaces:
Endpoint<RequestT,ResponseT,ErrorResponse>
,JsonEndpoint<RequestT,ResponseT,ErrorResponse>
- Direct Known Subclasses:
BooleanEndpoint
public class SimpleEndpoint<RequestT,ResponseT> extends java.lang.Object implements JsonEndpoint<RequestT,ResponseT,ErrorResponse>
-
Constructor Summary
Constructors Constructor Description SimpleEndpoint(java.lang.String id, java.util.function.Function<RequestT,java.lang.String> method, java.util.function.Function<RequestT,java.lang.String> requestUrl, java.util.function.Function<RequestT,java.util.Map<java.lang.String,java.lang.String>> queryParameters, java.util.function.Function<RequestT,java.util.Map<java.lang.String,java.lang.String>> headers, boolean hasRequestBody, JsonpDeserializer<ResponseT> responseParser)
-
Method Summary
Modifier and Type Method Description static <T> java.util.function.Function<T,java.util.Map<java.lang.String,java.lang.String>>
emptyMap()
Returns a function that always returns an empty String to String map.JsonpDeserializer<ErrorResponse>
errorDeserializer(int statusCode)
The entity parser for the error response body.boolean
hasRequestBody()
java.util.Map<java.lang.String,java.lang.String>
headers(RequestT request)
Get the HTTP headers for a request.java.lang.String
id()
The endpoint's identifier.boolean
isError(int statusCode)
Is this status code to be considered as an error?java.lang.String
method(RequestT request)
Get the endpoint's HTTP method for a request.static java.lang.RuntimeException
noPathTemplateFound(java.lang.String what)
static void
pathEncode(java.lang.String src, java.lang.StringBuilder dest)
java.util.Map<java.lang.String,java.lang.String>
queryParameters(RequestT request)
Get the query parameters for a request.java.lang.String
requestUrl(RequestT request)
Get the URL path for a request.JsonpDeserializer<ResponseT>
responseDeserializer()
The entity parser for the response body.<NewResponseT>
SimpleEndpoint<RequestT,NewResponseT>withResponseDeserializer(JsonpDeserializer<NewResponseT> newResponseParser)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
SimpleEndpoint
public SimpleEndpoint(java.lang.String id, java.util.function.Function<RequestT,java.lang.String> method, java.util.function.Function<RequestT,java.lang.String> requestUrl, java.util.function.Function<RequestT,java.util.Map<java.lang.String,java.lang.String>> queryParameters, java.util.function.Function<RequestT,java.util.Map<java.lang.String,java.lang.String>> headers, boolean hasRequestBody, JsonpDeserializer<ResponseT> responseParser)
-
-
Method Details
-
emptyMap
public static <T> java.util.function.Function<T,java.util.Map<java.lang.String,java.lang.String>> emptyMap()Returns a function that always returns an empty String to String map. Useful to avoid creating lots of duplicate lambdas in endpoints that don't have headers or parameters. -
id
public java.lang.String id()Description copied from interface:Endpoint
The endpoint's identifier.- Specified by:
id
in interfaceEndpoint<RequestT,ResponseT,ErrorResponse>
-
method
Description copied from interface:Endpoint
Get the endpoint's HTTP method for a request.- Specified by:
method
in interfaceEndpoint<RequestT,ResponseT,ErrorResponse>
-
requestUrl
Description copied from interface:Endpoint
Get the URL path for a request.- Specified by:
requestUrl
in interfaceEndpoint<RequestT,ResponseT,ErrorResponse>
-
queryParameters
Description copied from interface:Endpoint
Get the query parameters for a request.- Specified by:
queryParameters
in interfaceEndpoint<RequestT,ResponseT,ErrorResponse>
-
headers
Description copied from interface:Endpoint
Get the HTTP headers for a request.- Specified by:
headers
in interfaceEndpoint<RequestT,ResponseT,ErrorResponse>
-
hasRequestBody
public boolean hasRequestBody()- Specified by:
hasRequestBody
in interfaceEndpoint<RequestT,ResponseT,ErrorResponse>
-
responseDeserializer
Description copied from interface:JsonEndpoint
The entity parser for the response body.- Specified by:
responseDeserializer
in interfaceJsonEndpoint<RequestT,ResponseT,ErrorResponse>
-
isError
public boolean isError(int statusCode)Description copied from interface:Endpoint
Is this status code to be considered as an error?- Specified by:
isError
in interfaceEndpoint<RequestT,ResponseT,ErrorResponse>
-
errorDeserializer
Description copied from interface:Endpoint
The entity parser for the error response body. Can benull
to indicate that there's no error body.- Specified by:
errorDeserializer
in interfaceEndpoint<RequestT,ResponseT,ErrorResponse>
-
withResponseDeserializer
public <NewResponseT> SimpleEndpoint<RequestT,NewResponseT> withResponseDeserializer(JsonpDeserializer<NewResponseT> newResponseParser) -
noPathTemplateFound
public static java.lang.RuntimeException noPathTemplateFound(java.lang.String what) -
pathEncode
public static void pathEncode(java.lang.String src, java.lang.StringBuilder dest)
-