public final class Quota extends GeneratedMessageV3 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| Modifier and Type | Class and Description |
|---|---|
static class |
Quota.Builder
Quota configuration helps to achieve fairness and budgeting in service
usage.
|
GeneratedMessageV3.BuilderParent, GeneratedMessageV3.ExtendableBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage,BuilderType extends GeneratedMessageV3.ExtendableBuilder<MessageType,BuilderType>>, GeneratedMessageV3.ExtendableMessage<MessageType extends GeneratedMessageV3.ExtendableMessage>, GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>, GeneratedMessageV3.FieldAccessorTable| Modifier and Type | Field and Description |
|---|---|
static int |
LIMITS_FIELD_NUMBER |
static int |
METRIC_RULES_FIELD_NUMBER |
alwaysUseFieldBuilders, unknownFieldsmemoizedSizememoizedHashCode| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj) |
static Quota |
getDefaultInstance() |
Quota |
getDefaultInstanceForType() |
static Descriptors.Descriptor |
getDescriptor() |
QuotaLimit |
getLimits(int index)
List of `QuotaLimit` definitions for the service.
|
int |
getLimitsCount()
List of `QuotaLimit` definitions for the service.
|
java.util.List<QuotaLimit> |
getLimitsList()
List of `QuotaLimit` definitions for the service.
|
QuotaLimitOrBuilder |
getLimitsOrBuilder(int index)
List of `QuotaLimit` definitions for the service.
|
java.util.List<? extends QuotaLimitOrBuilder> |
getLimitsOrBuilderList()
List of `QuotaLimit` definitions for the service.
|
MetricRule |
getMetricRules(int index)
List of `MetricRule` definitions, each one mapping a selected method to one
or more metrics.
|
int |
getMetricRulesCount()
List of `MetricRule` definitions, each one mapping a selected method to one
or more metrics.
|
java.util.List<MetricRule> |
getMetricRulesList()
List of `MetricRule` definitions, each one mapping a selected method to one
or more metrics.
|
MetricRuleOrBuilder |
getMetricRulesOrBuilder(int index)
List of `MetricRule` definitions, each one mapping a selected method to one
or more metrics.
|
java.util.List<? extends MetricRuleOrBuilder> |
getMetricRulesOrBuilderList()
List of `MetricRule` definitions, each one mapping a selected method to one
or more metrics.
|
Parser<Quota> |
getParserForType() |
int |
getSerializedSize() |
UnknownFieldSet |
getUnknownFields() |
int |
hashCode() |
protected GeneratedMessageV3.FieldAccessorTable |
internalGetFieldAccessorTable() |
boolean |
isInitialized() |
static Quota.Builder |
newBuilder() |
static Quota.Builder |
newBuilder(Quota prototype) |
Quota.Builder |
newBuilderForType() |
protected Quota.Builder |
newBuilderForType(GeneratedMessageV3.BuilderParent parent) |
static Quota |
parseDelimitedFrom(java.io.InputStream input) |
static Quota |
parseDelimitedFrom(java.io.InputStream input,
ExtensionRegistryLite extensionRegistry) |
static Quota |
parseFrom(byte[] data) |
static Quota |
parseFrom(byte[] data,
ExtensionRegistryLite extensionRegistry) |
static Quota |
parseFrom(java.nio.ByteBuffer data) |
static Quota |
parseFrom(java.nio.ByteBuffer data,
ExtensionRegistryLite extensionRegistry) |
static Quota |
parseFrom(ByteString data) |
static Quota |
parseFrom(ByteString data,
ExtensionRegistryLite extensionRegistry) |
static Quota |
parseFrom(CodedInputStream input) |
static Quota |
parseFrom(CodedInputStream input,
ExtensionRegistryLite extensionRegistry) |
static Quota |
parseFrom(java.io.InputStream input) |
static Quota |
parseFrom(java.io.InputStream input,
ExtensionRegistryLite extensionRegistry) |
static Parser<Quota> |
parser() |
Quota.Builder |
toBuilder() |
void |
writeTo(CodedOutputStream output) |
canUseUnsafe, computeStringSize, computeStringSizeNoTag, emptyBooleanList, emptyDoubleList, emptyFloatList, emptyIntList, emptyLongList, getAllFields, getDescriptorForType, getField, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, hasField, hasOneof, internalGetMapField, makeExtensionsImmutable, mutableCopy, mutableCopy, mutableCopy, mutableCopy, mutableCopy, newBooleanList, newBuilderForType, newDoubleList, newFloatList, newIntList, newLongList, parseDelimitedWithIOException, parseDelimitedWithIOException, parseUnknownField, parseUnknownFieldProto3, parseWithIOException, parseWithIOException, parseWithIOException, parseWithIOException, serializeBooleanMapTo, serializeIntegerMapTo, serializeLongMapTo, serializeStringMapTo, writeReplace, writeString, writeStringNoTagfindInitializationErrors, getInitializationErrorString, hashBoolean, hashEnum, hashEnumList, hashFields, hashLong, toStringaddAll, addAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeToclone, finalize, getClass, notify, notifyAll, wait, wait, waitfindInitializationErrors, getAllFields, getDescriptorForType, getField, getInitializationErrorString, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, hasField, hasOneoftoByteArray, toByteString, writeDelimitedTo, writeTopublic static final int LIMITS_FIELD_NUMBER
public static final int METRIC_RULES_FIELD_NUMBER
public final UnknownFieldSet getUnknownFields()
getUnknownFields in interface MessageOrBuildergetUnknownFields in class GeneratedMessageV3public static final Descriptors.Descriptor getDescriptor()
protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
internalGetFieldAccessorTable in class GeneratedMessageV3public java.util.List<QuotaLimit> getLimitsList()
List of `QuotaLimit` definitions for the service.
repeated .google.api.QuotaLimit limits = 3;getLimitsList in interface QuotaOrBuilderpublic java.util.List<? extends QuotaLimitOrBuilder> getLimitsOrBuilderList()
List of `QuotaLimit` definitions for the service.
repeated .google.api.QuotaLimit limits = 3;getLimitsOrBuilderList in interface QuotaOrBuilderpublic int getLimitsCount()
List of `QuotaLimit` definitions for the service.
repeated .google.api.QuotaLimit limits = 3;getLimitsCount in interface QuotaOrBuilderpublic QuotaLimit getLimits(int index)
List of `QuotaLimit` definitions for the service.
repeated .google.api.QuotaLimit limits = 3;getLimits in interface QuotaOrBuilderpublic QuotaLimitOrBuilder getLimitsOrBuilder(int index)
List of `QuotaLimit` definitions for the service.
repeated .google.api.QuotaLimit limits = 3;getLimitsOrBuilder in interface QuotaOrBuilderpublic java.util.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;getMetricRulesList in interface QuotaOrBuilderpublic java.util.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;getMetricRulesOrBuilderList in interface QuotaOrBuilderpublic int getMetricRulesCount()
List of `MetricRule` definitions, each one mapping a selected method to one or more metrics.
repeated .google.api.MetricRule metric_rules = 4;getMetricRulesCount in interface QuotaOrBuilderpublic 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;getMetricRules in interface QuotaOrBuilderpublic 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;getMetricRulesOrBuilder in interface QuotaOrBuilderpublic final boolean isInitialized()
isInitialized in interface MessageLiteOrBuilderisInitialized in class GeneratedMessageV3public void writeTo(CodedOutputStream output) throws java.io.IOException
writeTo in interface MessageLitewriteTo in class GeneratedMessageV3java.io.IOExceptionpublic int getSerializedSize()
getSerializedSize in interface MessageLitegetSerializedSize in class GeneratedMessageV3public boolean equals(java.lang.Object obj)
equals in interface Messageequals in class AbstractMessagepublic int hashCode()
hashCode in interface MessagehashCode in class AbstractMessagepublic static Quota parseFrom(java.nio.ByteBuffer data) throws InvalidProtocolBufferException
InvalidProtocolBufferExceptionpublic static Quota parseFrom(java.nio.ByteBuffer data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
InvalidProtocolBufferExceptionpublic static Quota parseFrom(ByteString data) throws InvalidProtocolBufferException
InvalidProtocolBufferExceptionpublic static Quota parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
InvalidProtocolBufferExceptionpublic static Quota parseFrom(byte[] data) throws InvalidProtocolBufferException
InvalidProtocolBufferExceptionpublic static Quota parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
InvalidProtocolBufferExceptionpublic static Quota parseFrom(java.io.InputStream input) throws java.io.IOException
java.io.IOExceptionpublic static Quota parseFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry) throws java.io.IOException
java.io.IOExceptionpublic static Quota parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException
java.io.IOExceptionpublic static Quota parseDelimitedFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry) throws java.io.IOException
java.io.IOExceptionpublic static Quota parseFrom(CodedInputStream input) throws java.io.IOException
java.io.IOExceptionpublic static Quota parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws java.io.IOException
java.io.IOExceptionpublic Quota.Builder newBuilderForType()
newBuilderForType in interface MessagenewBuilderForType in interface MessageLitepublic static Quota.Builder newBuilder()
public static Quota.Builder newBuilder(Quota prototype)
public Quota.Builder toBuilder()
toBuilder in interface MessagetoBuilder in interface MessageLiteprotected Quota.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)
newBuilderForType in class GeneratedMessageV3public static Quota getDefaultInstance()
public Parser<Quota> getParserForType()
getParserForType in interface MessagegetParserForType in interface MessageLitegetParserForType in class GeneratedMessageV3public Quota getDefaultInstanceForType()
getDefaultInstanceForType in interface MessageLiteOrBuildergetDefaultInstanceForType in interface MessageOrBuilder