public interface QuotaBackend
DefaultQuotaBackend
which calls all plugins that implement QuotaEnforcer
. A different
implementation might be bound in tests. Plugins are not supposed to implement this interface, but
bind a QuotaEnforcer
implementation instead.
All quota requests require a quota group and a user. Enriching them with a top-level entity
Change, Project, Account
is optional but should be done if the request is targeted.
Example usage:
quotaBackend.currentUser().project(projectName).requestToken("/projects/create").throwOnError(); quotaBackend.user(user).requestToken("/restapi/config/put").throwOnError(); QuotaResponse.Aggregated result = quotaBackend.currentUser().account(accountId).requestToken("/restapi/accounts/emails/validate"); QuotaResponse.Aggregated result = quotaBackend.currentUser().project(projectName).requestTokens("/projects/git/upload", numBytesInPush);
All quota groups must be documented in quota.txt
and detail the metadata that is
provided (i.e. the parameters used to scope down the quota request).
Modifier and Type | Interface and Description |
---|---|
static interface |
QuotaBackend.WithResource
An interface capable of issuing quota requests.
|
static interface |
QuotaBackend.WithUser
An interface capable of issuing quota requests.
|
Modifier and Type | Method and Description |
---|---|
QuotaBackend.WithUser |
currentUser()
Constructs a request for the current user.
|
QuotaBackend.WithUser |
user(CurrentUser user)
See
currentUser() . |
QuotaBackend.WithUser currentUser()
QuotaBackend.WithUser user(CurrentUser user)
currentUser()
. Use this method only if you can't guarantee that the request is for
the current user (e.g. impersonation).