public ResponseEntity items()

in src/api-server/src/main/java/com/google/abmedge/apiserver/ApiServerController.java [99:121]


  public ResponseEntity<String> items() {
    String itemsEndpoint = INVENTORY_SERVICE + ITEMS_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 responseItems = response.body();
        LOGGER.info(
            String.format(
                "Inventory service response for endpoint '%s' is: \n%s",
                itemsEndpoint, responseItems));
        return new ResponseEntity<>(responseItems, HttpStatus.OK);
      }
      LOGGER.error(
          String.format(
              "Failed to fetch items list from '%s'. Status code '%s'", itemsEndpoint, statusCode));
    } catch (IOException | InterruptedException e) {
      LOGGER.error(String.format("Failed to fetch items list from '%s'", itemsEndpoint), e);
    }
    return new ResponseEntity<>(FAILED, HttpStatus.INTERNAL_SERVER_ERROR);
  }