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

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

The newest version!
// Generated by protokt version 1.0.0-beta.2. Do not modify.
// Source: google/api/logging.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

/**
 * 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
 */
@GeneratedMessage("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.
   */
  @GeneratedProperty(1)
  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.
   */
  @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 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()

  @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(): Logging =
      Logging(
        unmodifiableList(producerDestinations),
        unmodifiableList(consumerDestinations),
        unknownFields
      )
  }

  public companion object Deserializer : AbstractDeserializer() {
    @JvmStatic
    override fun deserialize(reader: Reader): Logging {
      var producerDestinations: MutableList? = null
      var consumerDestinations: MutableList? = null
      var unknownFields: UnknownFieldSet.Builder? = null

      while (true) {
        when (reader.readTag()) {
          0u -> return Logging(
            unmodifiableList(producerDestinations),
            unmodifiableList(consumerDestinations),
            UnknownFieldSet.from(unknownFields)
          )
          10u ->
            producerDestinations =
              (producerDestinations ?: mutableListOf()).apply {
                reader.readRepeated(false) {
                  add(reader.readMessage(LoggingDestination))
                }
              }
          18u ->
            consumerDestinations =
              (consumerDestinations ?: mutableListOf()).apply {
                reader.readRepeated(false) {
                  add(reader.readMessage(LoggingDestination))
                }
              }
          else ->
            unknownFields =
              (unknownFields ?: UnknownFieldSet.Builder()).also {
                it.add(reader.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).
   */
  @GeneratedMessage("google.api.Logging.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 "/".
     */
    @GeneratedProperty(1)
    public val logs: List,
    /**
     * The monitored resource type. The type must be defined in the
     * [Service.monitored_resources][google.api.Service.monitored_resources] section.
     */
    @GeneratedProperty(3)
    public val monitoredResource: String,
    public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
  ) : AbstractMessage() {
    private val `$messageSize`: Int by lazy {
      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()
      result
    }

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

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy