public static final class Quota.Builder extends GeneratedMessageV3.Builder<Quota.Builder> implements QuotaOrBuilder
Quota configuration helps to achieve fairness and budgeting in service
usage.
The metric based quota configuration works this way:
- The service configuration defines a set of metrics.
- For API calls, the quota.metric_rules maps methods to metrics with
corresponding costs.
- The quota.limits defines limits on the metrics, which will be used for
quota checks at runtime.
An example quota configuration in yaml format:
quota:
limits:
- name: apiWriteQpsPerProject
metric: library.googleapis.com/write_calls
unit: "1/min/{project}" # rate limit for consumer projects
values:
STANDARD: 10000
(The metric rules bind all methods to the read_calls metric,
except for the UpdateBook and DeleteBook methods. These two methods
are mapped to the write_calls metric, with the UpdateBook method
consuming at twice rate as the DeleteBook method.)
metric_rules:
- selector: "*"
metric_costs:
library.googleapis.com/read_calls: 1
- selector: google.example.library.v1.LibraryService.UpdateBook
metric_costs:
library.googleapis.com/write_calls: 2
- selector: google.example.library.v1.LibraryService.DeleteBook
metric_costs:
library.googleapis.com/write_calls: 1
Corresponding Metric definition:
metrics:
- name: library.googleapis.com/read_calls
display_name: Read requests
metric_kind: DELTA
value_type: INT64
- name: library.googleapis.com/write_calls
display_name: Write requests
metric_kind: DELTA
value_type: INT64
Protobuf type google.api.Quota
Inherited Members
com.google.protobuf.GeneratedMessageV3.Builder.getUnknownFieldSetBuilder()
com.google.protobuf.GeneratedMessageV3.Builder.mergeUnknownLengthDelimitedField(int,com.google.protobuf.ByteString)
com.google.protobuf.GeneratedMessageV3.Builder.mergeUnknownVarintField(int,int)
com.google.protobuf.GeneratedMessageV3.Builder.parseUnknownField(com.google.protobuf.CodedInputStream,com.google.protobuf.ExtensionRegistryLite,int)
com.google.protobuf.GeneratedMessageV3.Builder.setUnknownFieldSetBuilder(com.google.protobuf.UnknownFieldSet.Builder)
Static Methods
getDescriptor()
public static final Descriptors.Descriptor getDescriptor()
Methods
addAllLimits(Iterable<? extends QuotaLimit> values)
public Quota.Builder addAllLimits(Iterable<? extends QuotaLimit> values)
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
Parameter |
---|
Name | Description |
values | Iterable<? extends com.google.api.QuotaLimit>
|
addAllMetricRules(Iterable<? extends MetricRule> values)
public Quota.Builder addAllMetricRules(Iterable<? extends MetricRule> values)
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
Parameter |
---|
Name | Description |
values | Iterable<? extends com.google.api.MetricRule>
|
addLimits(QuotaLimit value)
public Quota.Builder addLimits(QuotaLimit value)
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
addLimits(QuotaLimit.Builder builderForValue)
public Quota.Builder addLimits(QuotaLimit.Builder builderForValue)
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
addLimits(int index, QuotaLimit value)
public Quota.Builder addLimits(int index, QuotaLimit value)
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
addLimits(int index, QuotaLimit.Builder builderForValue)
public Quota.Builder addLimits(int index, QuotaLimit.Builder builderForValue)
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
addLimitsBuilder()
public QuotaLimit.Builder addLimitsBuilder()
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
addLimitsBuilder(int index)
public QuotaLimit.Builder addLimitsBuilder(int index)
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
Parameter |
---|
Name | Description |
index | int
|
addMetricRules(MetricRule value)
public Quota.Builder addMetricRules(MetricRule value)
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
addMetricRules(MetricRule.Builder builderForValue)
public Quota.Builder addMetricRules(MetricRule.Builder builderForValue)
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
addMetricRules(int index, MetricRule value)
public Quota.Builder addMetricRules(int index, MetricRule value)
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
addMetricRules(int index, MetricRule.Builder builderForValue)
public Quota.Builder addMetricRules(int index, MetricRule.Builder builderForValue)
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
addMetricRulesBuilder()
public MetricRule.Builder addMetricRulesBuilder()
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
addMetricRulesBuilder(int index)
public MetricRule.Builder addMetricRulesBuilder(int index)
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
Parameter |
---|
Name | Description |
index | int
|
addRepeatedField(Descriptors.FieldDescriptor field, Object value)
public Quota.Builder addRepeatedField(Descriptors.FieldDescriptor field, Object value)
Overrides
build()
Returns |
---|
Type | Description |
Quota | |
buildPartial()
public Quota buildPartial()
Returns |
---|
Type | Description |
Quota | |
clear()
public Quota.Builder clear()
Overrides
clearField(Descriptors.FieldDescriptor field)
public Quota.Builder clearField(Descriptors.FieldDescriptor field)
Overrides
clearLimits()
public Quota.Builder clearLimits()
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
clearMetricRules()
public Quota.Builder clearMetricRules()
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
clearOneof(Descriptors.OneofDescriptor oneof)
public Quota.Builder clearOneof(Descriptors.OneofDescriptor oneof)
Overrides
clone()
public Quota.Builder clone()
Overrides
getDefaultInstanceForType()
public Quota getDefaultInstanceForType()
Returns |
---|
Type | Description |
Quota | |
getDescriptorForType()
public Descriptors.Descriptor getDescriptorForType()
Overrides
getLimits(int index)
public QuotaLimit getLimits(int index)
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
Parameter |
---|
Name | Description |
index | int
|
getLimitsBuilder(int index)
public QuotaLimit.Builder getLimitsBuilder(int index)
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
Parameter |
---|
Name | Description |
index | int
|
getLimitsBuilderList()
public List<QuotaLimit.Builder> getLimitsBuilderList()
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
getLimitsCount()
public int getLimitsCount()
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
Returns |
---|
Type | Description |
int | |
getLimitsList()
public List<QuotaLimit> getLimitsList()
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
getLimitsOrBuilder(int index)
public QuotaLimitOrBuilder getLimitsOrBuilder(int index)
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
Parameter |
---|
Name | Description |
index | int
|
getLimitsOrBuilderList()
public List<? extends QuotaLimitOrBuilder> getLimitsOrBuilderList()
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
Returns |
---|
Type | Description |
List<? extends com.google.api.QuotaLimitOrBuilder> | |
getMetricRules(int index)
public MetricRule getMetricRules(int index)
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
Parameter |
---|
Name | Description |
index | int
|
getMetricRulesBuilder(int index)
public MetricRule.Builder getMetricRulesBuilder(int index)
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
Parameter |
---|
Name | Description |
index | int
|
getMetricRulesBuilderList()
public List<MetricRule.Builder> getMetricRulesBuilderList()
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
getMetricRulesCount()
public int getMetricRulesCount()
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
Returns |
---|
Type | Description |
int | |
getMetricRulesList()
public List<MetricRule> getMetricRulesList()
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
getMetricRulesOrBuilder(int index)
public MetricRuleOrBuilder getMetricRulesOrBuilder(int index)
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
Parameter |
---|
Name | Description |
index | int
|
getMetricRulesOrBuilderList()
public List<? extends MetricRuleOrBuilder> getMetricRulesOrBuilderList()
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
Returns |
---|
Type | Description |
List<? extends com.google.api.MetricRuleOrBuilder> | |
internalGetFieldAccessorTable()
protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Overrides
isInitialized()
public final boolean isInitialized()
Overrides
mergeFrom(Quota other)
public Quota.Builder mergeFrom(Quota other)
Parameter |
---|
Name | Description |
other | Quota
|
public Quota.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Overrides
mergeFrom(Message other)
public Quota.Builder mergeFrom(Message other)
Parameter |
---|
Name | Description |
other | Message
|
Overrides
mergeUnknownFields(UnknownFieldSet unknownFields)
public final Quota.Builder mergeUnknownFields(UnknownFieldSet unknownFields)
Overrides
removeLimits(int index)
public Quota.Builder removeLimits(int index)
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
Parameter |
---|
Name | Description |
index | int
|
removeMetricRules(int index)
public Quota.Builder removeMetricRules(int index)
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
Parameter |
---|
Name | Description |
index | int
|
setField(Descriptors.FieldDescriptor field, Object value)
public Quota.Builder setField(Descriptors.FieldDescriptor field, Object value)
Overrides
setLimits(int index, QuotaLimit value)
public Quota.Builder setLimits(int index, QuotaLimit value)
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
setLimits(int index, QuotaLimit.Builder builderForValue)
public Quota.Builder setLimits(int index, QuotaLimit.Builder builderForValue)
List of QuotaLimit definitions for the service.
repeated .google.api.QuotaLimit limits = 3;
setMetricRules(int index, MetricRule value)
public Quota.Builder setMetricRules(int index, MetricRule value)
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
setMetricRules(int index, MetricRule.Builder builderForValue)
public Quota.Builder setMetricRules(int index, MetricRule.Builder builderForValue)
List of MetricRule definitions, each one mapping a selected method to one
or more metrics.
repeated .google.api.MetricRule metric_rules = 4;
setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
public Quota.Builder setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
Overrides
setUnknownFields(UnknownFieldSet unknownFields)
public final Quota.Builder setUnknownFields(UnknownFieldSet unknownFields)
Overrides