Package org.springframework.vault.client
Interface VaultClient.ResponseSpec
- Enclosing interface:
- VaultClient
public static interface VaultClient.ResponseSpec
Contract for specifying response operations following the exchange.
-
Method Summary
Modifier and TypeMethodDescription@Nullable VaultResponsebody()Extract the body as an object of the given type.<T> @Nullable TExtract the body as an object of the given type.<T> @Nullable Tbody(ParameterizedTypeReference<T> bodyType) Extract the body as an object of the given type.onStatus(Predicate<HttpStatusCode> statusPredicate, RestClient.ResponseSpec.ErrorHandler errorHandler) Provide a function to map specific error status codes to an error handler.Extract the required body as an object of the given type.<T> TrequiredBody(Class<T> bodyType) Extract the required body as an object of the given type.<T> TrequiredBody(ParameterizedTypeReference<T> bodyType) Extract the required body as an object of the given type.Return aResponseEntitywithout a body.default ResponseEntity<VaultResponse>toEntity()Return aResponseEntitywith the body decoded to VaultResponse.<T> ResponseEntity<T>Return aResponseEntitywith the body decoded to an Object of the given type.<T> ResponseEntity<T>toEntity(ParameterizedTypeReference<T> bodyType) Return aResponseEntitywith the body decoded to an Object of the given type.Wrap the response in a cubbyhole token with the requested TTL.
-
Method Details
-
onStatus
VaultClient.ResponseSpec onStatus(Predicate<HttpStatusCode> statusPredicate, RestClient.ResponseSpec.ErrorHandler errorHandler) Provide a function to map specific error status codes to an error handler.By default, if there are no matching status handlers, responses with status codes >= 400 will throw a
VaultClientResponseException.Note that
IOExceptions,UncheckedIOExceptions, andHttpMessageNotReadableExceptionsthrown fromerrorHandlerwill be wrapped in aVaultClientResponseException.- Parameters:
statusPredicate- to match responses witherrorHandler- handler that typically, though not necessarily, throws an exception- Returns:
- this builder
-
wrap
Wrap the response in a cubbyhole token with the requested TTL.- Parameters:
ttl- the time to live for the wrapped response.- Returns:
- the cubbyhole
WrappedMetadataproviding a token and metadata for the wrapped response. - Throws:
VaultClientResponseException- when receiving a response with a status code of 4xx or 5xx.IllegalStateException- if no response body was available.
-
requiredBody
VaultResponse requiredBody()Extract the required body as an object of the given type.- Returns:
- the body or
IllegalStateExceptionif no response body was available. - Throws:
VaultClientResponseException- when receiving a response with a status code of 4xx or 5xx.NoSuchElementException- if no response body was available.
-
body
@Nullable VaultResponse body()Extract the body as an object of the given type.- Returns:
- the body, or
nullif no response body was available. - Throws:
VaultClientResponseException- when receiving a response with a status code of 4xx or 5xx.
-
requiredBody
Extract the required body as an object of the given type.- Returns:
- the body or
IllegalStateExceptionif no response body was available. - Throws:
VaultClientResponseException- when receiving a response with a status code of 4xx or 5xx.NoSuchElementException- if no response body was available.
-
requiredBody
Extract the required body as an object of the given type.- Returns:
- the body or
IllegalStateExceptionif no response body was available. - Throws:
VaultClientResponseException- when receiving a response with a status code of 4xx or 5xx.NoSuchElementException- if no response body was available.
-
body
Extract the body as an object of the given type.- Type Parameters:
T- the body type.- Parameters:
bodyType- the type of return value.- Returns:
- the body, or
nullif no response body was available - Throws:
VaultClientResponseException- when receiving a response with a status code of 4xx or 5xx.
-
body
Extract the body as an object of the given type.- Type Parameters:
T- the body type.- Parameters:
bodyType- the type of return value.- Returns:
- the body, or
nullif no response body was available. - Throws:
VaultClientResponseException- when receiving a response with a status code of 4xx or 5xx.
-
toEntity
Return aResponseEntitywith the body decoded to VaultResponse.- Returns:
- the
ResponseEntitywith the decoded body. - Throws:
VaultClientResponseException- when receiving a response with a status code of 4xx or 5xx.
-
toEntity
Return aResponseEntitywith the body decoded to an Object of the given type.- Type Parameters:
T- response body type.- Parameters:
bodyType- the expected response body type.- Returns:
- the
ResponseEntitywith the decoded body - Throws:
VaultClientResponseException- when receiving a response with a status code of 4xx or 5xx.
-
toEntity
Return aResponseEntitywith the body decoded to an Object of the given type.- Type Parameters:
T- response body type.- Parameters:
bodyType- the expected response body type.- Returns:
- the
ResponseEntitywith the decoded body. - Throws:
VaultClientResponseException- when receiving a response with a status code of 4xx or 5xx.
-
toBodilessEntity
ResponseEntity<Void> toBodilessEntity()Return aResponseEntitywithout a body.- Returns:
- the
ResponseEntity. - Throws:
VaultClientResponseException- when receiving a response with a status code of 4xx or 5xx.
-