Please wait. This can take some minutes ...
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.
com.pulumi.gcp.compute.kotlin.RegionCommitment.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.compute.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.compute.kotlin.outputs.RegionCommitmentLicenseResource
import com.pulumi.gcp.compute.kotlin.outputs.RegionCommitmentResource
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.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import com.pulumi.gcp.compute.kotlin.outputs.RegionCommitmentLicenseResource.Companion.toKotlin as regionCommitmentLicenseResourceToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.RegionCommitmentResource.Companion.toKotlin as regionCommitmentResourceToKotlin
/**
* Builder for [RegionCommitment].
*/
@PulumiTagMarker
public class RegionCommitmentResourceBuilder internal constructor() {
public var name: String? = null
public var args: RegionCommitmentArgs = RegionCommitmentArgs()
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 RegionCommitmentArgsBuilder.() -> Unit) {
val builder = RegionCommitmentArgsBuilder()
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(): RegionCommitment {
val builtJavaResource = com.pulumi.gcp.compute.RegionCommitment(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return RegionCommitment(builtJavaResource)
}
}
/**
* Represents a regional Commitment resource.
* Creating a commitment resource means that you are purchasing a committed
* use contract with an explicit start and end time. You can create commitments
* based on vCPUs and memory usage and receive discounted rates.
* To get more information about RegionCommitment, see:
* * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/regionCommitments)
* * How-to Guides
* * [Committed use discounts for Compute Engine](https://cloud.google.com/compute/docs/instances/committed-use-discounts-overview)
* ## Example Usage
* ### Compute Region Commitment Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const foobar = new gcp.compute.RegionCommitment("foobar", {
* name: "my-region-commitment",
* plan: "THIRTY_SIX_MONTH",
* resources: [
* {
* type: "VCPU",
* amount: "4",
* },
* {
* type: "MEMORY",
* amount: "9",
* },
* ],
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* foobar = gcp.compute.RegionCommitment("foobar",
* name="my-region-commitment",
* plan="THIRTY_SIX_MONTH",
* resources=[
* {
* "type": "VCPU",
* "amount": "4",
* },
* {
* "type": "MEMORY",
* "amount": "9",
* },
* ])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var foobar = new Gcp.Compute.RegionCommitment("foobar", new()
* {
* Name = "my-region-commitment",
* Plan = "THIRTY_SIX_MONTH",
* Resources = new[]
* {
* new Gcp.Compute.Inputs.RegionCommitmentResourceArgs
* {
* Type = "VCPU",
* Amount = "4",
* },
* new Gcp.Compute.Inputs.RegionCommitmentResourceArgs
* {
* Type = "MEMORY",
* Amount = "9",
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := compute.NewRegionCommitment(ctx, "foobar", &compute.RegionCommitmentArgs{
* Name: pulumi.String("my-region-commitment"),
* Plan: pulumi.String("THIRTY_SIX_MONTH"),
* Resources: compute.RegionCommitmentResourceArray{
* &compute.RegionCommitmentResourceArgs{
* Type: pulumi.String("VCPU"),
* Amount: pulumi.String("4"),
* },
* &compute.RegionCommitmentResourceArgs{
* Type: pulumi.String("MEMORY"),
* Amount: pulumi.String("9"),
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.compute.RegionCommitment;
* import com.pulumi.gcp.compute.RegionCommitmentArgs;
* import com.pulumi.gcp.compute.inputs.RegionCommitmentResourceArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* var foobar = new RegionCommitment("foobar", RegionCommitmentArgs.builder()
* .name("my-region-commitment")
* .plan("THIRTY_SIX_MONTH")
* .resources(
* RegionCommitmentResourceArgs.builder()
* .type("VCPU")
* .amount("4")
* .build(),
* RegionCommitmentResourceArgs.builder()
* .type("MEMORY")
* .amount("9")
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* foobar:
* type: gcp:compute:RegionCommitment
* properties:
* name: my-region-commitment
* plan: THIRTY_SIX_MONTH
* resources:
* - type: VCPU
* amount: '4'
* - type: MEMORY
* amount: '9'
* ```
*
* ### Compute Region Commitment Full
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const foobar = new gcp.compute.RegionCommitment("foobar", {
* name: "my-full-commitment",
* description: "some description",
* plan: "THIRTY_SIX_MONTH",
* type: "MEMORY_OPTIMIZED",
* category: "MACHINE",
* autoRenew: true,
* resources: [
* {
* type: "VCPU",
* amount: "4",
* },
* {
* type: "MEMORY",
* amount: "9",
* },
* ],
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* foobar = gcp.compute.RegionCommitment("foobar",
* name="my-full-commitment",
* description="some description",
* plan="THIRTY_SIX_MONTH",
* type="MEMORY_OPTIMIZED",
* category="MACHINE",
* auto_renew=True,
* resources=[
* {
* "type": "VCPU",
* "amount": "4",
* },
* {
* "type": "MEMORY",
* "amount": "9",
* },
* ])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var foobar = new Gcp.Compute.RegionCommitment("foobar", new()
* {
* Name = "my-full-commitment",
* Description = "some description",
* Plan = "THIRTY_SIX_MONTH",
* Type = "MEMORY_OPTIMIZED",
* Category = "MACHINE",
* AutoRenew = true,
* Resources = new[]
* {
* new Gcp.Compute.Inputs.RegionCommitmentResourceArgs
* {
* Type = "VCPU",
* Amount = "4",
* },
* new Gcp.Compute.Inputs.RegionCommitmentResourceArgs
* {
* Type = "MEMORY",
* Amount = "9",
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := compute.NewRegionCommitment(ctx, "foobar", &compute.RegionCommitmentArgs{
* Name: pulumi.String("my-full-commitment"),
* Description: pulumi.String("some description"),
* Plan: pulumi.String("THIRTY_SIX_MONTH"),
* Type: pulumi.String("MEMORY_OPTIMIZED"),
* Category: pulumi.String("MACHINE"),
* AutoRenew: pulumi.Bool(true),
* Resources: compute.RegionCommitmentResourceArray{
* &compute.RegionCommitmentResourceArgs{
* Type: pulumi.String("VCPU"),
* Amount: pulumi.String("4"),
* },
* &compute.RegionCommitmentResourceArgs{
* Type: pulumi.String("MEMORY"),
* Amount: pulumi.String("9"),
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.compute.RegionCommitment;
* import com.pulumi.gcp.compute.RegionCommitmentArgs;
* import com.pulumi.gcp.compute.inputs.RegionCommitmentResourceArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* var foobar = new RegionCommitment("foobar", RegionCommitmentArgs.builder()
* .name("my-full-commitment")
* .description("some description")
* .plan("THIRTY_SIX_MONTH")
* .type("MEMORY_OPTIMIZED")
* .category("MACHINE")
* .autoRenew(true)
* .resources(
* RegionCommitmentResourceArgs.builder()
* .type("VCPU")
* .amount("4")
* .build(),
* RegionCommitmentResourceArgs.builder()
* .type("MEMORY")
* .amount("9")
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* foobar:
* type: gcp:compute:RegionCommitment
* properties:
* name: my-full-commitment
* description: some description
* plan: THIRTY_SIX_MONTH
* type: MEMORY_OPTIMIZED
* category: MACHINE
* autoRenew: true
* resources:
* - type: VCPU
* amount: '4'
* - type: MEMORY
* amount: '9'
* ```
*
* ## Import
* RegionCommitment can be imported using any of these accepted formats:
* * `projects/{{project}}/regions/{{region}}/commitments/{{name}}`
* * `{{project}}/{{region}}/{{name}}`
* * `{{region}}/{{name}}`
* * `{{name}}`
* When using the `pulumi import` command, RegionCommitment can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:compute/regionCommitment:RegionCommitment default projects/{{project}}/regions/{{region}}/commitments/{{name}}
* ```
* ```sh
* $ pulumi import gcp:compute/regionCommitment:RegionCommitment default {{project}}/{{region}}/{{name}}
* ```
* ```sh
* $ pulumi import gcp:compute/regionCommitment:RegionCommitment default {{region}}/{{name}}
* ```
* ```sh
* $ pulumi import gcp:compute/regionCommitment:RegionCommitment default {{name}}
* ```
*/
public class RegionCommitment internal constructor(
override val javaResource: com.pulumi.gcp.compute.RegionCommitment,
) : KotlinCustomResource(javaResource, RegionCommitmentMapper) {
/**
* Specifies whether to enable automatic renewal for the commitment.
* The default value is false if not specified.
* If the field is set to true, the commitment will be automatically renewed for either
* one or three years according to the terms of the existing commitment.
*/
public val autoRenew: Output
get() = javaResource.autoRenew().applyValue({ args0 -> args0 })
/**
* The category of the commitment. Category MACHINE specifies commitments composed of
* machine resources such as VCPU or MEMORY, listed in resources. Category LICENSE
* specifies commitments composed of software licenses, listed in licenseResources.
* Note that only MACHINE commitments should have a Type specified.
* Possible values are: `LICENSE`, `MACHINE`.
*/
public val category: Output
get() = javaResource.category().applyValue({ args0 -> args0 })
/**
* Unique identifier for the resource.
*/
public val commitmentId: Output
get() = javaResource.commitmentId().applyValue({ args0 -> args0 })
/**
* Creation timestamp in RFC3339 text format.
*/
public val creationTimestamp: Output
get() = javaResource.creationTimestamp().applyValue({ args0 -> args0 })
/**
* An optional description of this resource.
*/
public val description: Output?
get() = javaResource.description().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* Commitment end time in RFC3339 text format.
*/
public val endTimestamp: Output
get() = javaResource.endTimestamp().applyValue({ args0 -> args0 })
/**
* The license specification required as part of a license commitment.
* Structure is documented below.
*/
public val licenseResource: Output?
get() = javaResource.licenseResource().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> regionCommitmentLicenseResourceToKotlin(args0) })
}).orElse(null)
})
/**
* Name of the resource. The name must be 1-63 characters long and match
* the regular expression `a-z?` which means the
* first character must be a lowercase letter, and all following
* characters must be a dash, lowercase letter, or digit, except the last
* character, which cannot be a dash.
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* The plan for this commitment, which determines duration and discount rate.
* The currently supported plans are TWELVE_MONTH (1 year), and THIRTY_SIX_MONTH (3 years).
* Possible values are: `TWELVE_MONTH`, `THIRTY_SIX_MONTH`.
* - - -
*/
public val plan: Output
get() = javaResource.plan().applyValue({ args0 -> args0 })
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
public val project: Output
get() = javaResource.project().applyValue({ args0 -> args0 })
/**
* URL of the region where this commitment may be used.
*/
public val region: Output
get() = javaResource.region().applyValue({ args0 -> args0 })
/**
* A list of commitment amounts for particular resources.
* Note that VCPU and MEMORY resource commitments must occur together.
* Structure is documented below.
*/
public val resources: Output>?
get() = javaResource.resources().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> regionCommitmentResourceToKotlin(args0) })
})
}).orElse(null)
})
/**
* The URI of the created resource.
*/
public val selfLink: Output
get() = javaResource.selfLink().applyValue({ args0 -> args0 })
/**
* Commitment start time in RFC3339 text format.
*/
public val startTimestamp: Output
get() = javaResource.startTimestamp().applyValue({ args0 -> args0 })
/**
* Status of the commitment with regards to eventual expiration
* (each commitment has an end date defined).
*/
public val status: Output
get() = javaResource.status().applyValue({ args0 -> args0 })
/**
* A human-readable explanation of the status.
*/
public val statusMessage: Output
get() = javaResource.statusMessage().applyValue({ args0 -> args0 })
/**
* The type of commitment, which affects the discount rate and the eligible resources.
* The type could be one of the following value: `MEMORY_OPTIMIZED`, `ACCELERATOR_OPTIMIZED`,
* `GENERAL_PURPOSE_N1`, `GENERAL_PURPOSE_N2`, `GENERAL_PURPOSE_N2D`, `GENERAL_PURPOSE_E2`,
* `GENERAL_PURPOSE_T2D`, `GENERAL_PURPOSE_C3`, `COMPUTE_OPTIMIZED_C2`, `COMPUTE_OPTIMIZED_C2D` and
* `GRAPHICS_OPTIMIZED_G2`
*/
public val type: Output
get() = javaResource.type().applyValue({ args0 -> args0 })
}
public object RegionCommitmentMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.compute.RegionCommitment::class == javaResource::class
override fun map(javaResource: Resource): RegionCommitment = RegionCommitment(
javaResource as
com.pulumi.gcp.compute.RegionCommitment,
)
}
/**
* @see [RegionCommitment].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [RegionCommitment].
*/
public suspend fun regionCommitment(
name: String,
block: suspend RegionCommitmentResourceBuilder.() -> Unit,
): RegionCommitment {
val builder = RegionCommitmentResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [RegionCommitment].
* @param name The _unique_ name of the resulting resource.
*/
public fun regionCommitment(name: String): RegionCommitment {
val builder = RegionCommitmentResourceBuilder()
builder.name(name)
return builder.build()
}