All Downloads are FREE. Search and download functionalities are using the official Maven repository.

protokt.com.google.api.consumer.kt Maven / Gradle / Ivy

// Generated by protokt version 0.10.0. Do not modify.
// Source: google/api/consumer.proto
package com.google.api

import com.toasttab.protokt.rt.KtDeserializer
import com.toasttab.protokt.rt.KtEnum
import com.toasttab.protokt.rt.KtEnumDeserializer
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

/**
 * 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
 */
@KtGeneratedMessage("google.api.ProjectProperties")
class ProjectProperties private constructor(
    /**
     * List of per consumer project-specific properties.
     */
    val properties: List,
    val unknownFields: UnknownFieldSet = UnknownFieldSet.empty(),
) : KtMessage {
    override val messageSize: Int by lazy { messageSize() }

    private fun messageSize(): Int {
        var result = 0
        if (properties.isNotEmpty()) {
            result += (sizeof(Tag(1)) * properties.size) + properties.sumOf { sizeof(it) } 
        }
        result += unknownFields.size()
        return result
    }

    override fun serialize(serializer: KtMessageSerializer) {
        if (properties.isNotEmpty()) {
            properties.forEach { serializer.write(Tag(10)).write(it) }
        }
        serializer.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, " +
        "unknownFields=$unknownFields)"

    fun copy(dsl: ProjectPropertiesDsl.() -> Unit): ProjectProperties =
            ProjectProperties.Deserializer {
        properties = [email protected]
        unknownFields = [email protected]
        dsl()
    }

    class ProjectPropertiesDsl {
        var properties: List = emptyList()
            set(newValue) {
                field = copyList(newValue)
            }

        var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()

        fun build(): ProjectProperties = ProjectProperties(finishList(properties),
         unknownFields)
    }

    companion object Deserializer : KtDeserializer,
            (ProjectPropertiesDsl.() -> Unit) -> ProjectProperties {
        override fun deserialize(deserializer: KtMessageDeserializer): ProjectProperties {
            var properties : MutableList? = null
            var unknownFields: UnknownFieldSet.Builder? = null
            while (true) {
                when(deserializer.readTag()) {
                    0 -> return ProjectProperties(finishList(properties),
                            UnknownFieldSet.from(unknownFields))
                    10 -> properties = (properties ?: mutableListOf()).apply {
                                   deserializer.readRepeated(false) {
                                       add(deserializer.readMessage(com.google.api.Property))
                                   }
                               }
                    else -> unknownFields = (unknownFields ?:
                            UnknownFieldSet.Builder()).also {it.add(deserializer.readUnknown()) }
                }
            }
        }

        override fun invoke(dsl: ProjectPropertiesDsl.() -> Unit): ProjectProperties =
                ProjectPropertiesDsl().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.
 */
@KtGeneratedMessage("google.api.Property")
class Property private constructor(
    /**
     * The name of the property (a.k.a key).
     */
    val name: String,
    /**
     * The type of this property.
     */
    val type: PropertyType,
    /**
     * The description of the property
     */
    val description: 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 (type.value != 0) {
            result += sizeof(Tag(2)) + sizeof(type) 
        }
        if (description.isNotEmpty()) {
            result += sizeof(Tag(3)) + sizeof(description) 
        }
        result += unknownFields.size()
        return result
    }

    override fun serialize(serializer: KtMessageSerializer) {
        if (name.isNotEmpty()) {
            serializer.write(Tag(10)).write(name)
        }
        if (type.value != 0) {
            serializer.write(Tag(16)).write(type)
        }
        if (description.isNotEmpty()) {
            serializer.write(Tag(26)).write(description)
        }
        serializer.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, " +
        "unknownFields=$unknownFields)"

    fun copy(dsl: PropertyDsl.() -> Unit): Property = Property.Deserializer {
        name = [email protected]
        type = [email protected]
        description = [email protected]
        unknownFields = [email protected]
        dsl()
    }

    class PropertyDsl {
        var name: String = ""

        var type: PropertyType = PropertyType.from(0)

        var description: String = ""

        var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()

        fun build(): Property = Property(name,
        type,
        description,
         unknownFields)
    }

    companion object Deserializer : KtDeserializer,
            (PropertyDsl.() -> Unit) -> Property {
        override fun deserialize(deserializer: KtMessageDeserializer): Property {
            var name = ""
            var type = PropertyType.from(0)
            var description = ""
            var unknownFields: UnknownFieldSet.Builder? = null
            while (true) {
                when(deserializer.readTag()) {
                    0 -> return Property(name,
                            type,
                            description,
                            UnknownFieldSet.from(unknownFields))
                    10 -> name = deserializer.readString()
                    16 -> type = deserializer.readEnum(com.google.api.Property.PropertyType)
                    26 -> description = deserializer.readString()
                    else -> unknownFields = (unknownFields ?:
                            UnknownFieldSet.Builder()).also {it.add(deserializer.readUnknown()) }
                }
            }
        }

        override fun invoke(dsl: PropertyDsl.() -> Unit): Property =
                PropertyDsl().apply(dsl).build()
    }

    /**
     * Supported data type of the property values
     */
    sealed class PropertyType(
        override val `value`: Int,
        override val name: String,
    ) : KtEnum() {
        /**
         * The type is unspecified, and will result in an error.
         */
        object UNSPECIFIED : PropertyType(0, "UNSPECIFIED")

        /**
         * The type is `int64`.
         */
        object INT64 : PropertyType(1, "INT64")

        /**
         * The type is `bool`.
         */
        object BOOL : PropertyType(2, "BOOL")

        /**
         * The type is `string`.
         */
        object STRING : PropertyType(3, "STRING")

        /**
         * The type is 'double'.
         */
        object DOUBLE : PropertyType(4, "DOUBLE")

        class UNRECOGNIZED(
            `value`: Int,
        ) : PropertyType(value, "UNRECOGNIZED")

        companion object Deserializer : KtEnumDeserializer {
            override fun from(`value`: Int): PropertyType = when (value) {
              0 -> UNSPECIFIED
              1 -> INT64
              2 -> BOOL
              3 -> STRING
              4 -> DOUBLE
              else -> UNRECOGNIZED(value)
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy