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

com.google.longrunning.KotlinBuilders.kt Maven / Gradle / Ivy

package com.google.longrunning

import com.google.api.kgax.ProtoBuilder
import com.google.protobuf.Any
import com.google.rpc.Status
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Unit
import kotlin.collections.List

@ProtoBuilder
inline class OperationDsl(val builder: Operation.Builder) {
    inline var name: String
        get() = builder.name
        set(value) {
            builder.name = value
        }

    inline var metadata: Any
        get() = builder.metadata
        set(value) {
            builder.metadata = value
        }

    inline var done: Boolean
        get() = builder.done
        set(value) {
            builder.done = value
        }

    inline var error: Status
        get() = builder.error
        set(value) {
            builder.error = value
        }

    inline var response: Any
        get() = builder.response
        set(value) {
            builder.response = value
        }
}

@ProtoBuilder
inline class GetOperationRequestDsl(val builder: GetOperationRequest.Builder) {
    inline var name: String
        get() = builder.name
        set(value) {
            builder.name = value
        }
}

@ProtoBuilder
inline class ListOperationsRequestDsl(val builder: ListOperationsRequest.Builder) {
    inline var name: String
        get() = builder.name
        set(value) {
            builder.name = value
        }

    inline var filter: String
        get() = builder.filter
        set(value) {
            builder.filter = value
        }

    inline var pageSize: Int
        get() = builder.pageSize
        set(value) {
            builder.pageSize = value
        }

    inline var pageToken: String
        get() = builder.pageToken
        set(value) {
            builder.pageToken = value
        }
}

@ProtoBuilder
inline class ListOperationsResponseDsl(val builder: ListOperationsResponse.Builder) {
    inline var nextPageToken: String
        get() = builder.nextPageToken
        set(value) {
            builder.nextPageToken = value
        }

    inline var operations: List
        get() = builder.operationsList
        set(values) {
            builder.clearOperations()
            builder.addAllOperations(values)
        }

    inline fun operations(vararg values: Operation) {
        builder.addAllOperations(values.toList())
    }
}

@ProtoBuilder
inline class CancelOperationRequestDsl(val builder: CancelOperationRequest.Builder) {
    inline var name: String
        get() = builder.name
        set(value) {
            builder.name = value
        }
}

@ProtoBuilder
inline class DeleteOperationRequestDsl(val builder: DeleteOperationRequest.Builder) {
    inline var name: String
        get() = builder.name
        set(value) {
            builder.name = value
        }
}

fun operation(init: OperationDsl.() -> Unit): Operation {
    val builder = Operation.newBuilder()
    OperationDsl(builder).apply(init)
    return builder.build()
}

fun getOperationRequest(init: GetOperationRequestDsl.() -> Unit): GetOperationRequest {
    val builder = GetOperationRequest.newBuilder()
    GetOperationRequestDsl(builder).apply(init)
    return builder.build()
}

fun listOperationsRequest(init: ListOperationsRequestDsl.() -> Unit): ListOperationsRequest {
    val builder = ListOperationsRequest.newBuilder()
    ListOperationsRequestDsl(builder).apply(init)
    return builder.build()
}

fun listOperationsResponse(init: ListOperationsResponseDsl.() -> Unit): ListOperationsResponse {
    val builder = ListOperationsResponse.newBuilder()
    ListOperationsResponseDsl(builder).apply(init)
    return builder.build()
}

fun cancelOperationRequest(init: CancelOperationRequestDsl.() -> Unit): CancelOperationRequest {
    val builder = CancelOperationRequest.newBuilder()
    CancelOperationRequestDsl(builder).apply(init)
    return builder.build()
}

fun deleteOperationRequest(init: DeleteOperationRequestDsl.() -> Unit): DeleteOperationRequest {
    val builder = DeleteOperationRequest.newBuilder()
    DeleteOperationRequestDsl(builder).apply(init)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy