Search in sources :

Example 31 with HttpRequest

use of com.azure.core.http.HttpRequest in project lowkey-vault by nagyesta.

the class LowkeyVaultManagementClientImpl method timeShift.

@Override
public void timeShift(@NonNull final TimeShiftContext context) {
    final Map<String, String> parameters = new TreeMap<>();
    parameters.put(SECONDS_QUERY_PARAM, Integer.toString(context.getSeconds()));
    final Optional<URI> optionalURI = Optional.ofNullable(context.getVaultBaseUri());
    optionalURI.ifPresent(uri -> parameters.put(BASE_URI_QUERY_PARAM, uri.toString()));
    final String path = optionalURI.map(u -> MANAGEMENT_VAULT_TIME_PATH).orElse(MANAGEMENT_VAULT_TIME_ALL_PATH);
    final URI uri = UriUtil.uriBuilderForPath(vaultUrl, path, parameters);
    final HttpRequest request = new HttpRequest(HttpMethod.PUT, uri.toString()).setHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON);
    sendRaw(request);
}
Also used : HttpResponse(com.azure.core.http.HttpResponse) java.util(java.util) GZIPInputStream(java.util.zip.GZIPInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Nullable(reactor.util.annotation.Nullable) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) APPLICATION_JSON(com.azure.core.http.ContentType.APPLICATION_JSON) ByteArrayInputStream(java.io.ByteArrayInputStream) com.github.nagyesta.lowkeyvault.http.management(com.github.nagyesta.lowkeyvault.http.management) URI(java.net.URI) HttpHeaders(org.apache.http.HttpHeaders) VAULT_MODEL_LIST_TYPE_REF(com.github.nagyesta.lowkeyvault.http.management.impl.ResponseEntity.VAULT_MODEL_LIST_TYPE_REF) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) NonNull(lombok.NonNull) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) StandardCharsets(java.nio.charset.StandardCharsets) Slf4j(lombok.extern.slf4j.Slf4j) HttpRequest(com.azure.core.http.HttpRequest) HttpClient(com.azure.core.http.HttpClient) HttpMethod(com.azure.core.http.HttpMethod) GZIPOutputStream(java.util.zip.GZIPOutputStream) HttpRequest(com.azure.core.http.HttpRequest) URI(java.net.URI)

Aggregations

HttpRequest (com.azure.core.http.HttpRequest)31 Test (org.junit.jupiter.api.Test)13 HttpMethod (com.azure.core.http.HttpMethod)9 HttpResponse (com.azure.core.http.HttpResponse)9 HttpClient (com.azure.core.http.HttpClient)8 URI (java.net.URI)8 URL (java.net.URL)8 HttpHeaders (com.azure.core.http.HttpHeaders)7 IOException (java.io.IOException)7 Mono (reactor.core.publisher.Mono)7 Date (java.util.Date)6 QuarkusUnitTest (io.quarkus.test.QuarkusUnitTest)5 StandardCharsets (java.nio.charset.StandardCharsets)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 HttpPipeline (com.azure.core.http.HttpPipeline)3 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)3 WireMock (com.github.tomakehurst.wiremock.client.WireMock)3 WireMockConfiguration (com.github.tomakehurst.wiremock.core.WireMockConfiguration)3 Duration (java.time.Duration)3 HashMap (java.util.HashMap)3