com.google.api.visibility.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
// Generated by protokt version 0.12.0. Do not modify.
// Source: google/api/visibility.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.Int
import kotlin.String
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.MutableList
/**
* `Visibility` defines restrictions for the visibility of service elements. Restrictions are
* specified using visibility labels (e.g., PREVIEW) that are elsewhere linked to users and projects.
*
* Users and projects can have access to more than one visibility label. The effective visibility
* for multiple labels is the union of each label's elements, plus any unrestricted elements.
*
* If an element and its parents have no restrictions, visibility is unconditionally granted.
*
* Example:
*
* visibility: rules: - selector: google.calendar.Calendar.EnhancedSearch
* restriction: PREVIEW - selector: google.calendar.Calendar.Delegate restriction:
* INTERNAL
*
* Here, all methods are publicly visible except for the restricted methods EnhancedSearch and
* Delegate.
*/
@KtGeneratedMessage("google.api.Visibility")
class Visibility private constructor(
/**
* A list of visibility rules that apply to individual API elements.
*
* **NOTE:** All service configuration rules follow "last one wins" order.
*/
val rules: List,
val unknownFields: UnknownFieldSet = UnknownFieldSet.empty(),
) : KtMessage {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (rules.isNotEmpty()) {
result += (sizeof(Tag(1)) * rules.size) + rules.sumOf { sizeof(it) }
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
if (rules.isNotEmpty()) {
rules.forEach { serializer.write(Tag(10)).write(it) }
}
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean = other is Visibility &&
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 = "Visibility(" +
"rules=$rules" +
"${if (unknownFields.isEmpty()) "" else ", unknownFields=$unknownFields"})"
fun copy(dsl: VisibilityDsl.() -> Unit): Visibility = Visibility.Deserializer {
rules = [email protected]
unknownFields = [email protected]
dsl()
}
class VisibilityDsl {
var rules: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
fun build(): Visibility = Visibility(finishList(rules),
unknownFields)
}
companion object Deserializer : KtDeserializer,
(VisibilityDsl.() -> Unit) -> Visibility {
override fun deserialize(deserializer: KtMessageDeserializer): Visibility {
var rules : MutableList? = null
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when(deserializer.readTag()) {
0 -> return Visibility(finishList(rules),
UnknownFieldSet.from(unknownFields))
10 -> rules = (rules ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readMessage(com.google.api.VisibilityRule))
}
}
else -> unknownFields = (unknownFields ?:
UnknownFieldSet.Builder()).also {it.add(deserializer.readUnknown()) }
}
}
}
override fun invoke(dsl: VisibilityDsl.() -> Unit): Visibility =
VisibilityDsl().apply(dsl).build()
}
}
/**
* A visibility rule provides visibility configuration for an individual API element.
*/
@KtGeneratedMessage("google.api.VisibilityRule")
class VisibilityRule private constructor(
/**
* Selects methods, messages, fields, enums, etc. to which this rule applies.
*
* Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
*/
val selector: String,
/**
* A comma-separated list of visibility labels that apply to the `selector`. Any of the listed
* labels can be used to grant the visibility.
*
* If a rule has multiple labels, removing one of the labels but not all of them can break
* clients.
*
* Example:
*
* visibility: rules: - selector: google.calendar.Calendar.EnhancedSearch
* restriction: INTERNAL, PREVIEW
*
* Removing INTERNAL from this restriction will break clients that rely on this method and only
* had access to it through INTERNAL.
*/
val restriction: String,
val unknownFields: UnknownFieldSet = UnknownFieldSet.empty(),
) : KtMessage {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (selector.isNotEmpty()) {
result += sizeof(Tag(1)) + sizeof(selector)
}
if (restriction.isNotEmpty()) {
result += sizeof(Tag(2)) + sizeof(restriction)
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
if (selector.isNotEmpty()) {
serializer.write(Tag(10)).write(selector)
}
if (restriction.isNotEmpty()) {
serializer.write(Tag(18)).write(restriction)
}
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean = other is VisibilityRule &&
other.selector == selector &&
other.restriction == restriction &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + selector.hashCode()
result = 31 * result + restriction.hashCode()
return result
}
override fun toString(): String = "VisibilityRule(" +
"selector=$selector, " +
"restriction=$restriction" +
"${if (unknownFields.isEmpty()) "" else ", unknownFields=$unknownFields"})"
fun copy(dsl: VisibilityRuleDsl.() -> Unit): VisibilityRule =
VisibilityRule.Deserializer {
selector = [email protected]
restriction = [email protected]
unknownFields = [email protected]
dsl()
}
class VisibilityRuleDsl {
var selector: String = ""
var restriction: String = ""
var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
fun build(): VisibilityRule = VisibilityRule(selector,
restriction,
unknownFields)
}
companion object Deserializer : KtDeserializer,
(VisibilityRuleDsl.() -> Unit) -> VisibilityRule {
override fun deserialize(deserializer: KtMessageDeserializer): VisibilityRule {
var selector = ""
var restriction = ""
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when(deserializer.readTag()) {
0 -> return VisibilityRule(selector,
restriction,
UnknownFieldSet.from(unknownFields))
10 -> selector = deserializer.readString()
18 -> restriction = deserializer.readString()
else -> unknownFields = (unknownFields ?:
UnknownFieldSet.Builder()).also {it.add(deserializer.readUnknown()) }
}
}
}
override fun invoke(dsl: VisibilityRuleDsl.() -> Unit): VisibilityRule =
VisibilityRuleDsl().apply(dsl).build()
}
}