protokt.com.google.api.control.kt Maven / Gradle / Ivy
// Generated by protokt version 0.10.0. Do not modify.
// Source: google/api/control.proto
package com.google.api
import com.toasttab.protokt.rt.KtDeserializer
import com.toasttab.protokt.rt.KtGeneratedMessage
import com.toasttab.protokt.rt.KtMessage
import com.toasttab.protokt.rt.KtMessageDeserializer
import com.toasttab.protokt.rt.KtMessageSerializer
import com.toasttab.protokt.rt.Tag
import com.toasttab.protokt.rt.UnknownFieldSet
import com.toasttab.protokt.rt.sizeof
import kotlin.Any
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Unit
/**
* Selects and configures the service controller used by the service. The service controller
* handles features like abuse, quota, billing, logging, monitoring, etc.
*/
@KtGeneratedMessage("google.api.Control")
class Control private constructor(
/**
* The service control environment to use. If empty, no control plane feature (like quota and
* billing) will be enabled.
*/
val environment: String,
val unknownFields: UnknownFieldSet = UnknownFieldSet.empty(),
) : KtMessage {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (environment.isNotEmpty()) {
result += sizeof(Tag(1)) + sizeof(environment)
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
if (environment.isNotEmpty()) {
serializer.write(Tag(10)).write(environment)
}
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean = other is Control &&
other.environment == environment &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + environment.hashCode()
return result
}
override fun toString(): String = "Control(" +
"environment=$environment, " +
"unknownFields=$unknownFields)"
fun copy(dsl: ControlDsl.() -> Unit): Control = Control.Deserializer {
environment = [email protected]
unknownFields = [email protected]
dsl()
}
class ControlDsl {
var environment: String = ""
var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
fun build(): Control = Control(environment,
unknownFields)
}
companion object Deserializer : KtDeserializer,
(ControlDsl.() -> Unit) -> Control {
override fun deserialize(deserializer: KtMessageDeserializer): Control {
var environment = ""
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when(deserializer.readTag()) {
0 -> return Control(environment,
UnknownFieldSet.from(unknownFields))
10 -> environment = deserializer.readString()
else -> unknownFields = (unknownFields ?:
UnknownFieldSet.Builder()).also {it.add(deserializer.readUnknown()) }
}
}
}
override fun invoke(dsl: ControlDsl.() -> Unit): Control =
ControlDsl().apply(dsl).build()
}
}