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

commonMain.protokt.v1.google.rpc.context.audit_context.kt Maven / Gradle / Ivy

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

package protokt.v1.google.rpc.context

import protokt.v1.AbstractDeserializer
import protokt.v1.AbstractMessage
import protokt.v1.BuilderDsl
import protokt.v1.Bytes
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 protokt.v1.google.protobuf.Struct
import kotlin.Any
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.jvm.JvmStatic

/**
 * `AuditContext` provides information that is needed for audit logging.
 */
@GeneratedMessage("google.rpc.context.AuditContext")
public class AuditContext private constructor(
  /**
   * Serialized audit log.
   */
  @GeneratedProperty(1)
  public val auditLog: Bytes,
  /**
   * An API request message that is scrubbed based on the method annotation. This field should only
   * be filled if audit_log field is present. Service Control will use this to assemble a complete log
   * for Cloud Audit Logs and Google internal audit logs.
   */
  @GeneratedProperty(2)
  public val scrubbedRequest: Struct?,
  /**
   * An API response message that is scrubbed based on the method annotation. This field should only
   * be filled if audit_log field is present. Service Control will use this to assemble a complete log
   * for Cloud Audit Logs and Google internal audit logs.
   */
  @GeneratedProperty(3)
  public val scrubbedResponse: Struct?,
  /**
   * Number of scrubbed response items.
   */
  @GeneratedProperty(4)
  public val scrubbedResponseItemCount: Int,
  /**
   * Audit resource name which is scrubbed.
   */
  @GeneratedProperty(5)
  public val targetResource: String,
  public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractMessage() {
  private val `$messageSize`: Int by lazy {
    var result = 0
    if (auditLog.isNotEmpty()) {
      result += sizeOf(10u) + sizeOf(auditLog)
    }
    if (scrubbedRequest != null) {
      result += sizeOf(18u) + sizeOf(scrubbedRequest)
    }
    if (scrubbedResponse != null) {
      result += sizeOf(26u) + sizeOf(scrubbedResponse)
    }
    if (scrubbedResponseItemCount != 0) {
      result += sizeOf(32u) + sizeOf(scrubbedResponseItemCount)
    }
    if (targetResource.isNotEmpty()) {
      result += sizeOf(42u) + sizeOf(targetResource)
    }
    result += unknownFields.size()
    result
  }

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

  override fun serialize(writer: Writer) {
    if (auditLog.isNotEmpty()) {
      writer.writeTag(10u).write(auditLog)
    }
    if (scrubbedRequest != null) {
      writer.writeTag(18u).write(scrubbedRequest)
    }
    if (scrubbedResponse != null) {
      writer.writeTag(26u).write(scrubbedResponse)
    }
    if (scrubbedResponseItemCount != 0) {
      writer.writeTag(32u).write(scrubbedResponseItemCount)
    }
    if (targetResource.isNotEmpty()) {
      writer.writeTag(42u).write(targetResource)
    }
    writer.writeUnknown(unknownFields)
  }

  override fun equals(other: Any?): Boolean =
    other is AuditContext &&
      other.auditLog == auditLog &&
      other.scrubbedRequest == scrubbedRequest &&
      other.scrubbedResponse == scrubbedResponse &&
      other.scrubbedResponseItemCount == scrubbedResponseItemCount &&
      other.targetResource == targetResource &&
      other.unknownFields == unknownFields

  override fun hashCode(): Int {
    var result = unknownFields.hashCode()
    result = 31 * result + auditLog.hashCode()
    result = 31 * result + scrubbedRequest.hashCode()
    result = 31 * result + scrubbedResponse.hashCode()
    result = 31 * result + scrubbedResponseItemCount.hashCode()
    result = 31 * result + targetResource.hashCode()
    return result
  }

  override fun toString(): String =
    "AuditContext(" +
      "auditLog=$auditLog, " +
      "scrubbedRequest=$scrubbedRequest, " +
      "scrubbedResponse=$scrubbedResponse, " +
      "scrubbedResponseItemCount=$scrubbedResponseItemCount, " +
      "targetResource=$targetResource" +
      if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"

  public fun copy(builder: Builder.() -> Unit): AuditContext =
    Builder().apply {
      auditLog = [email protected]
      scrubbedRequest = [email protected]
      scrubbedResponse = [email protected]
      scrubbedResponseItemCount = [email protected]
      targetResource = [email protected]
      unknownFields = [email protected]
      builder()
    }.build()

  @BuilderDsl
  public class Builder {
    public var auditLog: Bytes = Bytes.empty()

    public var scrubbedRequest: Struct? = null

    public var scrubbedResponse: Struct? = null

    public var scrubbedResponseItemCount: Int = 0

    public var targetResource: String = ""

    public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()

    public fun build(): AuditContext =
      AuditContext(
        auditLog,
        scrubbedRequest,
        scrubbedResponse,
        scrubbedResponseItemCount,
        targetResource,
        unknownFields
      )
  }

  public companion object Deserializer : AbstractDeserializer() {
    @JvmStatic
    override fun deserialize(reader: Reader): AuditContext {
      var auditLog = Bytes.empty()
      var scrubbedRequest: Struct? = null
      var scrubbedResponse: Struct? = null
      var scrubbedResponseItemCount = 0
      var targetResource = ""
      var unknownFields: UnknownFieldSet.Builder? = null

      while (true) {
        when (reader.readTag()) {
          0u -> return AuditContext(
            auditLog,
            scrubbedRequest,
            scrubbedResponse,
            scrubbedResponseItemCount,
            targetResource,
            UnknownFieldSet.from(unknownFields)
          )
          10u -> auditLog = reader.readBytes()
          18u -> scrubbedRequest = reader.readMessage(Struct)
          26u -> scrubbedResponse = reader.readMessage(Struct)
          32u -> scrubbedResponseItemCount = reader.readInt32()
          42u -> targetResource = reader.readString()
          else ->
            unknownFields =
              (unknownFields ?: UnknownFieldSet.Builder()).also {
                it.add(reader.readUnknown())
              }
        }
      }
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy