Class ProxiedResource.NodeResponse<ResponseType>
java.lang.Object
org.graylog2.shared.rest.resources.ProxiedResource.NodeResponse<ResponseType>
- Enclosing class:
- ProxiedResource
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbody()
Convenience method that returns either the body of a successful request or if that one isnull
, it returns the error body.abstract int
code()
Returns the HTTP status code of the response.static <ResponseType>
ProxiedResource.NodeResponse<ResponseType>create
(boolean isSuccess, int code, ResponseType entity, byte[] error) abstract Optional<ResponseType>
entity()
Returns the typed response object if the request was successful.abstract Optional<byte[]>
error()
Returns the error response if the request wasn't successful.abstract boolean
Indicates whether the request has been successful or not.
-
Constructor Details
-
NodeResponse
public NodeResponse()
-
-
Method Details
-
isSuccess
public abstract boolean isSuccess()Indicates whether the request has been successful or not.- Returns:
true
for a successful request,false
otherwise
-
code
public abstract int code()Returns the HTTP status code of the response.- Returns:
- HTTP status code
-
entity
Returns the typed response object if the request was successful. Otherwise it returns an emptyOptional
.- Returns:
- typed response object or empty
Optional
-
error
Returns the error response if the request wasn't successful. Otherwise it returns an emptyOptional
.- Returns:
- error response or empty
Optional
-
body
Convenience method that returns either the body of a successful request or if that one isnull
, it returns the error body.Use
entity()
the get the typed response object. (only available ifisSuccess()
istrue
) -
errorText
-
create
public static <ResponseType> ProxiedResource.NodeResponse<ResponseType> create(boolean isSuccess, int code, @Nullable ResponseType entity, @Nullable byte[] error)
-