Class Quota.Builder (2.49.0)

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

Implements

QuotaOrBuilder

Static Methods

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
Type Description
Descriptor

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>
Returns
Type Description
Quota.Builder

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>
Returns
Type Description
Quota.Builder

addLimits(QuotaLimit value)

public Quota.Builder addLimits(QuotaLimit value)

List of QuotaLimit definitions for the service.

repeated .google.api.QuotaLimit limits = 3;

Parameter
Name Description
value QuotaLimit
Returns
Type Description
Quota.Builder

addLimits(QuotaLimit.Builder builderForValue)

public Quota.Builder addLimits(QuotaLimit.Builder builderForValue)

List of QuotaLimit definitions for the service.

repeated .google.api.QuotaLimit limits = 3;

Parameter
Name Description
builderForValue QuotaLimit.Builder
Returns
Type Description
Quota.Builder

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;

Parameters
Name Description
index int
value QuotaLimit
Returns
Type Description
Quota.Builder

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;

Parameters
Name Description
index int
builderForValue QuotaLimit.Builder
Returns
Type Description
Quota.Builder

addLimitsBuilder()

public QuotaLimit.Builder addLimitsBuilder()

List of QuotaLimit definitions for the service.

repeated .google.api.QuotaLimit limits = 3;

Returns
Type Description
QuotaLimit.Builder

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
Returns
Type Description
QuotaLimit.Builder

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;

Parameter
Name Description
value MetricRule
Returns
Type Description
Quota.Builder

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;

Parameter
Name Description
builderForValue MetricRule.Builder
Returns
Type Description
Quota.Builder

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;

Parameters
Name Description
index int
value MetricRule
Returns
Type Description
Quota.Builder

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;

Parameters
Name Description
index int
builderForValue MetricRule.Builder
Returns
Type Description
Quota.Builder

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;

Returns
Type Description
MetricRule.Builder

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
Returns
Type Description
MetricRule.Builder

addRepeatedField(Descriptors.FieldDescriptor field, Object value)

public Quota.Builder addRepeatedField(Descriptors.FieldDescriptor field, Object value)
Parameters
Name Description
field FieldDescriptor
value Object
Returns
Type Description
Quota.Builder
Overrides

build()

public Quota build()
Returns
Type Description
Quota

buildPartial()

public Quota buildPartial()
Returns
Type Description
Quota

clear()

public Quota.Builder clear()
Returns
Type Description
Quota.Builder
Overrides

clearField(Descriptors.FieldDescriptor field)

public Quota.Builder clearField(Descriptors.FieldDescriptor field)
Parameter
Name Description
field FieldDescriptor
Returns
Type Description
Quota.Builder
Overrides

clearLimits()

public Quota.Builder clearLimits()

List of QuotaLimit definitions for the service.

repeated .google.api.QuotaLimit limits = 3;

Returns
Type Description
Quota.Builder

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;

Returns
Type Description
Quota.Builder

clearOneof(Descriptors.OneofDescriptor oneof)

public Quota.Builder clearOneof(Descriptors.OneofDescriptor oneof)
Parameter
Name Description
oneof OneofDescriptor
Returns
Type Description
Quota.Builder
Overrides

clone()

public Quota.Builder clone()
Returns
Type Description
Quota.Builder
Overrides

getDefaultInstanceForType()

public Quota getDefaultInstanceForType()
Returns
Type Description
Quota

getDescriptorForType()

public Descriptors.Descriptor getDescriptorForType()
Returns
Type Description
Descriptor
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
Returns
Type Description
QuotaLimit

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
Returns
Type Description
QuotaLimit.Builder

getLimitsBuilderList()

public List<QuotaLimit.Builder> getLimitsBuilderList()

List of QuotaLimit definitions for the service.

repeated .google.api.QuotaLimit limits = 3;

Returns
Type Description
List<Builder>

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;

Returns
Type Description
List<QuotaLimit>

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
Returns
Type Description
QuotaLimitOrBuilder

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
Returns
Type Description
MetricRule

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
Returns
Type Description
MetricRule.Builder

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;

Returns
Type Description
List<Builder>

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;

Returns
Type Description
List<MetricRule>

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
Returns
Type Description
MetricRuleOrBuilder

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()
Returns
Type Description
FieldAccessorTable
Overrides

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

mergeFrom(Quota other)

public Quota.Builder mergeFrom(Quota other)
Parameter
Name Description
other Quota
Returns
Type Description
Quota.Builder

mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public Quota.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Quota.Builder
Overrides
Exceptions
Type Description
IOException

mergeFrom(Message other)

public Quota.Builder mergeFrom(Message other)
Parameter
Name Description
other Message
Returns
Type Description
Quota.Builder
Overrides

mergeUnknownFields(UnknownFieldSet unknownFields)

public final Quota.Builder mergeUnknownFields(UnknownFieldSet unknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
Quota.Builder
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
Returns
Type Description
Quota.Builder

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
Returns
Type Description
Quota.Builder

setField(Descriptors.FieldDescriptor field, Object value)

public Quota.Builder setField(Descriptors.FieldDescriptor field, Object value)
Parameters
Name Description
field FieldDescriptor
value Object
Returns
Type Description
Quota.Builder
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;

Parameters
Name Description
index int
value QuotaLimit
Returns
Type Description
Quota.Builder

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;

Parameters
Name Description
index int
builderForValue QuotaLimit.Builder
Returns
Type Description
Quota.Builder

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;

Parameters
Name Description
index int
value MetricRule
Returns
Type Description
Quota.Builder

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;

Parameters
Name Description
index int
builderForValue MetricRule.Builder
Returns
Type Description
Quota.Builder

setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)

public Quota.Builder setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
Parameters
Name Description
field FieldDescriptor
index int
value Object
Returns
Type Description
Quota.Builder
Overrides

setUnknownFields(UnknownFieldSet unknownFields)

public final Quota.Builder setUnknownFields(UnknownFieldSet unknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
Quota.Builder
Overrides