aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
diff options
context:
space:
mode:
Diffstat (limited to 'policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java')
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java82
1 files changed, 74 insertions, 8 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
index 2fe46fb3..01deaa2d 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
@@ -2,7 +2,8 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,15 +21,17 @@
package org.onap.policy.common.endpoints.http.client;
+import jakarta.ws.rs.client.Entity;
+import jakarta.ws.rs.client.InvocationCallback;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
import java.util.Map;
-
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Response;
-
+import java.util.concurrent.Future;
import org.onap.policy.common.capabilities.Startable;
/**
- * Http Client interface.
+ * Http Client interface. Supports both synchronous and asynchronous operations.
+ *
*/
public interface HttpClient extends Startable {
@@ -48,6 +51,26 @@ public interface HttpClient extends Startable {
Response get();
/**
+ * Asynchronous GET request.
+ *
+ * @param callback callback to be invoked, asynchronously, when the request completes
+ * @param path context uri path
+ * @param headers request headers
+ *
+ * @return future that can be used to cancel the request or await the response
+ */
+ Future<Response> get(InvocationCallback<Response> callback, String path, Map<String, Object> headers);
+
+ /**
+ * Asynchronous GET request.
+ *
+ * @param callback callback to be invoked, asynchronously, when the request completes
+ * @param headers request headers
+ * @return future that can be used to cancel the request or await the response
+ */
+ Future<Response> get(InvocationCallback<Response> callback, Map<String, Object> headers);
+
+ /**
* PUT request.
*
* @param path context uri path
@@ -59,6 +82,19 @@ public interface HttpClient extends Startable {
Response put(String path, Entity<?> entity, Map<String, Object> headers);
/**
+ * Asynchronous PUT request.
+ *
+ * @param callback callback to be invoked, asynchronously, when the request completes
+ * @param path context uri path
+ * @param entity body
+ * @param headers headers
+ *
+ * @return future that can be used to cancel the request or await the response
+ */
+ Future<Response> put(InvocationCallback<Response> callback, String path, Entity<?> entity,
+ Map<String, Object> headers);
+
+ /**
* POST request.
*
* @param path context uri path
@@ -70,6 +106,19 @@ public interface HttpClient extends Startable {
Response post(String path, Entity<?> entity, Map<String, Object> headers);
/**
+ * Asynchronous POST request.
+ *
+ * @param callback callback to be invoked, asynchronously, when the request completes
+ * @param path context uri path
+ * @param entity body
+ * @param headers headers
+ *
+ * @return future that can be used to cancel the request or await the response
+ */
+ Future<Response> post(InvocationCallback<Response> callback, String path, Entity<?> entity,
+ Map<String, Object> headers);
+
+ /**
* DELETE request.
*
* @param path context uri path
@@ -80,6 +129,17 @@ public interface HttpClient extends Startable {
Response delete(String path, Map<String, Object> headers);
/**
+ * Asynchronous DELETE request.
+ *
+ * @param callback callback to be invoked, asynchronously, when the request completes
+ * @param path context uri path
+ * @param headers headers
+ *
+ * @return future that can be used to cancel the request or await the response
+ */
+ Future<Response> delete(InvocationCallback<Response> callback, String path, Map<String, Object> headers);
+
+ /**
* Retrieve the body from the HTTP transaction.
*
* @param response response.
@@ -134,9 +194,9 @@ public interface HttpClient extends Startable {
String getBasePath();
/**
- * Get the user name.
+ * Get the username.
*
- * @return the user name
+ * @return the username
*/
String getUserName();
@@ -154,4 +214,10 @@ public interface HttpClient extends Startable {
*/
String getBaseUrl();
+ /**
+ * Gets a web target associated with the base URL.
+ *
+ * @return a webtarget
+ */
+ WebTarget getWebTarget();
}