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

org.signal.cdsi.proto.ClientResponse.kt Maven / Gradle / Ivy

There is a newer version: 2.15.3_unofficial_107
Show newest version
// Code generated by Wire protocol buffer compiler, do not edit.
// Source: org.signal.cdsi.ClientResponse in CDSI.proto
package org.signal.cdsi.proto

import com.squareup.wire.FieldEncoding
import com.squareup.wire.Message
import com.squareup.wire.ProtoAdapter
import com.squareup.wire.ProtoReader
import com.squareup.wire.ProtoWriter
import com.squareup.wire.ReverseProtoWriter
import com.squareup.wire.Syntax.PROTO_3
import com.squareup.wire.WireField
import kotlin.Any
import kotlin.Boolean
import kotlin.Int
import kotlin.Long
import kotlin.String
import kotlin.Unit
import kotlin.jvm.JvmField
import okio.ByteString

public class ClientResponse(
  /**
   * Each triple is an 8-byte e164, a 16-byte PNI, and a 16-byte ACI.
   * If the e164 was not found, PNI and ACI are all zeros.  If the PNI
   * was found but the ACI was not, the PNI will be non-zero and the ACI
   * will be all zeros.  ACI will be returned if one of the returned
   * PNIs has an ACI/UAK pair that matches.
   *
   * Should the request be successful (IE: a successful status returned),
   * |e164_pni_aci_triple| will always equal |e164| of the request,
   * so the entire marshalled size of the response will be (2+32)*|e164|,
   * where the additional 2 bytes are the id/type/length additions of the
   * protobuf marshaling added to each byte array.  This avoids any data
   * leakage based on the size of the encrypted output.
   */
  @field:WireField(
    tag = 1,
    adapter = "com.squareup.wire.ProtoAdapter#BYTES",
    label = WireField.Label.OMIT_IDENTITY,
  )
  @JvmField
  public val e164PniAciTriples: ByteString = ByteString.EMPTY,
  /**
   * If the user has run out of quota for lookups, they will receive
   * a response with just the following field set, followed by a websocket
   * closure of type 4008 (RESOURCE_EXHAUSTED).  Should they retry exactly
   * the same request after the provided number of seconds has passed,
   * we expect it should work.
   */
  @field:WireField(
    tag = 2,
    adapter = "com.squareup.wire.ProtoAdapter#INT32",
    label = WireField.Label.OMIT_IDENTITY,
  )
  @JvmField
  public val retryAfterSecs: Int = 0,
  /**
   * A token which allows subsequent calls' rate limiting to discount the
   * e164s sent up in this request, only counting those in the next
   * request's new_e164s.
   */
  @field:WireField(
    tag = 3,
    adapter = "com.squareup.wire.ProtoAdapter#BYTES",
    label = WireField.Label.OMIT_IDENTITY,
  )
  @JvmField
  public val token: ByteString = ByteString.EMPTY,
  /**
   * On a successful response to a token_ack request, the number of permits
   * that were deducted from the user's rate-limit in order to process the
   * request
   */
  @field:WireField(
    tag = 4,
    adapter = "com.squareup.wire.ProtoAdapter#INT32",
    label = WireField.Label.OMIT_IDENTITY,
  )
  @JvmField
  public val debugPermitsUsed: Int = 0,
  unknownFields: ByteString = ByteString.EMPTY,
) : Message(ADAPTER, unknownFields) {
  public override fun newBuilder(): Builder {
    val builder = Builder()
    builder.e164PniAciTriples = e164PniAciTriples
    builder.retryAfterSecs = retryAfterSecs
    builder.token = token
    builder.debugPermitsUsed = debugPermitsUsed
    builder.addUnknownFields(unknownFields)
    return builder
  }

  public override fun equals(other: Any?): Boolean {
    if (other === this) return true
    if (other !is ClientResponse) return false
    if (unknownFields != other.unknownFields) return false
    if (e164PniAciTriples != other.e164PniAciTriples) return false
    if (retryAfterSecs != other.retryAfterSecs) return false
    if (token != other.token) return false
    if (debugPermitsUsed != other.debugPermitsUsed) return false
    return true
  }

  public override fun hashCode(): Int {
    var result = super.hashCode
    if (result == 0) {
      result = unknownFields.hashCode()
      result = result * 37 + e164PniAciTriples.hashCode()
      result = result * 37 + retryAfterSecs.hashCode()
      result = result * 37 + token.hashCode()
      result = result * 37 + debugPermitsUsed.hashCode()
      super.hashCode = result
    }
    return result
  }

  public override fun toString(): String {
    val result = mutableListOf()
    result += """e164PniAciTriples=$e164PniAciTriples"""
    result += """retryAfterSecs=$retryAfterSecs"""
    result += """token=$token"""
    result += """debugPermitsUsed=$debugPermitsUsed"""
    return result.joinToString(prefix = "ClientResponse{", separator = ", ", postfix = "}")
  }

  public fun copy(
    e164PniAciTriples: ByteString = this.e164PniAciTriples,
    retryAfterSecs: Int = this.retryAfterSecs,
    token: ByteString = this.token,
    debugPermitsUsed: Int = this.debugPermitsUsed,
    unknownFields: ByteString = this.unknownFields,
  ): ClientResponse = ClientResponse(e164PniAciTriples, retryAfterSecs, token, debugPermitsUsed,
      unknownFields)

  public class Builder : Message.Builder() {
    @JvmField
    public var e164PniAciTriples: ByteString = ByteString.EMPTY

    @JvmField
    public var retryAfterSecs: Int = 0

    @JvmField
    public var token: ByteString = ByteString.EMPTY

    @JvmField
    public var debugPermitsUsed: Int = 0

    /**
     * Each triple is an 8-byte e164, a 16-byte PNI, and a 16-byte ACI.
     * If the e164 was not found, PNI and ACI are all zeros.  If the PNI
     * was found but the ACI was not, the PNI will be non-zero and the ACI
     * will be all zeros.  ACI will be returned if one of the returned
     * PNIs has an ACI/UAK pair that matches.
     *
     * Should the request be successful (IE: a successful status returned),
     * |e164_pni_aci_triple| will always equal |e164| of the request,
     * so the entire marshalled size of the response will be (2+32)*|e164|,
     * where the additional 2 bytes are the id/type/length additions of the
     * protobuf marshaling added to each byte array.  This avoids any data
     * leakage based on the size of the encrypted output.
     */
    public fun e164PniAciTriples(e164PniAciTriples: ByteString): Builder {
      this.e164PniAciTriples = e164PniAciTriples
      return this
    }

    /**
     * If the user has run out of quota for lookups, they will receive
     * a response with just the following field set, followed by a websocket
     * closure of type 4008 (RESOURCE_EXHAUSTED).  Should they retry exactly
     * the same request after the provided number of seconds has passed,
     * we expect it should work.
     */
    public fun retryAfterSecs(retryAfterSecs: Int): Builder {
      this.retryAfterSecs = retryAfterSecs
      return this
    }

    /**
     * A token which allows subsequent calls' rate limiting to discount the
     * e164s sent up in this request, only counting those in the next
     * request's new_e164s.
     */
    public fun token(token: ByteString): Builder {
      this.token = token
      return this
    }

    /**
     * On a successful response to a token_ack request, the number of permits
     * that were deducted from the user's rate-limit in order to process the
     * request
     */
    public fun debugPermitsUsed(debugPermitsUsed: Int): Builder {
      this.debugPermitsUsed = debugPermitsUsed
      return this
    }

    public override fun build(): ClientResponse = ClientResponse(
      e164PniAciTriples = e164PniAciTriples,
      retryAfterSecs = retryAfterSecs,
      token = token,
      debugPermitsUsed = debugPermitsUsed,
      unknownFields = buildUnknownFields()
    )
  }

  public companion object {
    @JvmField
    public val ADAPTER: ProtoAdapter = object : ProtoAdapter(
      FieldEncoding.LENGTH_DELIMITED, 
      ClientResponse::class, 
      "type.googleapis.com/org.signal.cdsi.ClientResponse", 
      PROTO_3, 
      null, 
      "CDSI.proto"
    ) {
      public override fun encodedSize(`value`: ClientResponse): Int {
        var size = value.unknownFields.size
        if (value.e164PniAciTriples != ByteString.EMPTY) size +=
            ProtoAdapter.BYTES.encodedSizeWithTag(1, value.e164PniAciTriples)
        if (value.retryAfterSecs != 0) size += ProtoAdapter.INT32.encodedSizeWithTag(2,
            value.retryAfterSecs)
        if (value.token != ByteString.EMPTY) size += ProtoAdapter.BYTES.encodedSizeWithTag(3,
            value.token)
        if (value.debugPermitsUsed != 0) size += ProtoAdapter.INT32.encodedSizeWithTag(4,
            value.debugPermitsUsed)
        return size
      }

      public override fun encode(writer: ProtoWriter, `value`: ClientResponse): Unit {
        if (value.e164PniAciTriples != ByteString.EMPTY) ProtoAdapter.BYTES.encodeWithTag(writer, 1,
            value.e164PniAciTriples)
        if (value.retryAfterSecs != 0) ProtoAdapter.INT32.encodeWithTag(writer, 2,
            value.retryAfterSecs)
        if (value.token != ByteString.EMPTY) ProtoAdapter.BYTES.encodeWithTag(writer, 3,
            value.token)
        if (value.debugPermitsUsed != 0) ProtoAdapter.INT32.encodeWithTag(writer, 4,
            value.debugPermitsUsed)
        writer.writeBytes(value.unknownFields)
      }

      public override fun encode(writer: ReverseProtoWriter, `value`: ClientResponse): Unit {
        writer.writeBytes(value.unknownFields)
        if (value.debugPermitsUsed != 0) ProtoAdapter.INT32.encodeWithTag(writer, 4,
            value.debugPermitsUsed)
        if (value.token != ByteString.EMPTY) ProtoAdapter.BYTES.encodeWithTag(writer, 3,
            value.token)
        if (value.retryAfterSecs != 0) ProtoAdapter.INT32.encodeWithTag(writer, 2,
            value.retryAfterSecs)
        if (value.e164PniAciTriples != ByteString.EMPTY) ProtoAdapter.BYTES.encodeWithTag(writer, 1,
            value.e164PniAciTriples)
      }

      public override fun decode(reader: ProtoReader): ClientResponse {
        var e164PniAciTriples: ByteString = ByteString.EMPTY
        var retryAfterSecs: Int = 0
        var token: ByteString = ByteString.EMPTY
        var debugPermitsUsed: Int = 0
        val unknownFields = reader.forEachTag { tag ->
          when (tag) {
            1 -> e164PniAciTriples = ProtoAdapter.BYTES.decode(reader)
            2 -> retryAfterSecs = ProtoAdapter.INT32.decode(reader)
            3 -> token = ProtoAdapter.BYTES.decode(reader)
            4 -> debugPermitsUsed = ProtoAdapter.INT32.decode(reader)
            else -> reader.readUnknownField(tag)
          }
        }
        return ClientResponse(
          e164PniAciTriples = e164PniAciTriples,
          retryAfterSecs = retryAfterSecs,
          token = token,
          debugPermitsUsed = debugPermitsUsed,
          unknownFields = unknownFields
        )
      }

      public override fun redact(`value`: ClientResponse): ClientResponse = value.copy(
        unknownFields = ByteString.EMPTY
      )
    }

    private const val serialVersionUID: Long = 0L
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy