commonMain.protokt.v1.google.api.policy.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/policy.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.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
/**
* Google API Policy Annotation
*
* This message defines a simple API policy annotation that can be used to annotate API request and
* response message fields with applicable policies. One field may have multiple applicable policies
* that must all be satisfied before a request can be processed. This policy annotation is used to
* generate the overall policy that will be used for automatic runtime policy enforcement and
* documentation generation.
*/
@GeneratedMessage("google.api.FieldPolicy")
public class FieldPolicy private constructor(
/**
* Selects one or more request or response message fields to apply this `FieldPolicy`.
*
* When a `FieldPolicy` is used in proto annotation, the selector must be left as empty. The
* service config generator will automatically fill the correct value.
*
* When a `FieldPolicy` is used in service config, the selector must be a comma-separated string
* with valid request or response field paths, such as "foo.bar" or "foo.bar,foo.baz".
*/
@GeneratedProperty(1)
public val selector: String,
/**
* Specifies the required permission(s) for the resource referred to by the field. It requires the
* field contains a valid resource reference, and the request must pass the permission checks to
* proceed. For example, "resourcemanager.projects.get".
*/
@GeneratedProperty(2)
public val resourcePermission: String,
/**
* Specifies the resource type for the resource referred to by the field.
*/
@GeneratedProperty(3)
public val resourceType: String,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractMessage() {
private val `$messageSize`: Int by lazy {
var result = 0
if (selector.isNotEmpty()) {
result += sizeOf(10u) + sizeOf(selector)
}
if (resourcePermission.isNotEmpty()) {
result += sizeOf(18u) + sizeOf(resourcePermission)
}
if (resourceType.isNotEmpty()) {
result += sizeOf(26u) + sizeOf(resourceType)
}
result += unknownFields.size()
result
}
override fun messageSize(): Int = `$messageSize`
override fun serialize(writer: Writer) {
if (selector.isNotEmpty()) {
writer.writeTag(10u).write(selector)
}
if (resourcePermission.isNotEmpty()) {
writer.writeTag(18u).write(resourcePermission)
}
if (resourceType.isNotEmpty()) {
writer.writeTag(26u).write(resourceType)
}
writer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is FieldPolicy &&
other.selector == selector &&
other.resourcePermission == resourcePermission &&
other.resourceType == resourceType &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + selector.hashCode()
result = 31 * result + resourcePermission.hashCode()
result = 31 * result + resourceType.hashCode()
return result
}
override fun toString(): String =
"FieldPolicy(" +
"selector=$selector, " +
"resourcePermission=$resourcePermission, " +
"resourceType=$resourceType" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): FieldPolicy =
Builder().apply {
selector = [email protected]
resourcePermission = [email protected]
resourceType = [email protected]
unknownFields = [email protected]
builder()
}.build()
@BuilderDsl
public class Builder {
public var selector: String = ""
public var resourcePermission: String = ""
public var resourceType: String = ""
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): FieldPolicy =
FieldPolicy(
selector,
resourcePermission,
resourceType,
unknownFields
)
}
public companion object Deserializer : AbstractDeserializer() {
@JvmStatic
override fun deserialize(reader: Reader): FieldPolicy {
var selector = ""
var resourcePermission = ""
var resourceType = ""
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (reader.readTag()) {
0u -> return FieldPolicy(
selector,
resourcePermission,
resourceType,
UnknownFieldSet.from(unknownFields)
)
10u -> selector = reader.readString()
18u -> resourcePermission = reader.readString()
26u -> resourceType = reader.readString()
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(reader.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): FieldPolicy = Builder().apply(dsl).build()
}
}
/**
* Defines policies applying to an RPC method.
*/
@GeneratedMessage("google.api.MethodPolicy")
public class MethodPolicy private constructor(
/**
* Policies that are applicable to the request message.
*/
@GeneratedProperty(2)
public val requestPolicies: List,
/**
* Selects a method to which these policies should be enforced, for example,
* "google.pubsub.v1.Subscriber.CreateSubscription".
*
* Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
*
* NOTE: This field must not be set in the proto annotation. It will be automatically filled by
* the service config compiler .
*/
@GeneratedProperty(9)
public val selector: String,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractMessage() {
private val `$messageSize`: Int by lazy {
var result = 0
if (requestPolicies.isNotEmpty()) {
result += (sizeOf(18u) * requestPolicies.size) + requestPolicies.sumOf { sizeOf(it) }
}
if (selector.isNotEmpty()) {
result += sizeOf(74u) + sizeOf(selector)
}
result += unknownFields.size()
result
}
override fun messageSize(): Int = `$messageSize`
override fun serialize(writer: Writer) {
requestPolicies.forEach { writer.writeTag(18u).write(it) }
if (selector.isNotEmpty()) {
writer.writeTag(74u).write(selector)
}
writer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is MethodPolicy &&
other.requestPolicies == requestPolicies &&
other.selector == selector &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + requestPolicies.hashCode()
result = 31 * result + selector.hashCode()
return result
}
override fun toString(): String =
"MethodPolicy(" +
"requestPolicies=$requestPolicies, " +
"selector=$selector" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): MethodPolicy =
Builder().apply {
requestPolicies = [email protected]
selector = [email protected]
unknownFields = [email protected]
builder()
}.build()
@BuilderDsl
public class Builder {
public var requestPolicies: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var selector: String = ""
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): MethodPolicy =
MethodPolicy(
unmodifiableList(requestPolicies),
selector,
unknownFields
)
}
public companion object Deserializer : AbstractDeserializer() {
@JvmStatic
override fun deserialize(reader: Reader): MethodPolicy {
var requestPolicies: MutableList? = null
var selector = ""
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (reader.readTag()) {
0u -> return MethodPolicy(
unmodifiableList(requestPolicies),
selector,
UnknownFieldSet.from(unknownFields)
)
18u ->
requestPolicies =
(requestPolicies ?: mutableListOf()).apply {
reader.readRepeated(false) {
add(reader.readMessage(FieldPolicy))
}
}
74u -> selector = reader.readString()
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(reader.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): MethodPolicy = Builder().apply(dsl).build()
}
}