protokt.com.google.api.endpoint.kt Maven / Gradle / Ivy
// Generated by protokt version 0.10.0. Do not modify.
// Source: google/api/endpoint.proto
package com.google.api
import com.toasttab.protokt.rt.KtDeserializer
import com.toasttab.protokt.rt.KtGeneratedMessage
import com.toasttab.protokt.rt.KtMessage
import com.toasttab.protokt.rt.KtMessageDeserializer
import com.toasttab.protokt.rt.KtMessageSerializer
import com.toasttab.protokt.rt.Tag
import com.toasttab.protokt.rt.UnknownFieldSet
import com.toasttab.protokt.rt.copyList
import com.toasttab.protokt.rt.finishList
import com.toasttab.protokt.rt.sizeof
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
/**
* `Endpoint` describes a network endpoint 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 service configuration:
*
* name: library-example.googleapis.com endpoints: # Below entry makes
* 'google.example.library.v1.Library' # API be served from endpoint address
* library-example.googleapis.com. # It also allows HTTP OPTIONS calls to be passed to the
* backend, for # it to decide whether the subsequent cross-origin request is # allowed to
* proceed. - name: library-example.googleapis.com allow_cors: true
*/
@KtGeneratedMessage("google.api.Endpoint")
@Suppress("DEPRECATION")
class Endpoint private constructor(
/**
* The canonical name of this endpoint.
*/
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")
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.
*/
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".
*/
val target: String,
val unknownFields: UnknownFieldSet = UnknownFieldSet.empty(),
) : KtMessage {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (name.isNotEmpty()) {
result += sizeof(Tag(1)) + sizeof(name)
}
if (aliases.isNotEmpty()) {
result += (sizeof(Tag(2)) * aliases.size) + aliases.sumOf { sizeof(it) }
}
if (allowCors) {
result += sizeof(Tag(5)) + sizeof(allowCors)
}
if (target.isNotEmpty()) {
result += sizeof(Tag(101)) + sizeof(target)
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
if (name.isNotEmpty()) {
serializer.write(Tag(10)).write(name)
}
if (aliases.isNotEmpty()) {
aliases.forEach { serializer.write(Tag(18)).write(it) }
}
if (allowCors) {
serializer.write(Tag(40)).write(allowCors)
}
if (target.isNotEmpty()) {
serializer.write(Tag(810)).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, " +
"unknownFields=$unknownFields)"
fun copy(dsl: EndpointDsl.() -> Unit): Endpoint = Endpoint.Deserializer {
name = [email protected]
aliases = [email protected]
allowCors = [email protected]
target = [email protected]
unknownFields = [email protected]
dsl()
}
class EndpointDsl {
var name: String = ""
@Deprecated("deprecated in proto")
var aliases: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
var allowCors: Boolean = false
var target: String = ""
var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
fun build(): Endpoint = Endpoint(name,
finishList(aliases),
allowCors,
target,
unknownFields)
}
companion object Deserializer : KtDeserializer,
(EndpointDsl.() -> Unit) -> Endpoint {
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,
finishList(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()) }
}
}
}
override fun invoke(dsl: EndpointDsl.() -> Unit): Endpoint =
EndpointDsl().apply(dsl).build()
}
}