public static QuotaResource fromRestRequest(RestRequest restRequest) throws QuotaException {
    try {
      final Account account = RestUtils.getAccountFromArgs(restRequest.getArgs());
      if (account.getQuotaResourceType() == QuotaResourceType.ACCOUNT) {
        return QuotaResource.fromAccountId(account.getId());
      }
      Container container = RestUtils.getContainerFromArgs(restRequest.getArgs());
      return QuotaResource.fromContainerId(account.getId(), container.getId());
    } catch (RestServiceException rEx) {
      LOGGER.error("Could not get quota resource for request: {} due to {}", RestUtils.convertToStr(restRequest),
          rEx.getMessage());
      throw new QuotaException("Could not get quota resource for request: " + RestUtils.convertToStr(restRequest),
          false);
    }
  }
Create {@link QuotaResource} for the specified {@link RestRequest}.
@param restRequest {@link RestRequest} object.
@return QuotaResource extracted from headers of {@link RestRequest}.
@throws QuotaException if appropriate headers aren't found in the {@link RestRequest}.
ambry-api/src/main/java/com/github/ambry/quota/QuotaResource.java