Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
// Generated by protokt version 1.0.0-alpha.8. Do not modify.
// Source: google/api/quota.proto
@file:Suppress("DEPRECATION")
package protokt.v1.google.api
import protokt.v1.AbstractKtDeserializer
import protokt.v1.AbstractKtMessage
import protokt.v1.Collections.copyList
import protokt.v1.Collections.copyMap
import protokt.v1.Collections.unmodifiableList
import protokt.v1.Collections.unmodifiableMap
import protokt.v1.KtBuilderDsl
import protokt.v1.KtMessageDeserializer
import protokt.v1.KtMessageSerializer
import protokt.v1.SizeCodecs.sizeOf
import protokt.v1.UnknownFieldSet
import kotlin.Any
import kotlin.Boolean
import kotlin.Int
import kotlin.Long
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.collections.MutableList
import kotlin.collections.MutableMap
import kotlin.jvm.JvmStatic
import com.toasttab.protokt.rt.KtGeneratedMessage as RtKtGeneratedMessage
import protokt.v1.KtGeneratedMessage as V1KtGeneratedMessage
/**
* 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
*
*
*/
@V1KtGeneratedMessage("google.api.Quota")
@RtKtGeneratedMessage("google.api.Quota")
public class Quota private constructor(
/**
* List of QuotaLimit definitions for the service.
*/
public val limits: List,
/**
* List of MetricRule definitions, each one mapping a selected method to one or more metrics.
*/
public val metricRules: List,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (limits.isNotEmpty()) {
result += (sizeOf(26u) * limits.size) + limits.sumOf { sizeOf(it) }
}
if (metricRules.isNotEmpty()) {
result += (sizeOf(34u) * metricRules.size) + metricRules.sumOf { sizeOf(it) }
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
limits.forEach { serializer.writeTag(26u).write(it) }
metricRules.forEach { serializer.writeTag(34u).write(it) }
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is Quota &&
other.limits == limits &&
other.metricRules == metricRules &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + limits.hashCode()
result = 31 * result + metricRules.hashCode()
return result
}
override fun toString(): String =
"Quota(" +
"limits=$limits, " +
"metricRules=$metricRules" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): Quota =
Builder().apply {
limits = [email protected]
metricRules = [email protected]
unknownFields = [email protected]
builder()
}.build()
@KtBuilderDsl
public class Builder {
public var limits: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var metricRules: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): Quota =
Quota(
unmodifiableList(limits),
unmodifiableList(metricRules),
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): Quota {
var limits: MutableList? = null
var metricRules: MutableList? = null
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return Quota(
unmodifiableList(limits),
unmodifiableList(metricRules),
UnknownFieldSet.from(unknownFields)
)
26 ->
limits =
(limits ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readMessage(QuotaLimit))
}
}
34 ->
metricRules =
(metricRules ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readMessage(MetricRule))
}
}
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): Quota = Builder().apply(dsl).build()
}
}
/**
* Bind API methods to metrics. Binding a method to a metric causes that metric's configured quota
* behaviors to apply to the method call.
*/
@V1KtGeneratedMessage("google.api.MetricRule")
@RtKtGeneratedMessage("google.api.MetricRule")
public class MetricRule private constructor(
/**
* Selects the methods to which this rule applies.
*
* Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
*/
public val selector: String,
/**
* Metrics to update when the selected methods are called, and the associated cost applied to each
* metric.
*
* The key of the map is the metric name, and the values are the amount increased for the metric
* against which the quota limits are defined. The value must not be negative.
*/
public val metricCosts: Map,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (selector.isNotEmpty()) {
result += sizeOf(10u) + sizeOf(selector)
}
if (metricCosts.isNotEmpty()) {
result +=
sizeOf(metricCosts, 18u) { k, v ->
MetricCostsEntry.entrySize(k, v)
}
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
if (selector.isNotEmpty()) {
serializer.writeTag(10u).write(selector)
}
metricCosts.entries.forEach {
serializer.writeTag(18u).write(MetricCostsEntry(it.key, it.value))
}
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is MetricRule &&
other.selector == selector &&
other.metricCosts == metricCosts &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + selector.hashCode()
result = 31 * result + metricCosts.hashCode()
return result
}
override fun toString(): String =
"MetricRule(" +
"selector=$selector, " +
"metricCosts=$metricCosts" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): MetricRule =
Builder().apply {
selector = [email protected]
metricCosts = [email protected]
unknownFields = [email protected]
builder()
}.build()
@KtBuilderDsl
public class Builder {
public var selector: String = ""
public var metricCosts: Map = emptyMap()
set(newValue) {
field = copyMap(newValue)
}
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): MetricRule =
MetricRule(
selector,
unmodifiableMap(metricCosts),
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): MetricRule {
var selector = ""
var metricCosts: MutableMap? = null
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return MetricRule(
selector,
unmodifiableMap(metricCosts),
UnknownFieldSet.from(unknownFields)
)
10 -> selector = deserializer.readString()
18 ->
metricCosts =
(metricCosts ?: mutableMapOf()).apply {
deserializer.readRepeated(false) {
deserializer.readMessage(MetricCostsEntry).let {
put(it.key, it.value)
}
}
}
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): MetricRule = Builder().apply(dsl).build()
}
private class MetricCostsEntry(
public val key: String,
public val `value`: Long
) : AbstractKtMessage() {
override val messageSize: Int
get() = entrySize(key, value)
override fun serialize(serializer: KtMessageSerializer) {
serializer.writeTag(10u).write(key)
serializer.writeTag(16u).write(`value`)
}
public companion object Deserializer : AbstractKtDeserializer() {
public fun entrySize(
key: String,
`value`: Long
): Int =
sizeOf(10u) + sizeOf(key) +
sizeOf(16u) + sizeOf(`value`)
override fun deserialize(deserializer: KtMessageDeserializer): MetricCostsEntry {
var key = ""
var value = 0L
while (true) {
when (deserializer.readTag()) {
0 -> return MetricCostsEntry(key, value)
10 -> key = deserializer.readString()
16 -> value = deserializer.readInt64()
}
}
}
}
}
}
/**
* `QuotaLimit` defines a specific limit that applies over a specified duration for a limit type.
* There can be at most one limit for a duration and limit type combination defined within a
* `QuotaGroup`.
*/
@V1KtGeneratedMessage("google.api.QuotaLimit")
@RtKtGeneratedMessage("google.api.QuotaLimit")
public class QuotaLimit private constructor(
/**
* Optional. User-visible, extended description for this quota limit. Should be used only when
* more context is needed to understand this limit than provided by the limit's display name (see:
* `display_name`).
*/
public val description: String,
/**
* Default number of tokens that can be consumed during the specified duration. This is the number
* of tokens assigned when a client application developer activates the service for his/her project.
*
* Specifying a value of 0 will block all requests. This can be used if you are provisioning
* quota to selected consumers and blocking others. Similarly, a value of -1 will indicate an
* unlimited quota. No other negative values are allowed.
*
* Used by group-based quotas only.
*/
public val defaultLimit: Long,
/**
* Maximum number of tokens that can be consumed during the specified duration. Client application
* developers can override the default limit up to this maximum. If specified, this value cannot be
* set to a value less than the default limit. If not specified, it is set to the default limit.
*
* To allow clients to apply overrides with no upper bound, set this to -1, indicating unlimited
* maximum quota.
*
* Used by group-based quotas only.
*/
public val maxLimit: Long,
/**
* Duration of this limit in textual notation. Must be "100s" or "1d".
*
* Used by group-based quotas only.
*/
public val duration: String,
/**
* Name of the quota limit.
*
* The name must be provided, and it must be unique within the service. The name can only include
* alphanumeric characters as well as '-'.
*
* The maximum length of the limit name is 64 characters.
*/
public val name: String,
/**
* Free tier value displayed in the Developers Console for this limit. The free tier is the number
* of tokens that will be subtracted from the billed amount when billing is enabled. This field can
* only be set on a limit with duration "1d", in a billable group; it is invalid on any other limit.
* If this field is not set, it defaults to 0, indicating that there is no free tier for this
* service.
*
* Used by group-based quotas only.
*/
public val freeTier: Long,
/**
* The name of the metric this quota limit applies to. The quota limits with the same metric will
* be checked together during runtime. The metric must be defined within the service config.
*/
public val metric: String,
/**
* Specify the unit of the quota limit. It uses the same syntax as [Metric.unit][]. The supported
* unit kinds are determined by the quota backend system.
*
* Here are some examples: * "1/min/{project}" for quota per minute per project.
*
* Note: the order of unit components is insignificant. The "1" at the beginning is required to
* follow the metric unit syntax.
*/
public val unit: String,
/**
* Tiered limit values. You must specify this as a key:value pair, with an integer value that is
* the maximum number of requests allowed for the specified unit. Currently only STANDARD is
* supported.
*/
public val values: Map,
/**
* User-visible display name for this limit. Optional. If not set, the UI will provide a default
* display name based on the quota configuration. This field can be used to override the default
* display name generated from the configuration.
*/
public val displayName: String,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (description.isNotEmpty()) {
result += sizeOf(18u) + sizeOf(description)
}
if (defaultLimit != 0L) {
result += sizeOf(24u) + sizeOf(defaultLimit)
}
if (maxLimit != 0L) {
result += sizeOf(32u) + sizeOf(maxLimit)
}
if (duration.isNotEmpty()) {
result += sizeOf(42u) + sizeOf(duration)
}
if (name.isNotEmpty()) {
result += sizeOf(50u) + sizeOf(name)
}
if (freeTier != 0L) {
result += sizeOf(56u) + sizeOf(freeTier)
}
if (metric.isNotEmpty()) {
result += sizeOf(66u) + sizeOf(metric)
}
if (unit.isNotEmpty()) {
result += sizeOf(74u) + sizeOf(unit)
}
if (values.isNotEmpty()) {
result +=
sizeOf(values, 82u) { k, v ->
ValuesEntry.entrySize(k, v)
}
}
if (displayName.isNotEmpty()) {
result += sizeOf(98u) + sizeOf(displayName)
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
if (description.isNotEmpty()) {
serializer.writeTag(18u).write(description)
}
if (defaultLimit != 0L) {
serializer.writeTag(24u).write(defaultLimit)
}
if (maxLimit != 0L) {
serializer.writeTag(32u).write(maxLimit)
}
if (duration.isNotEmpty()) {
serializer.writeTag(42u).write(duration)
}
if (name.isNotEmpty()) {
serializer.writeTag(50u).write(name)
}
if (freeTier != 0L) {
serializer.writeTag(56u).write(freeTier)
}
if (metric.isNotEmpty()) {
serializer.writeTag(66u).write(metric)
}
if (unit.isNotEmpty()) {
serializer.writeTag(74u).write(unit)
}
values.entries.forEach {
serializer.writeTag(82u).write(ValuesEntry(it.key, it.value))
}
if (displayName.isNotEmpty()) {
serializer.writeTag(98u).write(displayName)
}
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is QuotaLimit &&
other.description == description &&
other.defaultLimit == defaultLimit &&
other.maxLimit == maxLimit &&
other.duration == duration &&
other.name == name &&
other.freeTier == freeTier &&
other.metric == metric &&
other.unit == unit &&
other.values == values &&
other.displayName == displayName &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + description.hashCode()
result = 31 * result + defaultLimit.hashCode()
result = 31 * result + maxLimit.hashCode()
result = 31 * result + duration.hashCode()
result = 31 * result + name.hashCode()
result = 31 * result + freeTier.hashCode()
result = 31 * result + metric.hashCode()
result = 31 * result + unit.hashCode()
result = 31 * result + values.hashCode()
result = 31 * result + displayName.hashCode()
return result
}
override fun toString(): String =
"QuotaLimit(" +
"description=$description, " +
"defaultLimit=$defaultLimit, " +
"maxLimit=$maxLimit, " +
"duration=$duration, " +
"name=$name, " +
"freeTier=$freeTier, " +
"metric=$metric, " +
"unit=$unit, " +
"values=$values, " +
"displayName=$displayName" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): QuotaLimit =
Builder().apply {
description = [email protected]
defaultLimit = [email protected]
maxLimit = [email protected]
duration = [email protected]
name = [email protected]
freeTier = [email protected]
metric = [email protected]
unit = [email protected]
values = [email protected]
displayName = [email protected]
unknownFields = [email protected]
builder()
}.build()
@KtBuilderDsl
public class Builder {
public var description: String = ""
public var defaultLimit: Long = 0L
public var maxLimit: Long = 0L
public var duration: String = ""
public var name: String = ""
public var freeTier: Long = 0L
public var metric: String = ""
public var unit: String = ""
public var values: Map = emptyMap()
set(newValue) {
field = copyMap(newValue)
}
public var displayName: String = ""
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): QuotaLimit =
QuotaLimit(
description,
defaultLimit,
maxLimit,
duration,
name,
freeTier,
metric,
unit,
unmodifiableMap(values),
displayName,
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): QuotaLimit {
var description = ""
var defaultLimit = 0L
var maxLimit = 0L
var duration = ""
var name = ""
var freeTier = 0L
var metric = ""
var unit = ""
var values: MutableMap? = null
var displayName = ""
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return QuotaLimit(
description,
defaultLimit,
maxLimit,
duration,
name,
freeTier,
metric,
unit,
unmodifiableMap(values),
displayName,
UnknownFieldSet.from(unknownFields)
)
18 -> description = deserializer.readString()
24 -> defaultLimit = deserializer.readInt64()
32 -> maxLimit = deserializer.readInt64()
42 -> duration = deserializer.readString()
50 -> name = deserializer.readString()
56 -> freeTier = deserializer.readInt64()
66 -> metric = deserializer.readString()
74 -> unit = deserializer.readString()
82 ->
values =
(values ?: mutableMapOf()).apply {
deserializer.readRepeated(false) {
deserializer.readMessage(ValuesEntry).let {
put(it.key, it.value)
}
}
}
98 -> displayName = deserializer.readString()
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): QuotaLimit = Builder().apply(dsl).build()
}
private class ValuesEntry(
public val key: String,
public val `value`: Long
) : AbstractKtMessage() {
override val messageSize: Int
get() = entrySize(key, value)
override fun serialize(serializer: KtMessageSerializer) {
serializer.writeTag(10u).write(key)
serializer.writeTag(16u).write(`value`)
}
public companion object Deserializer : AbstractKtDeserializer() {
public fun entrySize(
key: String,
`value`: Long
): Int =
sizeOf(10u) + sizeOf(key) +
sizeOf(16u) + sizeOf(`value`)
override fun deserialize(deserializer: KtMessageDeserializer): ValuesEntry {
var key = ""
var value = 0L
while (true) {
when (deserializer.readTag()) {
0 -> return ValuesEntry(key, value)
10 -> key = deserializer.readString()
16 -> value = deserializer.readInt64()
}
}
}
}
}
}