- final String jsonData,
- final HttpHeaders httpHeaders) {
- final var httpEntity = new HttpEntity<>(jsonData, configureHttpHeaders(httpHeaders));
- return restTemplate.postForEntity(dmiResourceUrl, httpEntity, Object.class);
+ final String requestBodyAsJsonString,
+ final OperationType operationType) {
+ final var httpEntity = new HttpEntity<>(requestBodyAsJsonString, configureHttpHeaders(new HttpHeaders()));
+ try {
+ return restTemplate.postForEntity(dmiResourceUrl, httpEntity, Object.class);
+ } catch (final HttpStatusCodeException httpStatusCodeException) {
+ final String exceptionMessage = "Unable to " + operationType.toString() + " resource data.";
+ throw new HttpClientRequestException(exceptionMessage, httpStatusCodeException.getResponseBodyAsString(),
+ httpStatusCodeException.getStatusCode().value());
+ }
+ }
+
+ /**
+ * Sends GET operation to DMI plugin's health check URL.
+ *
+ * @param dmiPluginBaseUrl the base URL of the dmi-plugin
+ * @return DmiPluginStatus as UP or DOWN
+ */
+ public DmiPluginStatus getDmiPluginStatus(final String dmiPluginBaseUrl) {
+ try {
+ final HttpEntity<Object> httpHeaders = new HttpEntity<>(configureHttpHeaders(new HttpHeaders()));
+ final JsonNode dmiPluginHealthStatus = restTemplate.getForObject(dmiPluginBaseUrl + "/manage/health",
+ JsonNode.class, httpHeaders);
+ if (dmiPluginHealthStatus != null) {
+ if (dmiPluginHealthStatus.get("status").asText().equals("UP")) {
+ return DmiPluginStatus.UP;
+ }
+ }
+ } catch (final Exception exception) {
+ log.warn("Could not send request for health check since {}", exception.getMessage());
+ }
+ return DmiPluginStatus.DOWN;