aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-impl/rest/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-impl/rest/src/main/java/org/onap')
-rw-r--r--models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java b/models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java
index 643c629b3..dde3aa2e2 100644
--- a/models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java
+++ b/models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java
@@ -29,6 +29,7 @@ import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPatch;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
@@ -172,6 +173,33 @@ public class RestManager {
}
/**
+ * Perform REST Patch.
+ *
+ * @param url the url
+ * @param username the user name
+ * @param password the password
+ * @param headers any headers
+ * @param body body to send
+ * @return the response status code and the body
+ */
+ public Pair<Integer, String> patch(String url, String username, String password,
+ Map<String, String> headers, String body) {
+ String contentType = "application/merge-patch+json";
+ HttpPatch patch = new HttpPatch(url);
+ addHeaders(patch, username, password, headers);
+ patch.addHeader(CONTENT_TYPE, contentType);
+ try {
+ StringEntity input = new StringEntity(body);
+ input.setContentType(contentType);
+ patch.setEntity(input);
+ } catch (Exception e) {
+ logger.error("patch threw: ", e);
+ return null;
+ }
+ return sendRequest(patch);
+ }
+
+ /**
* Send REST request.
*
* @param request http request to send