private Collection<Account> getAccounts() throws RestServiceException {
      Short id = RestUtils.getNumericalHeader(restRequest.getArgs(), RestUtils.Headers.TARGET_ACCOUNT_ID, false,
          Short::parseShort);
      String name = RestUtils.getHeader(restRequest.getArgs(), RestUtils.Headers.TARGET_ACCOUNT_NAME, false);
      Collection<Account> accounts;
      if (id != null && name != null) {
        throw new RestServiceException("Cannot supply both account ID and account name in request",
            RestServiceErrorCode.BadRequest);
      } else if (id == null && name == null) {
        accounts = accountService.getAllAccounts();
      } else {
        Account account = id != null ? accountService.getAccountById(id) : accountService.getAccountByName(name);
        if (account == null) {
          throw new RestServiceException("Account not found: " + (id != null ? "id=" + id : "name=" + name),
              RestServiceErrorCode.NotFound);
        }
        accounts = Collections.singleton(account);
      }
      return accounts;
    }
Get the accounts to return in the response. This method will check the
{@link RestUtils.Headers#TARGET_ACCOUNT_ID} and {@link RestUtils.Headers#TARGET_ACCOUNT_NAME} request arguments.
If either of those arguments is set in the request, this will return the account with the respective id or name.
If neither is set in the request, this will return all accounts that this frontend knows about.
@return a {@link Collection} of {@link Account}s.
@throws RestServiceException If both the account ID and name arguments are set or if the requested account was
                             not found.
ambry-frontend/src/main/java/com/github/ambry/frontend/GetAccountsHandler.java