summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java
diff options
context:
space:
mode:
authorDylanB95EST <dylan.byrne@est.tech>2021-11-09 13:54:35 +0000
committerDylanB95EST <dylan.byrne@est.tech>2021-11-12 15:24:27 +0000
commit5fe0daebb1360bd5d4c525125cdb0d6250583ff4 (patch)
tree3c0e08b48627b9c7c4c20c0291c6290673f061fb /src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java
parent306cadd63b69274afbb3073d35a15381a12d6389 (diff)
Support Update and Delete operations for DS Passtrough-Running in DMI Plugin
-Add Update operation for Passthrough Running -Use POST operatiosn for all methods as agrred -refactor to simplify and beter reuse of common methods -add delete operation for passthrough running Issue-ID: CPS-637 Issue-ID: CPS-638 Change-Id: I441181f977dee2bc0be944662465d868595ea452 Signed-off-by: DylanB95EST <dylan.byrne@est.tech>
Diffstat (limited to 'src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java')
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java b/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java
index b8e33dfc..cf7b4599 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java
@@ -57,28 +57,30 @@ public class SdncRestconfClient {
* @return the response entity
*/
public ResponseEntity<String> getOperation(final String getResourceUrl, final HttpHeaders httpHeaders) {
- final String sdncBaseUrl = sdncProperties.getBaseUrl();
- final String sdncRestconfUrl = sdncBaseUrl.concat(getResourceUrl);
- httpHeaders.setBasicAuth(sdncProperties.getAuthUsername(), sdncProperties.getAuthPassword());
- final var httpEntity = new HttpEntity<>(httpHeaders);
- return restTemplate.exchange(sdncRestconfUrl,
- HttpMethod.GET, httpEntity, String.class);
+ return httpOperationWithJsonData(HttpMethod.GET, getResourceUrl, null, httpHeaders);
}
/**
- * restconf post operation on sdnc.
+ * restconf http operations on sdnc.
*
- * @param postResourceUrl sdnc post resource url
- * @param jsonData json data
- * @param httpHeaders HTTP headers
- * @return the response entity
+ * @param httpMethod HTTP Method
+ * @param resourceUrl sdnc resource url
+ * @param jsonData json data
+ * @param httpHeaders HTTP Headers
+ * @return response entity
*/
- public ResponseEntity<String> postOperationWithJsonData(final String postResourceUrl,
- final String jsonData, final HttpHeaders httpHeaders) {
- final var sdncBaseUrl = sdncProperties.getBaseUrl();
- final var sdncRestconfUrl = sdncBaseUrl.concat(postResourceUrl);
+ public ResponseEntity<String> httpOperationWithJsonData(final HttpMethod httpMethod, final String resourceUrl,
+ final String jsonData,
+ final HttpHeaders httpHeaders) {
+ final String sdncBaseUrl = sdncProperties.getBaseUrl();
+ final String sdncRestconfUrl = sdncBaseUrl.concat(resourceUrl);
httpHeaders.setBasicAuth(sdncProperties.getAuthUsername(), sdncProperties.getAuthPassword());
- final var httpEntity = new HttpEntity<>(jsonData, httpHeaders);
- return restTemplate.exchange(sdncRestconfUrl, HttpMethod.POST, httpEntity, String.class);
+ final HttpEntity<String> httpEntity;
+ if (jsonData == null) {
+ httpEntity = new HttpEntity<>(httpHeaders);
+ } else {
+ httpEntity = new HttpEntity<>(jsonData, httpHeaders);
+ }
+ return restTemplate.exchange(sdncRestconfUrl, httpMethod, httpEntity, String.class);
}
-} \ No newline at end of file
+}