commonMain.protokt.v1.google.api.logging.kt Maven / Gradle / Ivy
// Generated by protokt version 1.0.0-alpha.8. Do not modify.
// Source: google/api/logging.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
/**
* Logging configuration of the service.
*
* The following example shows how to configure logs to be sent to the producer and consumer
* projects. In the example, the `activity_history` log is sent to both the producer and consumer
* projects, whereas the `purchase_history` log is only sent to the producer project.
*
* monitored_resources: - type: library.googleapis.com/branch labels: - key:
* /city description: The city where the library branch is located in. - key: /name
* description: The name of the branch. logs: - name: activity_history labels: -
* key: /customer_id - name: purchase_history logging: producer_destinations: -
* monitored_resource: library.googleapis.com/branch logs: - activity_history -
* purchase_history consumer_destinations: - monitored_resource:
* library.googleapis.com/branch logs: - activity_history
*/
@V1KtGeneratedMessage("google.api.Logging")
@RtKtGeneratedMessage("google.api.Logging")
public class Logging private constructor(
/**
* Logging configurations for sending logs to the producer project. There can be multiple producer
* destinations, each one must have a different monitored resource type. A log can be used in at most
* one producer destination.
*/
public val producerDestinations: List,
/**
* Logging configurations for sending logs to the consumer project. There can be multiple consumer
* destinations, each one must have a different monitored resource type. A log can be used in at most
* one consumer destination.
*/
public val consumerDestinations: List,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (producerDestinations.isNotEmpty()) {
result += (sizeOf(10u) * producerDestinations.size) +
producerDestinations.sumOf { sizeOf(it) }
}
if (consumerDestinations.isNotEmpty()) {
result += (sizeOf(18u) * consumerDestinations.size) +
consumerDestinations.sumOf { sizeOf(it) }
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
producerDestinations.forEach { serializer.writeTag(10u).write(it) }
consumerDestinations.forEach { serializer.writeTag(18u).write(it) }
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is Logging &&
other.producerDestinations == producerDestinations &&
other.consumerDestinations == consumerDestinations &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + producerDestinations.hashCode()
result = 31 * result + consumerDestinations.hashCode()
return result
}
override fun toString(): String =
"Logging(" +
"producerDestinations=$producerDestinations, " +
"consumerDestinations=$consumerDestinations" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): Logging =
Builder().apply {
producerDestinations = [email protected]
consumerDestinations = [email protected]
unknownFields = [email protected]
builder()
}.build()
@KtBuilderDsl
public class Builder {
public var producerDestinations: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var consumerDestinations: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): Logging =
Logging(
unmodifiableList(producerDestinations),
unmodifiableList(consumerDestinations),
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): Logging {
var producerDestinations: MutableList? = null
var consumerDestinations: MutableList? = null
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return Logging(
unmodifiableList(producerDestinations),
unmodifiableList(consumerDestinations),
UnknownFieldSet.from(unknownFields)
)
10 ->
producerDestinations =
(producerDestinations ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readMessage(LoggingDestination))
}
}
18 ->
consumerDestinations =
(consumerDestinations ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readMessage(LoggingDestination))
}
}
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): Logging = Builder().apply(dsl).build()
}
/**
* Configuration of a specific logging destination (the producer project or the consumer project).
*/
@V1KtGeneratedMessage("google.api.LoggingDestination")
@RtKtGeneratedMessage("google.api.LoggingDestination")
public class LoggingDestination private constructor(
/**
* Names of the logs to be sent to this destination. Each name must be defined in the
* [Service.logs][google.api.Service.logs] section. If the log name is not a domain scoped name, it
* will be automatically prefixed with the service name followed by "/".
*/
public val logs: List,
/**
* The monitored resource type. The type must be defined in the
* [Service.monitored_resources][google.api.Service.monitored_resources] section.
*/
public val monitoredResource: String,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (logs.isNotEmpty()) {
result += (sizeOf(10u) * logs.size) + logs.sumOf { sizeOf(it) }
}
if (monitoredResource.isNotEmpty()) {
result += sizeOf(26u) + sizeOf(monitoredResource)
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
logs.forEach { serializer.writeTag(10u).write(it) }
if (monitoredResource.isNotEmpty()) {
serializer.writeTag(26u).write(monitoredResource)
}
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is LoggingDestination &&
other.logs == logs &&
other.monitoredResource == monitoredResource &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + logs.hashCode()
result = 31 * result + monitoredResource.hashCode()
return result
}
override fun toString(): String =
"LoggingDestination(" +
"logs=$logs, " +
"monitoredResource=$monitoredResource" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): LoggingDestination =
Builder().apply {
logs = [email protected]
monitoredResource = [email protected]
unknownFields = [email protected]
builder()
}.build()
@KtBuilderDsl
public class Builder {
public var logs: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var monitoredResource: String = ""
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): LoggingDestination =
LoggingDestination(
unmodifiableList(logs),
monitoredResource,
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): LoggingDestination {
var logs: MutableList? = null
var monitoredResource = ""
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return LoggingDestination(
unmodifiableList(logs),
monitoredResource,
UnknownFieldSet.from(unknownFields)
)
10 ->
logs =
(logs ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readString())
}
}
26 -> monitoredResource = deserializer.readString()
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): LoggingDestination = Builder().apply(dsl).build()
}
}
}