in src/api-server/src/main/java/com/google/abmedge/apiserver/ApiServerController.java [124:147]
public ResponseEntity<String> types() {
String itemsEndpoint = INVENTORY_SERVICE + TYPES_EP;
try {
HttpRequest request = HttpRequest.newBuilder().GET().uri(URI.create(itemsEndpoint)).build();
HttpResponse<String> response =
HTTP_CLIENT.send(request, HttpResponse.BodyHandlers.ofString());
int statusCode = response.statusCode();
if (statusCode == HttpStatus.OK.value() || statusCode == HttpStatus.NO_CONTENT.value()) {
String responseTypes = response.body();
LOGGER.info(
String.format(
"Inventory service response for endpoint '%s' is: \n%s",
itemsEndpoint, responseTypes));
return new ResponseEntity<>(responseTypes, HttpStatus.OK);
}
LOGGER.error(
String.format(
"Failed to fetch store types from '%s'. Status code '%s'",
itemsEndpoint, statusCode));
} catch (IOException | InterruptedException e) {
LOGGER.error(String.format("Failed to fetch store types from '%s'", itemsEndpoint), e);
}
return new ResponseEntity<>(FAILED, HttpStatus.INTERNAL_SERVER_ERROR);
}