- public DmiRestClient(final RestTemplate restTemplate, final DmiProperties dmiProperties) {
- this.restTemplate = restTemplate;
- this.dmiProperties = dmiProperties;
+ public ResponseEntity<Object> postOperationWithJsonData(final String dmiResourceUrl,
+ 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());
+ }