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

// Generated by protokt version 1.0.0-alpha.8. Do not modify.
// Source: google/rpc/context/audit_context.proto
@file:Suppress("DEPRECATION")

package protokt.v1.google.rpc.context

import protokt.v1.AbstractKtDeserializer
import protokt.v1.AbstractKtMessage
import protokt.v1.Bytes
import protokt.v1.KtBuilderDsl
import protokt.v1.KtMessageDeserializer
import protokt.v1.KtMessageSerializer
import protokt.v1.SizeCodecs.sizeOf
import protokt.v1.UnknownFieldSet
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
import com.toasttab.protokt.rt.KtGeneratedMessage as RtKtGeneratedMessage
import protokt.v1.KtGeneratedMessage as V1KtGeneratedMessage

/**
 * `AuditContext` provides information that is needed for audit logging.
 */
@V1KtGeneratedMessage("google.rpc.context.AuditContext")
@RtKtGeneratedMessage("google.rpc.context.AuditContext")
public class AuditContext private constructor(
  /**
   * Serialized audit log.
   */
  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.
   */
  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.
   */
  public val scrubbedResponse: Struct?,
  /**
   * Number of scrubbed response items.
   */
  public val scrubbedResponseItemCount: Int,
  /**
   * Audit resource name which is scrubbed.
   */
  public val targetResource: String,
  public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
  override val messageSize: Int by lazy { messageSize() }

  private fun messageSize(): Int {
    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()
    return result
  }

  override fun serialize(serializer: KtMessageSerializer) {
    if (auditLog.isNotEmpty()) {
      serializer.writeTag(10u).write(auditLog)
    }
    if (scrubbedRequest != null) {
      serializer.writeTag(18u).write(scrubbedRequest)
    }
    if (scrubbedResponse != null) {
      serializer.writeTag(26u).write(scrubbedResponse)
    }
    if (scrubbedResponseItemCount != 0) {
      serializer.writeTag(32u).write(scrubbedResponseItemCount)
    }
    if (targetResource.isNotEmpty()) {
      serializer.writeTag(42u).write(targetResource)
    }
    serializer.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()

  @KtBuilderDsl
  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 : AbstractKtDeserializer() {
    @JvmStatic
    override fun deserialize(deserializer: KtMessageDeserializer): 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 (deserializer.readTag()) {
          0 -> return AuditContext(
            auditLog,
            scrubbedRequest,
            scrubbedResponse,
            scrubbedResponseItemCount,
            targetResource,
            UnknownFieldSet.from(unknownFields)
          )
          10 -> auditLog = deserializer.readBytes()
          18 -> scrubbedRequest = deserializer.readMessage(Struct)
          26 -> scrubbedResponse = deserializer.readMessage(Struct)
          32 -> scrubbedResponseItemCount = deserializer.readInt32()
          42 -> targetResource = deserializer.readString()
          else ->
            unknownFields =
              (unknownFields ?: UnknownFieldSet.Builder()).also {
                it.add(deserializer.readUnknown())
              }
        }
      }
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy