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

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

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

package protokt.v1.google.api

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

/**
 * ### System parameter configuration
 *
 *  A system parameter is a special kind of parameter defined by the API system, not by an
 * individual API. It is typically mapped to an HTTP header and/or a URL query parameter. This
 * configuration specifies which methods change the names of the system parameters.
 */
@V1KtGeneratedMessage("google.api.SystemParameters")
@RtKtGeneratedMessage("google.api.SystemParameters")
public class SystemParameters private constructor(
  /**
   * Define system parameters.
   *
   *  The parameters defined here will override the default parameters implemented by the system. If
   * this field is missing from the service config, default system parameters will be used. Default
   * system parameters and names is implementation-dependent.
   *
   *  Example: define api key for all methods
   *
   *      system_parameters       rules:         - selector: "*"           parameters:             -
   * name: api_key               url_query_parameter: api_key
   *
   *
   *
   *  Example: define 2 api key names for a specific method.
   *
   *      system_parameters       rules:         - selector: "/ListShelves"
   * parameters:             - name: api_key               http_header: Api-Key1             - name:
   * api_key               http_header: Api-Key2
   *
   *  **NOTE:** All service configuration rules follow "last one wins" order.
   */
  public val rules: List,
  public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
  override val messageSize: Int by lazy { messageSize() }

  private fun messageSize(): Int {
    var result = 0
    if (rules.isNotEmpty()) {
      result += (sizeOf(10u) * rules.size) + rules.sumOf { sizeOf(it) }
    }
    result += unknownFields.size()
    return result
  }

  override fun serialize(serializer: KtMessageSerializer) {
    rules.forEach { serializer.writeTag(10u).write(it) }
    serializer.writeUnknown(unknownFields)
  }

  override fun equals(other: Any?): Boolean =
    other is SystemParameters &&
      other.rules == rules &&
      other.unknownFields == unknownFields

  override fun hashCode(): Int {
    var result = unknownFields.hashCode()
    result = 31 * result + rules.hashCode()
    return result
  }

  override fun toString(): String =
    "SystemParameters(" +
      "rules=$rules" +
      if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"

  public fun copy(builder: Builder.() -> Unit): SystemParameters =
    Builder().apply {
      rules = [email protected]
      unknownFields = [email protected]
      builder()
    }.build()

  @KtBuilderDsl
  public class Builder {
    public var rules: List = emptyList()
      set(newValue) {
        field = copyList(newValue)
      }

    public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()

    public fun build(): SystemParameters =
      SystemParameters(
        unmodifiableList(rules),
        unknownFields
      )
  }

  public companion object Deserializer : AbstractKtDeserializer() {
    @JvmStatic
    override fun deserialize(deserializer: KtMessageDeserializer): SystemParameters {
      var rules: MutableList? = null
      var unknownFields: UnknownFieldSet.Builder? = null

      while (true) {
        when (deserializer.readTag()) {
          0 -> return SystemParameters(
            unmodifiableList(rules),
            UnknownFieldSet.from(unknownFields)
          )
          10 ->
            rules =
              (rules ?: mutableListOf()).apply {
                deserializer.readRepeated(false) {
                  add(deserializer.readMessage(SystemParameterRule))
                }
              }
          else ->
            unknownFields =
              (unknownFields ?: UnknownFieldSet.Builder()).also {
                it.add(deserializer.readUnknown())
              }
        }
      }
    }

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

/**
 * Define a system parameter rule mapping system parameter definitions to methods.
 */
@V1KtGeneratedMessage("google.api.SystemParameterRule")
@RtKtGeneratedMessage("google.api.SystemParameterRule")
public class SystemParameterRule private constructor(
  /**
   * Selects the methods to which this rule applies. Use '*' to indicate all methods in all APIs.
   *
   *  Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
   */
  public val selector: String,
  /**
   * Define parameters. Multiple names may be defined for a parameter. For a given method call, only
   * one of them should be used. If multiple names are used the behavior is implementation-dependent.
   * If none of the specified names are present the behavior is parameter-dependent.
   */
  public val parameters: List,
  public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
  override val messageSize: Int by lazy { messageSize() }

  private fun messageSize(): Int {
    var result = 0
    if (selector.isNotEmpty()) {
      result += sizeOf(10u) + sizeOf(selector)
    }
    if (parameters.isNotEmpty()) {
      result += (sizeOf(18u) * parameters.size) + parameters.sumOf { sizeOf(it) }
    }
    result += unknownFields.size()
    return result
  }

  override fun serialize(serializer: KtMessageSerializer) {
    if (selector.isNotEmpty()) {
      serializer.writeTag(10u).write(selector)
    }
    parameters.forEach { serializer.writeTag(18u).write(it) }
    serializer.writeUnknown(unknownFields)
  }

  override fun equals(other: Any?): Boolean =
    other is SystemParameterRule &&
      other.selector == selector &&
      other.parameters == parameters &&
      other.unknownFields == unknownFields

  override fun hashCode(): Int {
    var result = unknownFields.hashCode()
    result = 31 * result + selector.hashCode()
    result = 31 * result + parameters.hashCode()
    return result
  }

  override fun toString(): String =
    "SystemParameterRule(" +
      "selector=$selector, " +
      "parameters=$parameters" +
      if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"

  public fun copy(builder: Builder.() -> Unit): SystemParameterRule =
    Builder().apply {
      selector = [email protected]
      parameters = [email protected]
      unknownFields = [email protected]
      builder()
    }.build()

  @KtBuilderDsl
  public class Builder {
    public var selector: String = ""

    public var parameters: List = emptyList()
      set(newValue) {
        field = copyList(newValue)
      }

    public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()

    public fun build(): SystemParameterRule =
      SystemParameterRule(
        selector,
        unmodifiableList(parameters),
        unknownFields
      )
  }

  public companion object Deserializer : AbstractKtDeserializer() {
    @JvmStatic
    override fun deserialize(deserializer: KtMessageDeserializer): SystemParameterRule {
      var selector = ""
      var parameters: MutableList? = null
      var unknownFields: UnknownFieldSet.Builder? = null

      while (true) {
        when (deserializer.readTag()) {
          0 -> return SystemParameterRule(
            selector,
            unmodifiableList(parameters),
            UnknownFieldSet.from(unknownFields)
          )
          10 -> selector = deserializer.readString()
          18 ->
            parameters =
              (parameters ?: mutableListOf()).apply {
                deserializer.readRepeated(false) {
                  add(deserializer.readMessage(SystemParameter))
                }
              }
          else ->
            unknownFields =
              (unknownFields ?: UnknownFieldSet.Builder()).also {
                it.add(deserializer.readUnknown())
              }
        }
      }
    }

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

/**
 * Define a parameter's name and location. The parameter may be passed as either an HTTP header or a
 * URL query parameter, and if both are passed the behavior is implementation-dependent.
 */
@V1KtGeneratedMessage("google.api.SystemParameter")
@RtKtGeneratedMessage("google.api.SystemParameter")
public class SystemParameter private constructor(
  /**
   * Define the name of the parameter, such as "api_key" . It is case sensitive.
   */
  public val name: String,
  /**
   * Define the HTTP header name to use for the parameter. It is case insensitive.
   */
  public val httpHeader: String,
  /**
   * Define the URL query parameter name to use for the parameter. It is case sensitive.
   */
  public val urlQueryParameter: String,
  public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
  override val messageSize: Int by lazy { messageSize() }

  private fun messageSize(): Int {
    var result = 0
    if (name.isNotEmpty()) {
      result += sizeOf(10u) + sizeOf(name)
    }
    if (httpHeader.isNotEmpty()) {
      result += sizeOf(18u) + sizeOf(httpHeader)
    }
    if (urlQueryParameter.isNotEmpty()) {
      result += sizeOf(26u) + sizeOf(urlQueryParameter)
    }
    result += unknownFields.size()
    return result
  }

  override fun serialize(serializer: KtMessageSerializer) {
    if (name.isNotEmpty()) {
      serializer.writeTag(10u).write(name)
    }
    if (httpHeader.isNotEmpty()) {
      serializer.writeTag(18u).write(httpHeader)
    }
    if (urlQueryParameter.isNotEmpty()) {
      serializer.writeTag(26u).write(urlQueryParameter)
    }
    serializer.writeUnknown(unknownFields)
  }

  override fun equals(other: Any?): Boolean =
    other is SystemParameter &&
      other.name == name &&
      other.httpHeader == httpHeader &&
      other.urlQueryParameter == urlQueryParameter &&
      other.unknownFields == unknownFields

  override fun hashCode(): Int {
    var result = unknownFields.hashCode()
    result = 31 * result + name.hashCode()
    result = 31 * result + httpHeader.hashCode()
    result = 31 * result + urlQueryParameter.hashCode()
    return result
  }

  override fun toString(): String =
    "SystemParameter(" +
      "name=$name, " +
      "httpHeader=$httpHeader, " +
      "urlQueryParameter=$urlQueryParameter" +
      if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"

  public fun copy(builder: Builder.() -> Unit): SystemParameter =
    Builder().apply {
      name = [email protected]
      httpHeader = [email protected]
      urlQueryParameter = [email protected]
      unknownFields = [email protected]
      builder()
    }.build()

  @KtBuilderDsl
  public class Builder {
    public var name: String = ""

    public var httpHeader: String = ""

    public var urlQueryParameter: String = ""

    public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()

    public fun build(): SystemParameter =
      SystemParameter(
        name,
        httpHeader,
        urlQueryParameter,
        unknownFields
      )
  }

  public companion object Deserializer : AbstractKtDeserializer() {
    @JvmStatic
    override fun deserialize(deserializer: KtMessageDeserializer): SystemParameter {
      var name = ""
      var httpHeader = ""
      var urlQueryParameter = ""
      var unknownFields: UnknownFieldSet.Builder? = null

      while (true) {
        when (deserializer.readTag()) {
          0 -> return SystemParameter(
            name,
            httpHeader,
            urlQueryParameter,
            UnknownFieldSet.from(unknownFields)
          )
          10 -> name = deserializer.readString()
          18 -> httpHeader = deserializer.readString()
          26 -> urlQueryParameter = deserializer.readString()
          else ->
            unknownFields =
              (unknownFields ?: UnknownFieldSet.Builder()).also {
                it.add(deserializer.readUnknown())
              }
        }
      }
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy