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

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

// Generated by protokt version 1.0.0-alpha.8. Do not modify.
// Source: google/api/endpoint.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.Deprecated
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

/**
 * `Endpoint` describes a network address of a service that serves a set of APIs. It is commonly
 * known as a service endpoint. A service may expose any number of service endpoints, and all service
 * endpoints share the same service definition, such as quota limits and monitoring metrics.
 *
 *  Example:
 *
 *      type: google.api.Service     name: library-example.googleapis.com     endpoints:       #
 * Declares network address `https://library-example.googleapis.com`       # for service
 * `library-example.googleapis.com`. The `https` scheme       # is implicit for all service endpoints.
 * Other schemes may be       # supported in the future.     - name: library-example.googleapis.com
 *   allow_cors: false     - name: content-staging-library-example.googleapis.com       # Allows HTTP
 * OPTIONS calls to be passed to the API frontend, for it       # to decide whether the subsequent
 * cross-origin request is allowed       # to proceed.       allow_cors: true
 */
@V1KtGeneratedMessage("google.api.Endpoint")
@RtKtGeneratedMessage("google.api.Endpoint")
public class Endpoint private constructor(
  /**
   * The canonical name of this endpoint.
   */
  public val name: String,
  /**
   * Unimplemented. Dot not use.
   *
   *  DEPRECATED: This field is no longer supported. Instead of using aliases, please specify
   * multiple [google.api.Endpoint][google.api.Endpoint] for each of the intended aliases.
   *
   *  Additional names that this endpoint will be hosted on.
   */
  @Deprecated("deprecated in proto")
  public val aliases: List,
  /**
   * Allowing [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing), aka cross-domain
   * traffic, would allow the backends served from this endpoint to receive and respond to HTTP OPTIONS
   * requests. The response will be used by the browser to determine whether the subsequent
   * cross-origin request is allowed to proceed.
   */
  public val allowCors: Boolean,
  /**
   * The specification of an Internet routable address of API frontend that will handle requests to
   * this [API Endpoint](https://cloud.google.com/apis/design/glossary). It should be either a valid
   * IPv4 address or a fully-qualified domain name. For example, "8.8.8.8" or "myservice.appspot.com".
   */
  public val target: 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 (aliases.isNotEmpty()) {
      result += (sizeOf(18u) * aliases.size) + aliases.sumOf { sizeOf(it) }
    }
    if (allowCors) {
      result += sizeOf(40u) + 1
    }
    if (target.isNotEmpty()) {
      result += sizeOf(810u) + sizeOf(target)
    }
    result += unknownFields.size()
    return result
  }

  override fun serialize(serializer: KtMessageSerializer) {
    if (name.isNotEmpty()) {
      serializer.writeTag(10u).write(name)
    }
    aliases.forEach { serializer.writeTag(18u).write(it) }
    if (allowCors) {
      serializer.writeTag(40u).write(allowCors)
    }
    if (target.isNotEmpty()) {
      serializer.writeTag(810u).write(target)
    }
    serializer.writeUnknown(unknownFields)
  }

  override fun equals(other: Any?): Boolean =
    other is Endpoint &&
      other.name == name &&
      other.aliases == aliases &&
      other.allowCors == allowCors &&
      other.target == target &&
      other.unknownFields == unknownFields

  override fun hashCode(): Int {
    var result = unknownFields.hashCode()
    result = 31 * result + name.hashCode()
    result = 31 * result + aliases.hashCode()
    result = 31 * result + allowCors.hashCode()
    result = 31 * result + target.hashCode()
    return result
  }

  override fun toString(): String =
    "Endpoint(" +
      "name=$name, " +
      "aliases=$aliases, " +
      "allowCors=$allowCors, " +
      "target=$target" +
      if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"

  public fun copy(builder: Builder.() -> Unit): Endpoint =
    Builder().apply {
      name = [email protected]
      aliases = [email protected]
      allowCors = [email protected]
      target = [email protected]
      unknownFields = [email protected]
      builder()
    }.build()

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

    @Deprecated("deprecated in proto")
    public var aliases: List = emptyList()
      set(newValue) {
        field = copyList(newValue)
      }

    public var allowCors: Boolean = false

    public var target: String = ""

    public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()

    public fun build(): Endpoint =
      Endpoint(
        name,
        unmodifiableList(aliases),
        allowCors,
        target,
        unknownFields
      )
  }

  public companion object Deserializer : AbstractKtDeserializer() {
    @JvmStatic
    override fun deserialize(deserializer: KtMessageDeserializer): Endpoint {
      var name = ""
      var aliases: MutableList? = null
      var allowCors = false
      var target = ""
      var unknownFields: UnknownFieldSet.Builder? = null

      while (true) {
        when (deserializer.readTag()) {
          0 -> return Endpoint(
            name,
            unmodifiableList(aliases),
            allowCors,
            target,
            UnknownFieldSet.from(unknownFields)
          )
          10 -> name = deserializer.readString()
          18 ->
            aliases =
              (aliases ?: mutableListOf()).apply {
                deserializer.readRepeated(false) {
                  add(deserializer.readString())
                }
              }
          40 -> allowCors = deserializer.readBool()
          810 -> target = deserializer.readString()
          else ->
            unknownFields =
              (unknownFields ?: UnknownFieldSet.Builder()).also {
                it.add(deserializer.readUnknown())
              }
        }
      }
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy