Add SDNR A1 client in policy-agent
[nonrtric.git] / policy-agent / src / main / java / org / oransc / policyagent / clients / AsyncRestClient.java
index 2574217..b10cf27 100644 (file)
@@ -49,7 +49,19 @@ public class AsyncRestClient {
         return client.post() //
             .uri(uri) //
             .contentType(MediaType.APPLICATION_JSON) //
-            .syncBody(body) //
+            .bodyValue(body) //
+            .retrieve() //
+            .onStatus(HttpStatus::isError,
+                response -> Mono.error(new AsyncRestClientException(response.statusCode().toString()))) //
+            .bodyToMono(String.class);
+    }
+
+    public Mono<String> postWithAuthHeader(String uri, String body, String username, String password) {
+        return client.post() //
+            .uri(uri) //
+            .headers(headers -> headers.setBasicAuth(username, password)) //
+            .contentType(MediaType.APPLICATION_JSON) //
+            .bodyValue(body) //
             .retrieve() //
             .onStatus(HttpStatus::isError,
                 response -> Mono.error(new AsyncRestClientException(response.statusCode().toString()))) //
@@ -61,7 +73,7 @@ public class AsyncRestClient {
         return client.put() //
             .uri(uri) //
             .contentType(MediaType.APPLICATION_JSON) //
-            .syncBody(body) //
+            .bodyValue(body) //
             .retrieve() //
             .onStatus(HttpStatus::isError,
                 response -> Mono.error(new AsyncRestClientException(response.statusCode().toString()))) //