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

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

There is a newer version: 0.12.1
Show newest version
// Generated by protokt version 0.12.0. Do not modify.
// Source: google/api/billing.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

/**
 * Billing related configuration of the service. 
 *
 *  The following example shows how to configure monitored resources and metrics for billing,
 * `consumer_destinations` is the only supported destination and the monitored resources need at least
 * one label key `cloud.googleapis.com/location` to indicate the location of the billing usage, using
 * different monitored resources between monitoring and billing is recommended so they can be evolved
 * independently: 
 *
 *  
 *
 *      monitored_resources:     - type: library.googleapis.com/billing_branch       labels:       -
 * key: cloud.googleapis.com/location         description: |           Predefined label to support
 * billing location restriction.       - key: city         description: |           Custom label to
 * define the city where the library branch is located           in.       - key: name        
 * description: Custom label to define the name of the library branch.     metrics:     - name:
 * library.googleapis.com/book/borrowed_count       metric_kind: DELTA       value_type: INT64      
 * unit: "1"     billing:       consumer_destinations:       - monitored_resource:
 * library.googleapis.com/billing_branch         metrics:         -
 * library.googleapis.com/book/borrowed_count
 */
@KtGeneratedMessage("google.api.Billing")
class Billing private constructor(
    /**
     * Billing configurations for sending metrics to the consumer project. There can be multiple
     * consumer destinations per service, each one must have a different monitored resource type. A
     * metric can be used in at most one consumer destination.
     */
    val consumerDestinations: List,
    val unknownFields: UnknownFieldSet = UnknownFieldSet.empty(),
) : KtMessage {
    override val messageSize: Int by lazy { messageSize() }

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

    override fun serialize(serializer: KtMessageSerializer) {
        if (consumerDestinations.isNotEmpty()) {
            consumerDestinations.forEach { serializer.write(Tag(66)).write(it) }
        }
        serializer.writeUnknown(unknownFields)
    }

    override fun equals(other: Any?): Boolean = other is Billing &&
        other.consumerDestinations == consumerDestinations &&
        other.unknownFields == unknownFields

    override fun hashCode(): Int {
        var result = unknownFields.hashCode()
        result = 31 * result + consumerDestinations.hashCode()
        return result
    }

    override fun toString(): String = "Billing(" +
        "consumerDestinations=$consumerDestinations" +
        "${if (unknownFields.isEmpty()) "" else ", unknownFields=$unknownFields"})"

    fun copy(dsl: BillingDsl.() -> Unit): Billing = Billing.Deserializer {
        consumerDestinations = [email protected]
        unknownFields = [email protected]
        dsl()
    }

    class BillingDsl {
        var consumerDestinations: List = emptyList()
            set(newValue) {
                field = copyList(newValue)
            }

        var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()

        fun build(): Billing = Billing(finishList(consumerDestinations),
         unknownFields)
    }

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

        override fun invoke(dsl: BillingDsl.() -> Unit): Billing =
                BillingDsl().apply(dsl).build()
    }

    /**
     * Configuration of a specific billing destination (Currently only support bill against consumer
     * project).
     */
    @KtGeneratedMessage("google.api.BillingDestination")
    class BillingDestination private constructor(
        /**
         * The monitored resource type. The type must be defined in
         * [Service.monitored_resources][google.api.Service.monitored_resources] section.
         */
        val monitoredResource: String,
        /**
         * Names of the metrics to report to this billing destination. Each name must be defined in
         * [Service.metrics][google.api.Service.metrics] section.
         */
        val metrics: List,
        val unknownFields: UnknownFieldSet = UnknownFieldSet.empty(),
    ) : KtMessage {
        override val messageSize: Int by lazy { messageSize() }

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

        override fun serialize(serializer: KtMessageSerializer) {
            if (monitoredResource.isNotEmpty()) {
                serializer.write(Tag(10)).write(monitoredResource)
            }
            if (metrics.isNotEmpty()) {
                metrics.forEach { serializer.write(Tag(18)).write(it) }
            }
            serializer.writeUnknown(unknownFields)
        }

        override fun equals(other: Any?): Boolean = other is BillingDestination &&
            other.monitoredResource == monitoredResource &&
            other.metrics == metrics &&
            other.unknownFields == unknownFields

        override fun hashCode(): Int {
            var result = unknownFields.hashCode()
            result = 31 * result + monitoredResource.hashCode()
            result = 31 * result + metrics.hashCode()
            return result
        }

        override fun toString(): String = "BillingDestination(" +
            "monitoredResource=$monitoredResource, " +
            "metrics=$metrics" +
            "${if (unknownFields.isEmpty()) "" else ", unknownFields=$unknownFields"})"

        fun copy(dsl: BillingDestinationDsl.() -> Unit): BillingDestination =
                BillingDestination.Deserializer {
            monitoredResource = [email protected]
            metrics = [email protected]
            unknownFields = [email protected]
            dsl()
        }

        class BillingDestinationDsl {
            var monitoredResource: String = ""

            var metrics: List = emptyList()
                set(newValue) {
                    field = copyList(newValue)
                }

            var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()

            fun build(): BillingDestination = BillingDestination(monitoredResource,
            finishList(metrics),
             unknownFields)
        }

        companion object Deserializer : KtDeserializer,
                (BillingDestinationDsl.() -> Unit) -> BillingDestination {
            override fun deserialize(deserializer: KtMessageDeserializer):
                    BillingDestination {
                var monitoredResource = ""
                var metrics : MutableList? = null
                var unknownFields: UnknownFieldSet.Builder? = null
                while (true) {
                    when(deserializer.readTag()) {
                        0 -> return BillingDestination(monitoredResource,
                                finishList(metrics),
                                UnknownFieldSet.from(unknownFields))
                        10 -> monitoredResource = deserializer.readString()
                        18 -> metrics = (metrics ?: mutableListOf()).apply {
                                       deserializer.readRepeated(false) {
                                           add(deserializer.readString())
                                       }
                                   }
                        else -> unknownFields = (unknownFields ?:
                                UnknownFieldSet.Builder()).also {it.add(deserializer.readUnknown())
                                }
                    }
                }
            }

            override fun invoke(dsl: BillingDestinationDsl.() -> Unit): BillingDestination =
                    BillingDestinationDsl().apply(dsl).build()
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy