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

com.pulumi.googlenative.spanner.v1.kotlin.Session.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

The newest version!
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.googlenative.spanner.v1.kotlin

import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map

/**
 * Builder for [Session].
 */
@PulumiTagMarker
public class SessionResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: SessionArgs = SessionArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend SessionArgsBuilder.() -> Unit) {
        val builder = SessionArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): Session {
        val builtJavaResource = com.pulumi.googlenative.spanner.v1.Session(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Session(builtJavaResource)
    }
}

/**
 * Creates a new session. A session can be used to perform transactions that read and/or modify data in a Cloud Spanner database. Sessions are meant to be reused for many consecutive transactions. Sessions can only execute one transaction at a time. To execute multiple concurrent read-write/write-only transactions, create multiple sessions. Note that standalone reads and queries use a transaction internally, and count toward the one transaction limit. Active sessions use additional server resources, so it is a good idea to delete idle and unneeded sessions. Aside from explicit deletes, Cloud Spanner may delete sessions for which no operations are sent for more than an hour. If a session is deleted, requests to it return `NOT_FOUND`. Idle sessions can be kept alive by sending a trivial SQL query periodically, e.g., `"SELECT 1"`.
 * Auto-naming is currently not supported for this resource.
 */
public class Session internal constructor(
    override val javaResource: com.pulumi.googlenative.spanner.v1.Session,
) : KotlinCustomResource(javaResource, SessionMapper) {
    /**
     * The approximate timestamp when the session is last used. It is typically earlier than the actual last use time.
     */
    public val approximateLastUseTime: Output
        get() = javaResource.approximateLastUseTime().applyValue({ args0 -> args0 })

    /**
     * The timestamp when the session is created.
     */
    public val createTime: Output
        get() = javaResource.createTime().applyValue({ args0 -> args0 })

    /**
     * The database role which created this session.
     */
    public val creatorRole: Output
        get() = javaResource.creatorRole().applyValue({ args0 -> args0 })

    public val databaseId: Output
        get() = javaResource.databaseId().applyValue({ args0 -> args0 })

    public val instanceId: Output
        get() = javaResource.instanceId().applyValue({ args0 -> args0 })

    /**
     * The labels for the session. * Label keys must be between 1 and 63 characters long and must conform to the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`. * Label values must be between 0 and 63 characters long and must conform to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`. * No more than 64 labels can be associated with a given session. See https://goo.gl/xmQnxf for more information on and examples of labels.
     */
    public val labels: Output>
        get() = javaResource.labels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * The name of the session. This is always system-assigned.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })
}

public object SessionMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.googlenative.spanner.v1.Session::class == javaResource::class

    override fun map(javaResource: Resource): Session = Session(
        javaResource as
            com.pulumi.googlenative.spanner.v1.Session,
    )
}

/**
 * @see [Session].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [Session].
 */
public suspend fun session(name: String, block: suspend SessionResourceBuilder.() -> Unit): Session {
    val builder = SessionResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [Session].
 * @param name The _unique_ name of the resulting resource.
 */
public fun session(name: String): Session {
    val builder = SessionResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy