commonMain.protokt.v1.google.api.monitoring.kt Maven / Gradle / Ivy
// Generated by protokt version 1.0.0-alpha.8. Do not modify.
// Source: google/api/monitoring.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
/**
* Monitoring configuration of the service.
*
* The example below shows how to configure monitored resources and metrics for monitoring. In the
* example, a monitored resource and two metrics are defined. The
* `library.googleapis.com/book/returned_count` metric is sent to both producer and consumer projects,
* whereas the `library.googleapis.com/book/num_overdue` metric is only sent to the consumer project.
*
* monitored_resources: - type: library.googleapis.com/Branch display_name: "Library
* Branch" description: "A branch of a library." launch_stage: GA labels: -
* key: resource_container description: "The Cloud container (ie. project id) for the
* Branch." - key: location description: "The location of the library branch." -
* key: branch_id description: "The id of the branch." metrics: - name:
* library.googleapis.com/book/returned_count display_name: "Books Returned" description:
* "The count of books that have been returned." launch_stage: GA metric_kind: DELTA
* value_type: INT64 unit: "1" labels: - key: customer_id description: "The
* id of the customer." - name: library.googleapis.com/book/num_overdue display_name: "Books
* Overdue" description: "The current number of overdue books." launch_stage: GA
* metric_kind: GAUGE value_type: INT64 unit: "1" labels: - key: customer_id
* description: "The id of the customer." monitoring: producer_destinations: -
* monitored_resource: library.googleapis.com/Branch metrics: -
* library.googleapis.com/book/returned_count consumer_destinations: - monitored_resource:
* library.googleapis.com/Branch metrics: -
* library.googleapis.com/book/returned_count - library.googleapis.com/book/num_overdue
*/
@V1KtGeneratedMessage("google.api.Monitoring")
@RtKtGeneratedMessage("google.api.Monitoring")
public class Monitoring private constructor(
/**
* Monitoring configurations for sending metrics to the producer project. There can be multiple
* producer destinations. A monitored resource type may appear in multiple monitoring destinations if
* different aggregations are needed for different sets of metrics associated with that monitored
* resource type. A monitored resource and metric pair may only be used once in the Monitoring
* configuration.
*/
public val producerDestinations: List,
/**
* Monitoring configurations for sending metrics to the consumer project. There can be multiple
* consumer destinations. A monitored resource type may appear in multiple monitoring destinations if
* different aggregations are needed for different sets of metrics associated with that monitored
* resource type. A monitored resource and metric pair may only be used once in the Monitoring
* configuration.
*/
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 Monitoring &&
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 =
"Monitoring(" +
"producerDestinations=$producerDestinations, " +
"consumerDestinations=$consumerDestinations" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): Monitoring =
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(): Monitoring =
Monitoring(
unmodifiableList(producerDestinations),
unmodifiableList(consumerDestinations),
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): Monitoring {
var producerDestinations: MutableList? = null
var consumerDestinations: MutableList? = null
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return Monitoring(
unmodifiableList(producerDestinations),
unmodifiableList(consumerDestinations),
UnknownFieldSet.from(unknownFields)
)
10 ->
producerDestinations =
(producerDestinations ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readMessage(MonitoringDestination))
}
}
18 ->
consumerDestinations =
(consumerDestinations ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readMessage(MonitoringDestination))
}
}
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): Monitoring = Builder().apply(dsl).build()
}
/**
* Configuration of a specific monitoring destination (the producer project or the consumer
* project).
*/
@V1KtGeneratedMessage("google.api.MonitoringDestination")
@RtKtGeneratedMessage("google.api.MonitoringDestination")
public class MonitoringDestination private constructor(
/**
* The monitored resource type. The type must be defined in
* [Service.monitored_resources][google.api.Service.monitored_resources] section.
*/
public val monitoredResource: String,
/**
* Types of the metrics to report to this monitoring destination. Each type must be defined in
* [Service.metrics][google.api.Service.metrics] section.
*/
public val metrics: List,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (monitoredResource.isNotEmpty()) {
result += sizeOf(10u) + sizeOf(monitoredResource)
}
if (metrics.isNotEmpty()) {
result += (sizeOf(18u) * metrics.size) + metrics.sumOf { sizeOf(it) }
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
if (monitoredResource.isNotEmpty()) {
serializer.writeTag(10u).write(monitoredResource)
}
metrics.forEach { serializer.writeTag(18u).write(it) }
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is MonitoringDestination &&
other.monitoredResource == monitoredResource &&
other.metrics == metrics &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + monitoredResource.hashCode()
result = 31 * result + metrics.hashCode()
return result
}
override fun toString(): String =
"MonitoringDestination(" +
"monitoredResource=$monitoredResource, " +
"metrics=$metrics" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): MonitoringDestination =
Builder().apply {
monitoredResource = [email protected]
metrics = [email protected]
unknownFields = [email protected]
builder()
}.build()
@KtBuilderDsl
public class Builder {
public var monitoredResource: String = ""
public var metrics: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): MonitoringDestination =
MonitoringDestination(
monitoredResource,
unmodifiableList(metrics),
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): MonitoringDestination {
var monitoredResource = ""
var metrics: MutableList? = null
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return MonitoringDestination(
monitoredResource,
unmodifiableList(metrics),
UnknownFieldSet.from(unknownFields)
)
10 -> monitoredResource = deserializer.readString()
18 ->
metrics =
(metrics ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readString())
}
}
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): MonitoringDestination = Builder().apply(dsl).build()
}
}
}