All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.protokt.v1.google.api.monitoring.kt Maven / Gradle / Ivy

The newest version!
// Generated by protokt version 1.0.0-beta.2. Do not modify.
// Source: google/api/monitoring.proto
@file:Suppress("DEPRECATION")

package protokt.v1.google.api

import protokt.v1.AbstractDeserializer
import protokt.v1.AbstractMessage
import protokt.v1.BuilderDsl
import protokt.v1.Collections.copyList
import protokt.v1.Collections.unmodifiableList
import protokt.v1.GeneratedMessage
import protokt.v1.GeneratedProperty
import protokt.v1.Reader
import protokt.v1.SizeCodecs.sizeOf
import protokt.v1.UnknownFieldSet
import protokt.v1.Writer
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

/**
 * 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
 */
@GeneratedMessage("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.
   */
  @GeneratedProperty(1)
  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.
   */
  @GeneratedProperty(2)
  public val consumerDestinations: List,
  public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractMessage() {
  private val `$messageSize`: Int by lazy {
    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()
    result
  }

  override fun messageSize(): Int = `$messageSize`

  override fun serialize(writer: Writer) {
    producerDestinations.forEach { writer.writeTag(10u).write(it) }
    consumerDestinations.forEach { writer.writeTag(18u).write(it) }
    writer.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()

  @BuilderDsl
  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 : AbstractDeserializer() {
    @JvmStatic
    override fun deserialize(reader: Reader): Monitoring {
      var producerDestinations: MutableList? = null
      var consumerDestinations: MutableList? = null
      var unknownFields: UnknownFieldSet.Builder? = null

      while (true) {
        when (reader.readTag()) {
          0u -> return Monitoring(
            unmodifiableList(producerDestinations),
            unmodifiableList(consumerDestinations),
            UnknownFieldSet.from(unknownFields)
          )
          10u ->
            producerDestinations =
              (producerDestinations ?: mutableListOf()).apply {
                reader.readRepeated(false) {
                  add(reader.readMessage(MonitoringDestination))
                }
              }
          18u ->
            consumerDestinations =
              (consumerDestinations ?: mutableListOf()).apply {
                reader.readRepeated(false) {
                  add(reader.readMessage(MonitoringDestination))
                }
              }
          else ->
            unknownFields =
              (unknownFields ?: UnknownFieldSet.Builder()).also {
                it.add(reader.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).
   */
  @GeneratedMessage("google.api.Monitoring.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.
     */
    @GeneratedProperty(1)
    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.
     */
    @GeneratedProperty(2)
    public val metrics: List,
    public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
  ) : AbstractMessage() {
    private val `$messageSize`: Int by lazy {
      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()
      result
    }

    override fun messageSize(): Int = `$messageSize`

    override fun serialize(writer: Writer) {
      if (monitoredResource.isNotEmpty()) {
        writer.writeTag(10u).write(monitoredResource)
      }
      metrics.forEach { writer.writeTag(18u).write(it) }
      writer.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()

    @BuilderDsl
    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 : AbstractDeserializer() {
      @JvmStatic
      override fun deserialize(reader: Reader): MonitoringDestination {
        var monitoredResource = ""
        var metrics: MutableList? = null
        var unknownFields: UnknownFieldSet.Builder? = null

        while (true) {
          when (reader.readTag()) {
            0u -> return MonitoringDestination(
              monitoredResource,
              unmodifiableList(metrics),
              UnknownFieldSet.from(unknownFields)
            )
            10u -> monitoredResource = reader.readString()
            18u ->
              metrics =
                (metrics ?: mutableListOf()).apply {
                  reader.readRepeated(false) {
                    add(reader.readString())
                  }
                }
            else ->
              unknownFields =
                (unknownFields ?: UnknownFieldSet.Builder()).also {
                  it.add(reader.readUnknown())
                }
          }
        }
      }

      @JvmStatic
      public operator fun invoke(dsl: Builder.() -> Unit): MonitoringDestination = Builder().apply(dsl).build()
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy