Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
// Generated by protokt version 1.0.0-alpha.8. Do not modify.
// Source: google/api/auth.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.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
/**
* `Authentication` defines the authentication configuration for API methods provided by an API
* service.
*
* Example:
*
* name: calendar.googleapis.com authentication: providers: - id:
* google_calendar_auth jwks_uri: https://www.googleapis.com/oauth2/v1/certs issuer:
* https://securetoken.google.com rules: - selector: "*" requirements:
* provider_id: google_calendar_auth - selector: google.calendar.Delegate oauth:
* canonical_scopes: https://www.googleapis.com/auth/calendar.read
*/
@V1KtGeneratedMessage("google.api.Authentication")
@RtKtGeneratedMessage("google.api.Authentication")
public class Authentication private constructor(
/**
* A list of authentication rules that apply to individual API methods.
*
* **NOTE:** All service configuration rules follow "last one wins" order.
*/
public val rules: List,
/**
* Defines a set of authentication providers that a service supports.
*/
public val providers: List,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (rules.isNotEmpty()) {
result += (sizeOf(26u) * rules.size) + rules.sumOf { sizeOf(it) }
}
if (providers.isNotEmpty()) {
result += (sizeOf(34u) * providers.size) + providers.sumOf { sizeOf(it) }
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
rules.forEach { serializer.writeTag(26u).write(it) }
providers.forEach { serializer.writeTag(34u).write(it) }
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is Authentication &&
other.rules == rules &&
other.providers == providers &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + rules.hashCode()
result = 31 * result + providers.hashCode()
return result
}
override fun toString(): String =
"Authentication(" +
"rules=$rules, " +
"providers=$providers" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): Authentication =
Builder().apply {
rules = [email protected]
providers = [email protected]
unknownFields = [email protected]
builder()
}.build()
@KtBuilderDsl
public class Builder {
public var rules: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var providers: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): Authentication =
Authentication(
unmodifiableList(rules),
unmodifiableList(providers),
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): Authentication {
var rules: MutableList? = null
var providers: MutableList? = null
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return Authentication(
unmodifiableList(rules),
unmodifiableList(providers),
UnknownFieldSet.from(unknownFields)
)
26 ->
rules =
(rules ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readMessage(AuthenticationRule))
}
}
34 ->
providers =
(providers ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readMessage(AuthProvider))
}
}
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): Authentication = Builder().apply(dsl).build()
}
}
/**
* Authentication rules for the service.
*
* By default, if a method has any authentication requirements, every request must include a valid
* credential matching one of the requirements. It's an error to include more than one kind of
* credential in a single request.
*
* If a method doesn't have any auth requirements, request credentials will be ignored.
*/
@V1KtGeneratedMessage("google.api.AuthenticationRule")
@RtKtGeneratedMessage("google.api.AuthenticationRule")
public class AuthenticationRule private constructor(
/**
* Selects the methods to which this rule applies.
*
* Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
*/
public val selector: String,
/**
* The requirements for OAuth credentials.
*/
public val oauth: OAuthRequirements?,
/**
* If true, the service accepts API keys without any other credential. This flag only applies to
* HTTP and gRPC requests.
*/
public val allowWithoutCredential: Boolean,
/**
* Requirements for additional authentication providers.
*/
public val requirements: List,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (selector.isNotEmpty()) {
result += sizeOf(10u) + sizeOf(selector)
}
if (oauth != null) {
result += sizeOf(18u) + sizeOf(oauth)
}
if (allowWithoutCredential) {
result += sizeOf(40u) + 1
}
if (requirements.isNotEmpty()) {
result += (sizeOf(58u) * requirements.size) + requirements.sumOf { sizeOf(it) }
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
if (selector.isNotEmpty()) {
serializer.writeTag(10u).write(selector)
}
if (oauth != null) {
serializer.writeTag(18u).write(oauth)
}
if (allowWithoutCredential) {
serializer.writeTag(40u).write(allowWithoutCredential)
}
requirements.forEach { serializer.writeTag(58u).write(it) }
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is AuthenticationRule &&
other.selector == selector &&
other.oauth == oauth &&
other.allowWithoutCredential == allowWithoutCredential &&
other.requirements == requirements &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + selector.hashCode()
result = 31 * result + oauth.hashCode()
result = 31 * result + allowWithoutCredential.hashCode()
result = 31 * result + requirements.hashCode()
return result
}
override fun toString(): String =
"AuthenticationRule(" +
"selector=$selector, " +
"oauth=$oauth, " +
"allowWithoutCredential=$allowWithoutCredential, " +
"requirements=$requirements" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): AuthenticationRule =
Builder().apply {
selector = [email protected]
oauth = [email protected]
allowWithoutCredential = [email protected]
requirements = [email protected]
unknownFields = [email protected]
builder()
}.build()
@KtBuilderDsl
public class Builder {
public var selector: String = ""
public var oauth: OAuthRequirements? = null
public var allowWithoutCredential: Boolean = false
public var requirements: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): AuthenticationRule =
AuthenticationRule(
selector,
oauth,
allowWithoutCredential,
unmodifiableList(requirements),
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): AuthenticationRule {
var selector = ""
var oauth: OAuthRequirements? = null
var allowWithoutCredential = false
var requirements: MutableList? = null
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return AuthenticationRule(
selector,
oauth,
allowWithoutCredential,
unmodifiableList(requirements),
UnknownFieldSet.from(unknownFields)
)
10 -> selector = deserializer.readString()
18 -> oauth = deserializer.readMessage(OAuthRequirements)
40 -> allowWithoutCredential = deserializer.readBool()
58 ->
requirements =
(requirements ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readMessage(AuthRequirement))
}
}
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): AuthenticationRule = Builder().apply(dsl).build()
}
}
/**
* Specifies a location to extract JWT from an API request.
*/
@V1KtGeneratedMessage("google.api.JwtLocation")
@RtKtGeneratedMessage("google.api.JwtLocation")
public class JwtLocation private constructor(
public val `in`: In?,
/**
* The value prefix. The value format is "value_prefix{token}" Only applies to "in" header type.
* Must be empty for "in" query type. If not empty, the header value has to match (case sensitive)
* this prefix. If not matched, JWT will not be extracted. If matched, JWT will be extracted after
* the prefix is removed.
*
* For example, for "Authorization: Bearer {JWT}", value_prefix="Bearer " with a space at the
* end.
*/
public val valuePrefix: String,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
when (`in`) {
is In.Header ->
result += sizeOf(10u) + sizeOf(`in`.`header`)
is In.Query ->
result += sizeOf(18u) + sizeOf(`in`.query)
is In.Cookie ->
result += sizeOf(34u) + sizeOf(`in`.cookie)
null -> Unit
}
if (valuePrefix.isNotEmpty()) {
result += sizeOf(26u) + sizeOf(valuePrefix)
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
when (`in`) {
is In.Header ->
serializer.writeTag(10u).write(`in`.`header`)
is In.Query ->
serializer.writeTag(18u).write(`in`.query)
is In.Cookie ->
serializer.writeTag(34u).write(`in`.cookie)
null -> Unit
}
if (valuePrefix.isNotEmpty()) {
serializer.writeTag(26u).write(valuePrefix)
}
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is JwtLocation &&
other.`in` == `in` &&
other.valuePrefix == valuePrefix &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + `in`.hashCode()
result = 31 * result + valuePrefix.hashCode()
return result
}
override fun toString(): String =
"JwtLocation(" +
"`in`=$`in`, " +
"valuePrefix=$valuePrefix" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): JwtLocation =
Builder().apply {
`in` = this@JwtLocation.`in`
valuePrefix = [email protected]
unknownFields = [email protected]
builder()
}.build()
public sealed class In {
/**
* Specifies HTTP header name to extract JWT token.
*/
public data class Header(
public val `header`: String
) : In()
/**
* Specifies URL query parameter name to extract JWT token.
*/
public data class Query(
public val query: String
) : In()
/**
* Specifies cookie name to extract JWT token.
*/
public data class Cookie(
public val cookie: String
) : In()
}
@KtBuilderDsl
public class Builder {
public var `in`: In? = null
public var valuePrefix: String = ""
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): JwtLocation =
JwtLocation(
`in`,
valuePrefix,
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): JwtLocation {
var `in`: In? = null
var valuePrefix = ""
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return JwtLocation(
`in`,
valuePrefix,
UnknownFieldSet.from(unknownFields)
)
10 -> `in` = In.Header(deserializer.readString())
18 -> `in` = In.Query(deserializer.readString())
26 -> valuePrefix = deserializer.readString()
34 -> `in` = In.Cookie(deserializer.readString())
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): JwtLocation = Builder().apply(dsl).build()
}
}
/**
* Configuration for an authentication provider, including support for [JSON Web Token
* (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
*/
@V1KtGeneratedMessage("google.api.AuthProvider")
@RtKtGeneratedMessage("google.api.AuthProvider")
public class AuthProvider private constructor(
/**
* The unique identifier of the auth provider. It will be referred to by
* `AuthRequirement.provider_id`.
*
* Example: "bookstore_auth".
*/
public val id: String,
/**
* Identifies the principal that issued the JWT. See
* https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.1 Usually a URL or an
* email address.
*
* Example: https://securetoken.google.com Example: [email protected]
*/
public val issuer: String,
/**
* URL of the provider's public key set to validate signature of the JWT. See [OpenID
* Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata). Optional
* if the key set document: - can be retrieved from [OpenID
* Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html) of the issuer. - can be
* inferred from the email domain of the issuer (e.g. a Google service account).
*
* Example: https://www.googleapis.com/oauth2/v1/certs
*/
public val jwksUri: String,
/**
* The list of JWT
* [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3). that
* are allowed to access. A JWT containing any of these audiences will be accepted. When this setting
* is absent, JWTs with audiences: - "https://[service.name]/[google.protobuf.Api.name]" -
* "https://[service.name]/" will be accepted. For example, if no audiences are in the setting,
* LibraryService API will accept JWTs with the following audiences: -
* https://library-example.googleapis.com/google.example.library.v1.LibraryService -
* https://library-example.googleapis.com/
*
* Example:
*
* audiences: bookstore_android.apps.googleusercontent.com,
* bookstore_web.apps.googleusercontent.com
*/
public val audiences: String,
/**
* Redirect URL if JWT token is required but not present or is expired. Implement authorizationUrl
* of securityDefinitions in OpenAPI spec.
*/
public val authorizationUrl: String,
/**
* Defines the locations to extract the JWT. For now it is only used by the Cloud Endpoints to
* store the OpenAPI extension [x-google-jwt-locations]
* (https://cloud.google.com/endpoints/docs/openapi/openapi-extensions#x-google-jwt-locations)
*
* JWT locations can be one of HTTP headers, URL query parameters or cookies. The rule is that
* the first match wins.
*
* If not specified, default to use following 3 locations: 1) Authorization: Bearer 2)
* x-goog-iap-jwt-assertion 3) access_token query parameter
*
* Default locations can be specified as followings: jwt_locations: - header: Authorization
* value_prefix: "Bearer " - header: x-goog-iap-jwt-assertion - query: access_token
*/
public val jwtLocations: List,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (id.isNotEmpty()) {
result += sizeOf(10u) + sizeOf(id)
}
if (issuer.isNotEmpty()) {
result += sizeOf(18u) + sizeOf(issuer)
}
if (jwksUri.isNotEmpty()) {
result += sizeOf(26u) + sizeOf(jwksUri)
}
if (audiences.isNotEmpty()) {
result += sizeOf(34u) + sizeOf(audiences)
}
if (authorizationUrl.isNotEmpty()) {
result += sizeOf(42u) + sizeOf(authorizationUrl)
}
if (jwtLocations.isNotEmpty()) {
result += (sizeOf(50u) * jwtLocations.size) + jwtLocations.sumOf { sizeOf(it) }
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
if (id.isNotEmpty()) {
serializer.writeTag(10u).write(id)
}
if (issuer.isNotEmpty()) {
serializer.writeTag(18u).write(issuer)
}
if (jwksUri.isNotEmpty()) {
serializer.writeTag(26u).write(jwksUri)
}
if (audiences.isNotEmpty()) {
serializer.writeTag(34u).write(audiences)
}
if (authorizationUrl.isNotEmpty()) {
serializer.writeTag(42u).write(authorizationUrl)
}
jwtLocations.forEach { serializer.writeTag(50u).write(it) }
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is AuthProvider &&
other.id == id &&
other.issuer == issuer &&
other.jwksUri == jwksUri &&
other.audiences == audiences &&
other.authorizationUrl == authorizationUrl &&
other.jwtLocations == jwtLocations &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + id.hashCode()
result = 31 * result + issuer.hashCode()
result = 31 * result + jwksUri.hashCode()
result = 31 * result + audiences.hashCode()
result = 31 * result + authorizationUrl.hashCode()
result = 31 * result + jwtLocations.hashCode()
return result
}
override fun toString(): String =
"AuthProvider(" +
"id=$id, " +
"issuer=$issuer, " +
"jwksUri=$jwksUri, " +
"audiences=$audiences, " +
"authorizationUrl=$authorizationUrl, " +
"jwtLocations=$jwtLocations" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): AuthProvider =
Builder().apply {
id = [email protected]
issuer = [email protected]
jwksUri = [email protected]
audiences = [email protected]
authorizationUrl = [email protected]
jwtLocations = [email protected]
unknownFields = [email protected]
builder()
}.build()
@KtBuilderDsl
public class Builder {
public var id: String = ""
public var issuer: String = ""
public var jwksUri: String = ""
public var audiences: String = ""
public var authorizationUrl: String = ""
public var jwtLocations: List = emptyList()
set(newValue) {
field = copyList(newValue)
}
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): AuthProvider =
AuthProvider(
id,
issuer,
jwksUri,
audiences,
authorizationUrl,
unmodifiableList(jwtLocations),
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): AuthProvider {
var id = ""
var issuer = ""
var jwksUri = ""
var audiences = ""
var authorizationUrl = ""
var jwtLocations: MutableList? = null
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return AuthProvider(
id,
issuer,
jwksUri,
audiences,
authorizationUrl,
unmodifiableList(jwtLocations),
UnknownFieldSet.from(unknownFields)
)
10 -> id = deserializer.readString()
18 -> issuer = deserializer.readString()
26 -> jwksUri = deserializer.readString()
34 -> audiences = deserializer.readString()
42 -> authorizationUrl = deserializer.readString()
50 ->
jwtLocations =
(jwtLocations ?: mutableListOf()).apply {
deserializer.readRepeated(false) {
add(deserializer.readMessage(JwtLocation))
}
}
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): AuthProvider = Builder().apply(dsl).build()
}
}
/**
* OAuth scopes are a way to define data and permissions on data. For example, there are scopes
* defined for "Read-only access to Google Calendar" and "Access to Cloud Platform". Users can consent
* to a scope for an application, giving it permission to access that data on their behalf.
*
* OAuth scope specifications should be fairly coarse grained; a user will need to see and
* understand the text description of what your scope means.
*
* In most cases: use one or at most two OAuth scopes for an entire family of products. If your
* product has multiple APIs, you should probably be sharing the OAuth scope across all of those APIs.
*
* When you need finer grained OAuth consent screens: talk with your product management about how
* developers will use them in practice.
*
* Please note that even though each of the canonical scopes is enough for a request to be accepted
* and passed to the backend, a request can still fail due to the backend requiring additional scopes
* or permissions.
*/
@V1KtGeneratedMessage("google.api.OAuthRequirements")
@RtKtGeneratedMessage("google.api.OAuthRequirements")
public class OAuthRequirements private constructor(
/**
* The list of publicly documented OAuth scopes that are allowed access. An OAuth token containing
* any of these scopes will be accepted.
*
* Example:
*
* canonical_scopes: https://www.googleapis.com/auth/calendar,
* https://www.googleapis.com/auth/calendar.read
*/
public val canonicalScopes: String,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (canonicalScopes.isNotEmpty()) {
result += sizeOf(10u) + sizeOf(canonicalScopes)
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
if (canonicalScopes.isNotEmpty()) {
serializer.writeTag(10u).write(canonicalScopes)
}
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is OAuthRequirements &&
other.canonicalScopes == canonicalScopes &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + canonicalScopes.hashCode()
return result
}
override fun toString(): String =
"OAuthRequirements(" +
"canonicalScopes=$canonicalScopes" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): OAuthRequirements =
Builder().apply {
canonicalScopes = [email protected]
unknownFields = [email protected]
builder()
}.build()
@KtBuilderDsl
public class Builder {
public var canonicalScopes: String = ""
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): OAuthRequirements =
OAuthRequirements(
canonicalScopes,
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): OAuthRequirements {
var canonicalScopes = ""
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return OAuthRequirements(
canonicalScopes,
UnknownFieldSet.from(unknownFields)
)
10 -> canonicalScopes = deserializer.readString()
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): OAuthRequirements = Builder().apply(dsl).build()
}
}
/**
* User-defined authentication requirements, including support for [JSON Web Token
* (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
*/
@V1KtGeneratedMessage("google.api.AuthRequirement")
@RtKtGeneratedMessage("google.api.AuthRequirement")
public class AuthRequirement private constructor(
/**
* [id][google.api.AuthProvider.id] from authentication provider.
*
* Example:
*
* provider_id: bookstore_auth
*/
public val providerId: String,
/**
* NOTE: This will be deprecated soon, once AuthProvider.audiences is implemented and accepted in
* all the runtime components.
*
* The list of JWT
* [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3). that
* are allowed to access. A JWT containing any of these audiences will be accepted. When this setting
* is absent, only JWTs with audience
* "https://[Service_name][google.api.Service.name]/[API_name][google.protobuf.Api.name]" will be
* accepted. For example, if no audiences are in the setting, LibraryService API will only accept
* JWTs with the following audience
* "https://library-example.googleapis.com/google.example.library.v1.LibraryService".
*
* Example:
*
* audiences: bookstore_android.apps.googleusercontent.com,
* bookstore_web.apps.googleusercontent.com
*/
public val audiences: String,
public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
override val messageSize: Int by lazy { messageSize() }
private fun messageSize(): Int {
var result = 0
if (providerId.isNotEmpty()) {
result += sizeOf(10u) + sizeOf(providerId)
}
if (audiences.isNotEmpty()) {
result += sizeOf(18u) + sizeOf(audiences)
}
result += unknownFields.size()
return result
}
override fun serialize(serializer: KtMessageSerializer) {
if (providerId.isNotEmpty()) {
serializer.writeTag(10u).write(providerId)
}
if (audiences.isNotEmpty()) {
serializer.writeTag(18u).write(audiences)
}
serializer.writeUnknown(unknownFields)
}
override fun equals(other: Any?): Boolean =
other is AuthRequirement &&
other.providerId == providerId &&
other.audiences == audiences &&
other.unknownFields == unknownFields
override fun hashCode(): Int {
var result = unknownFields.hashCode()
result = 31 * result + providerId.hashCode()
result = 31 * result + audiences.hashCode()
return result
}
override fun toString(): String =
"AuthRequirement(" +
"providerId=$providerId, " +
"audiences=$audiences" +
if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"
public fun copy(builder: Builder.() -> Unit): AuthRequirement =
Builder().apply {
providerId = [email protected]
audiences = [email protected]
unknownFields = [email protected]
builder()
}.build()
@KtBuilderDsl
public class Builder {
public var providerId: String = ""
public var audiences: String = ""
public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
public fun build(): AuthRequirement =
AuthRequirement(
providerId,
audiences,
unknownFields
)
}
public companion object Deserializer : AbstractKtDeserializer() {
@JvmStatic
override fun deserialize(deserializer: KtMessageDeserializer): AuthRequirement {
var providerId = ""
var audiences = ""
var unknownFields: UnknownFieldSet.Builder? = null
while (true) {
when (deserializer.readTag()) {
0 -> return AuthRequirement(
providerId,
audiences,
UnknownFieldSet.from(unknownFields)
)
10 -> providerId = deserializer.readString()
18 -> audiences = deserializer.readString()
else ->
unknownFields =
(unknownFields ?: UnknownFieldSet.Builder()).also {
it.add(deserializer.readUnknown())
}
}
}
}
@JvmStatic
public operator fun invoke(dsl: Builder.() -> Unit): AuthRequirement = Builder().apply(dsl).build()
}
}