commonMain.protokt.v1.google.api.consumer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of proto-google-common-protos-lite Show documentation
Show all versions of proto-google-common-protos-lite Show documentation
Protobuf compiler and runtime for Kotlin
The newest version!
// Generated by protokt version 1.0.0-beta.2. Do not modify.
// Source: google/api/consumer.proto
@file:Suppress("DEPRECATION")
package protokt.v1.google.api
import protokt.v1.AbstractDeserializer
import protokt.v1.AbstractMessage
import protokt.v1.BuilderDsl
import protokt.v1.Collections.copyList
import protokt.v1.Collections.unmodifiableList
import protokt.v1.Enum
import protokt.v1.EnumReader
import protokt.v1.GeneratedMessage
import protokt.v1.GeneratedProperty
import protokt.v1.Reader
import protokt.v1.SizeCodecs.sizeOf
import protokt.v1.UnknownFieldSet
import protokt.v1.Writer
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
/**
* A descriptor for defining project properties for a service. One service may have many consumer
* projects, and the service may want to behave differently depending on some properties on the
* project. For example, a project may be associated with a school, or a business, or a government
* agency, a business type property on the project may affect how a service responds to the client.
* This descriptor defines which properties are allowed to be set on a project.
*
* Example:
*
* project_properties: properties: - name: NO_WATERMARK type: BOOL
* description: Allows usage of the API without watermarks. - name: EXTENDED_TILE_CACHE_PERIOD
* type: INT64
*/
@GeneratedMessage("google.api.ProjectProperties")
public class ProjectProperties private constructor(
/**
* List of per consumer project-specific properties.
*/
@GeneratedProperty(1)
public val properties: List,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractMessage() {
private val `$messageSize`: Int by lazy {
var result = 0
if (properties.isNotEmpty()) {
result += (sizeOf(10u) * properties.size) + properties.sumOf { sizeOf(it) }
}
result += unknownFields.size()
result
}
override fun messageSize(): Int = `$messageSize`
override fun serialize(writer: Writer) {
properties.forEach { writer.writeTag(10u).write(it) }
writer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is ProjectProperties &&
other.properties == properties &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + properties.hashCode()
return result
}
override fun toString(): String =
"ProjectProperties(" +
"properties=$properties" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): ProjectProperties =
Builder().apply {
properties = [email protected]
unknownFields = [email protected]
builder()
}.build()
@BuilderDsl
public class Builder {
public var properties: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): ProjectProperties =
ProjectProperties(
unmodifiableList(properties),
unknownFields
)
}
public companion object Deserializer : AbstractDeserializer() {
@JvmStatic
override fun deserialize(reader: Reader): ProjectProperties {
var properties: MutableList? = null
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (reader.readTag()) {
0u -> return ProjectProperties(
unmodifiableList(properties),
UnknownFieldSet.from(unknownFields)
)
10u ->
properties =
(properties ?: mutableListOf()).apply {
reader.readRepeated(false) {
add(reader.readMessage(Property))
}
}
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(reader.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): ProjectProperties = Builder().apply(dsl).build()
}
}
/**
* Defines project properties.
*
* API services can define properties that can be assigned to consumer projects so that backends
* can perform response customization without having to make additional calls or maintain additional
* storage. For example, Maps API defines properties that controls map tile cache period, or whether to
* embed a watermark in a result.
*
* These values can be set via API producer console. Only API providers can define and set these
* properties.
*/
@GeneratedMessage("google.api.Property")
public class Property private constructor(
/**
* The name of the property (a.k.a key).
*/
@GeneratedProperty(1)
public val name: String,
/**
* The type of this property.
*/
@GeneratedProperty(2)
public val type: PropertyType,
/**
* The description of the property
*/
@GeneratedProperty(3)
public val description: String,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractMessage() {
private val `$messageSize`: Int by lazy {
var result = 0
if (name.isNotEmpty()) {
result += sizeOf(10u) + sizeOf(name)
}
if (type.value != 0) {
result += sizeOf(16u) + sizeOf(type)
}
if (description.isNotEmpty()) {
result += sizeOf(26u) + sizeOf(description)
}
result += unknownFields.size()
result
}
override fun messageSize(): Int = `$messageSize`
override fun serialize(writer: Writer) {
if (name.isNotEmpty()) {
writer.writeTag(10u).write(name)
}
if (type.value != 0) {
writer.writeTag(16u).write(type)
}
if (description.isNotEmpty()) {
writer.writeTag(26u).write(description)
}
writer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is Property &&
other.name == name &&
other.type == type &&
other.description == description &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + name.hashCode()
result = 31 * result + type.hashCode()
result = 31 * result + description.hashCode()
return result
}
override fun toString(): String =
"Property(" +
"name=$name, " +
"type=$type, " +
"description=$description" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): Property =
Builder().apply {
name = [email protected]
type = [email protected]
description = [email protected]
unknownFields = [email protected]
builder()
}.build()
@BuilderDsl
public class Builder {
public var name: String = ""
public var type: PropertyType = PropertyType.from(0)
public var description: String = ""
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): Property =
Property(
name,
type,
description,
unknownFields
)
}
public companion object Deserializer : AbstractDeserializer() {
@JvmStatic
override fun deserialize(reader: Reader): Property {
var name = ""
var type = PropertyType.from(0)
var description = ""
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (reader.readTag()) {
0u -> return Property(
name,
type,
description,
UnknownFieldSet.from(unknownFields)
)
10u -> name = reader.readString()
16u -> type = reader.readEnum(PropertyType)
26u -> description = reader.readString()
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(reader.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): Property = Builder().apply(dsl).build()
}
/**
* Supported data type of the property values
*/
public sealed class PropertyType(
override val `value`: Int,
override val name: String
) : Enum() {
/**
* The type is unspecified, and will result in an error.
*/
public object UNSPECIFIED : PropertyType(0, "UNSPECIFIED")
/**
* The type is `int64`.
*/
public object INT64 : PropertyType(1, "INT64")
/**
* The type is `bool`.
*/
public object BOOL : PropertyType(2, "BOOL")
/**
* The type is `string`.
*/
public object STRING : PropertyType(3, "STRING")
/**
* The type is 'double'.
*/
public object DOUBLE : PropertyType(4, "DOUBLE")
public class UNRECOGNIZED(
`value`: Int
) : PropertyType(value, "UNRECOGNIZED")
public companion object Deserializer : EnumReader {
override fun from(`value`: Int): PropertyType =
when (value) {
0 -> UNSPECIFIED
1 -> INT64
2 -> BOOL
3 -> STRING
4 -> DOUBLE
else -> UNRECOGNIZED(value)
}
}
}
}