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/usage.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.unmodifiableList
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.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.MutableList
import kotlin.jvm.JvmStatic
import com.toasttab.protokt.rt.KtGeneratedMessage as RtKtGeneratedMessage
import protokt.v1.KtGeneratedMessage as V1KtGeneratedMessage
/**
* Configuration controlling usage of a service.
*/
@V1KtGeneratedMessage("google.api.Usage")
@RtKtGeneratedMessage("google.api.Usage")
public class Usage private constructor(
/**
* Requirements that must be satisfied before a consumer project can use the service. Each
* requirement is of the form /; for example
* 'serviceusage.googleapis.com/billing-enabled'.
*
* For Google APIs, a Terms of Service requirement must be included here. Google Cloud APIs must
* include "serviceusage.googleapis.com/tos/cloud". Other Google APIs should include
* "serviceusage.googleapis.com/tos/universal". Additional ToS can be included based on the business
* needs.
*/
public val requirements: List,
/**
* A list of usage rules that apply to individual API methods.
*
* **NOTE:** All service configuration rules follow "last one wins" order.
*/
public val rules: List,
/**
* The full resource name of a channel used for sending notifications to the service producer.
*
* Google Service Management currently only supports [Google Cloud
* Pub/Sub](https://cloud.google.com/pubsub) as a notification channel. To use Google Cloud Pub/Sub
* as the channel, this must be the name of a Cloud Pub/Sub topic that uses the Cloud Pub/Sub topic
* name format documented in https://cloud.google.com/pubsub/docs/overview.
*/
public val producerNotificationChannel: String,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (requirements.isNotEmpty()) {
result += (sizeOf(10u) * requirements.size) + requirements.sumOf { sizeOf(it) }
}
if (rules.isNotEmpty()) {
result += (sizeOf(50u) * rules.size) + rules.sumOf { sizeOf(it) }
}
if (producerNotificationChannel.isNotEmpty()) {
result += sizeOf(58u) + sizeOf(producerNotificationChannel)
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
requirements.forEach { serializer.writeTag(10u).write(it) }
rules.forEach { serializer.writeTag(50u).write(it) }
if (producerNotificationChannel.isNotEmpty()) {
serializer.writeTag(58u).write(producerNotificationChannel)
}
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is Usage &&
other.requirements == requirements &&
other.rules == rules &&
other.producerNotificationChannel == producerNotificationChannel &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + requirements.hashCode()
result = 31 * result + rules.hashCode()
result = 31 * result + producerNotificationChannel.hashCode()
return result
}
override fun toString(): String =
"Usage(" +
"requirements=$requirements, " +
"rules=$rules, " +
"producerNotificationChannel=$producerNotificationChannel" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): Usage =
Builder().apply {
requirements = [email protected]
rules = [email protected]
producerNotificationChannel = [email protected]
unknownFields = [email protected]
builder()
}.build()
@KtBuilderDsl
public class Builder {
public var requirements: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var rules: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var producerNotificationChannel: String = ""
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): Usage =
Usage(
unmodifiableList(requirements),
unmodifiableList(rules),
producerNotificationChannel,
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): Usage {
var requirements: MutableList? = null
var rules: MutableList? = null
var producerNotificationChannel = ""
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return Usage(
unmodifiableList(requirements),
unmodifiableList(rules),
producerNotificationChannel,
UnknownFieldSet.from(unknownFields)
)
10 ->
requirements =
(requirements ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readString())
}
}
50 ->
rules =
(rules ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readMessage(UsageRule))
}
}
58 -> producerNotificationChannel = deserializer.readString()
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): Usage = Builder().apply(dsl).build()
}
}
/**
* Usage configuration rules for the service.
*
* NOTE: Under development.
*
*
*
* Use this rule to configure unregistered calls for the service. Unregistered calls are calls that
* do not contain consumer project identity. (Example: calls that do not contain an API key). By
* default, API methods do not allow unregistered calls, and each method call must be identified by a
* consumer project identity. Use this rule to allow/disallow unregistered calls.
*
* Example of an API that wants to allow unregistered calls for entire service.
*
* usage: rules: - selector: "*" allow_unregistered_calls: true
*
* Example of a method that wants to allow unregistered calls.
*
* usage: rules: - selector: "google.example.library.v1.LibraryService.CreateBook"
* allow_unregistered_calls: true
*/
@V1KtGeneratedMessage("google.api.UsageRule")
@RtKtGeneratedMessage("google.api.UsageRule")
public class UsageRule private constructor(
/**
* Selects the methods to which this rule applies. Use '*' to indicate all methods in all APIs.
*
* Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
*/
public val selector: String,
/**
* If true, the selected method allows unregistered calls, e.g. calls that don't identify any user
* or application.
*/
public val allowUnregisteredCalls: Boolean,
/**
* If true, the selected method should skip service control and the control plane features, such
* as quota and billing, will not be available. This flag is used by Google Cloud Endpoints to bypass
* checks for internal methods, such as service health check methods.
*/
public val skipServiceControl: Boolean,
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 (allowUnregisteredCalls) {
result += sizeOf(16u) + 1
}
if (skipServiceControl) {
result += sizeOf(24u) + 1
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
if (selector.isNotEmpty()) {
serializer.writeTag(10u).write(selector)
}
if (allowUnregisteredCalls) {
serializer.writeTag(16u).write(allowUnregisteredCalls)
}
if (skipServiceControl) {
serializer.writeTag(24u).write(skipServiceControl)
}
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is UsageRule &&
other.selector == selector &&
other.allowUnregisteredCalls == allowUnregisteredCalls &&
other.skipServiceControl == skipServiceControl &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + selector.hashCode()
result = 31 * result + allowUnregisteredCalls.hashCode()
result = 31 * result + skipServiceControl.hashCode()
return result
}
override fun toString(): String =
"UsageRule(" +
"selector=$selector, " +
"allowUnregisteredCalls=$allowUnregisteredCalls, " +
"skipServiceControl=$skipServiceControl" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): UsageRule =
Builder().apply {
selector = [email protected]
allowUnregisteredCalls = [email protected]
skipServiceControl = [email protected]
unknownFields = [email protected]
builder()
}.build()
@KtBuilderDsl
public class Builder {
public var selector: String = ""
public var allowUnregisteredCalls: Boolean = false
public var skipServiceControl: Boolean = false
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): UsageRule =
UsageRule(
selector,
allowUnregisteredCalls,
skipServiceControl,
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): UsageRule {
var selector = ""
var allowUnregisteredCalls = false
var skipServiceControl = false
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return UsageRule(
selector,
allowUnregisteredCalls,
skipServiceControl,
UnknownFieldSet.from(unknownFields)
)
10 -> selector = deserializer.readString()
16 -> allowUnregisteredCalls = deserializer.readBool()
24 -> skipServiceControl = deserializer.readBool()
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): UsageRule = Builder().apply(dsl).build()
}
}