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

com.pulumi.azure.consumption.kotlin.BudgetResourceGroup.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.consumption.kotlin

import com.pulumi.azure.consumption.kotlin.outputs.BudgetResourceGroupFilter
import com.pulumi.azure.consumption.kotlin.outputs.BudgetResourceGroupNotification
import com.pulumi.azure.consumption.kotlin.outputs.BudgetResourceGroupTimePeriod
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.Double
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import com.pulumi.azure.consumption.kotlin.outputs.BudgetResourceGroupFilter.Companion.toKotlin as budgetResourceGroupFilterToKotlin
import com.pulumi.azure.consumption.kotlin.outputs.BudgetResourceGroupNotification.Companion.toKotlin as budgetResourceGroupNotificationToKotlin
import com.pulumi.azure.consumption.kotlin.outputs.BudgetResourceGroupTimePeriod.Companion.toKotlin as budgetResourceGroupTimePeriodToKotlin

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

    public var args: BudgetResourceGroupArgs = BudgetResourceGroupArgs()

    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 BudgetResourceGroupArgsBuilder.() -> Unit) {
        val builder = BudgetResourceGroupArgsBuilder()
        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(): BudgetResourceGroup {
        val builtJavaResource =
            com.pulumi.azure.consumption.BudgetResourceGroup(
                this.name,
                this.args.toJava(),
                this.opts.toJava(),
            )
        return BudgetResourceGroup(builtJavaResource)
    }
}

/**
 * Manages a Resource Group Consumption Budget.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example",
 *     location: "eastus",
 * });
 * const exampleActionGroup = new azure.monitoring.ActionGroup("example", {
 *     name: "example",
 *     resourceGroupName: example.name,
 *     shortName: "example",
 * });
 * const exampleBudgetResourceGroup = new azure.consumption.BudgetResourceGroup("example", {
 *     name: "example",
 *     resourceGroupId: example.id,
 *     amount: 1000,
 *     timeGrain: "Monthly",
 *     timePeriod: {
 *         startDate: "2022-06-01T00:00:00Z",
 *         endDate: "2022-07-01T00:00:00Z",
 *     },
 *     filter: {
 *         dimensions: [{
 *             name: "ResourceId",
 *             values: [exampleActionGroup.id],
 *         }],
 *         tags: [{
 *             name: "foo",
 *             values: [
 *                 "bar",
 *                 "baz",
 *             ],
 *         }],
 *     },
 *     notifications: [
 *         {
 *             enabled: true,
 *             threshold: 90,
 *             operator: "EqualTo",
 *             thresholdType: "Forecasted",
 *             contactEmails: [
 *                 "[email protected]",
 *                 "[email protected]",
 *             ],
 *             contactGroups: [exampleActionGroup.id],
 *             contactRoles: ["Owner"],
 *         },
 *         {
 *             enabled: false,
 *             threshold: 100,
 *             operator: "GreaterThan",
 *             contactEmails: [
 *                 "[email protected]",
 *                 "[email protected]",
 *             ],
 *         },
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example",
 *     location="eastus")
 * example_action_group = azure.monitoring.ActionGroup("example",
 *     name="example",
 *     resource_group_name=example.name,
 *     short_name="example")
 * example_budget_resource_group = azure.consumption.BudgetResourceGroup("example",
 *     name="example",
 *     resource_group_id=example.id,
 *     amount=1000,
 *     time_grain="Monthly",
 *     time_period={
 *         "start_date": "2022-06-01T00:00:00Z",
 *         "end_date": "2022-07-01T00:00:00Z",
 *     },
 *     filter={
 *         "dimensions": [{
 *             "name": "ResourceId",
 *             "values": [example_action_group.id],
 *         }],
 *         "tags": [{
 *             "name": "foo",
 *             "values": [
 *                 "bar",
 *                 "baz",
 *             ],
 *         }],
 *     },
 *     notifications=[
 *         {
 *             "enabled": True,
 *             "threshold": 90,
 *             "operator": "EqualTo",
 *             "threshold_type": "Forecasted",
 *             "contact_emails": [
 *                 "[email protected]",
 *                 "[email protected]",
 *             ],
 *             "contact_groups": [example_action_group.id],
 *             "contact_roles": ["Owner"],
 *         },
 *         {
 *             "enabled": False,
 *             "threshold": 100,
 *             "operator": "GreaterThan",
 *             "contact_emails": [
 *                 "[email protected]",
 *                 "[email protected]",
 *             ],
 *         },
 *     ])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example",
 *         Location = "eastus",
 *     });
 *     var exampleActionGroup = new Azure.Monitoring.ActionGroup("example", new()
 *     {
 *         Name = "example",
 *         ResourceGroupName = example.Name,
 *         ShortName = "example",
 *     });
 *     var exampleBudgetResourceGroup = new Azure.Consumption.BudgetResourceGroup("example", new()
 *     {
 *         Name = "example",
 *         ResourceGroupId = example.Id,
 *         Amount = 1000,
 *         TimeGrain = "Monthly",
 *         TimePeriod = new Azure.Consumption.Inputs.BudgetResourceGroupTimePeriodArgs
 *         {
 *             StartDate = "2022-06-01T00:00:00Z",
 *             EndDate = "2022-07-01T00:00:00Z",
 *         },
 *         Filter = new Azure.Consumption.Inputs.BudgetResourceGroupFilterArgs
 *         {
 *             Dimensions = new[]
 *             {
 *                 new Azure.Consumption.Inputs.BudgetResourceGroupFilterDimensionArgs
 *                 {
 *                     Name = "ResourceId",
 *                     Values = new[]
 *                     {
 *                         exampleActionGroup.Id,
 *                     },
 *                 },
 *             },
 *             Tags = new[]
 *             {
 *                 new Azure.Consumption.Inputs.BudgetResourceGroupFilterTagArgs
 *                 {
 *                     Name = "foo",
 *                     Values = new[]
 *                     {
 *                         "bar",
 *                         "baz",
 *                     },
 *                 },
 *             },
 *         },
 *         Notifications = new[]
 *         {
 *             new Azure.Consumption.Inputs.BudgetResourceGroupNotificationArgs
 *             {
 *                 Enabled = true,
 *                 Threshold = 90,
 *                 Operator = "EqualTo",
 *                 ThresholdType = "Forecasted",
 *                 ContactEmails = new[]
 *                 {
 *                     "[email protected]",
 *                     "[email protected]",
 *                 },
 *                 ContactGroups = new[]
 *                 {
 *                     exampleActionGroup.Id,
 *                 },
 *                 ContactRoles = new[]
 *                 {
 *                     "Owner",
 *                 },
 *             },
 *             new Azure.Consumption.Inputs.BudgetResourceGroupNotificationArgs
 *             {
 *                 Enabled = false,
 *                 Threshold = 100,
 *                 Operator = "GreaterThan",
 *                 ContactEmails = new[]
 *                 {
 *                     "[email protected]",
 *                     "[email protected]",
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/consumption"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/monitoring"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example"),
 * 			Location: pulumi.String("eastus"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleActionGroup, err := monitoring.NewActionGroup(ctx, "example", &monitoring.ActionGroupArgs{
 * 			Name:              pulumi.String("example"),
 * 			ResourceGroupName: example.Name,
 * 			ShortName:         pulumi.String("example"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = consumption.NewBudgetResourceGroup(ctx, "example", &consumption.BudgetResourceGroupArgs{
 * 			Name:            pulumi.String("example"),
 * 			ResourceGroupId: example.ID(),
 * 			Amount:          pulumi.Float64(1000),
 * 			TimeGrain:       pulumi.String("Monthly"),
 * 			TimePeriod: &consumption.BudgetResourceGroupTimePeriodArgs{
 * 				StartDate: pulumi.String("2022-06-01T00:00:00Z"),
 * 				EndDate:   pulumi.String("2022-07-01T00:00:00Z"),
 * 			},
 * 			Filter: &consumption.BudgetResourceGroupFilterArgs{
 * 				Dimensions: consumption.BudgetResourceGroupFilterDimensionArray{
 * 					&consumption.BudgetResourceGroupFilterDimensionArgs{
 * 						Name: pulumi.String("ResourceId"),
 * 						Values: pulumi.StringArray{
 * 							exampleActionGroup.ID(),
 * 						},
 * 					},
 * 				},
 * 				Tags: consumption.BudgetResourceGroupFilterTagArray{
 * 					&consumption.BudgetResourceGroupFilterTagArgs{
 * 						Name: pulumi.String("foo"),
 * 						Values: pulumi.StringArray{
 * 							pulumi.String("bar"),
 * 							pulumi.String("baz"),
 * 						},
 * 					},
 * 				},
 * 			},
 * 			Notifications: consumption.BudgetResourceGroupNotificationArray{
 * 				&consumption.BudgetResourceGroupNotificationArgs{
 * 					Enabled:       pulumi.Bool(true),
 * 					Threshold:     pulumi.Int(90),
 * 					Operator:      pulumi.String("EqualTo"),
 * 					ThresholdType: pulumi.String("Forecasted"),
 * 					ContactEmails: pulumi.StringArray{
 * 						pulumi.String("[email protected]"),
 * 						pulumi.String("[email protected]"),
 * 					},
 * 					ContactGroups: pulumi.StringArray{
 * 						exampleActionGroup.ID(),
 * 					},
 * 					ContactRoles: pulumi.StringArray{
 * 						pulumi.String("Owner"),
 * 					},
 * 				},
 * 				&consumption.BudgetResourceGroupNotificationArgs{
 * 					Enabled:   pulumi.Bool(false),
 * 					Threshold: pulumi.Int(100),
 * 					Operator:  pulumi.String("GreaterThan"),
 * 					ContactEmails: pulumi.StringArray{
 * 						pulumi.String("[email protected]"),
 * 						pulumi.String("[email protected]"),
 * 					},
 * 				},
 * 			},
 * 		})
 * 		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.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.monitoring.ActionGroup;
 * import com.pulumi.azure.monitoring.ActionGroupArgs;
 * import com.pulumi.azure.consumption.BudgetResourceGroup;
 * import com.pulumi.azure.consumption.BudgetResourceGroupArgs;
 * import com.pulumi.azure.consumption.inputs.BudgetResourceGroupTimePeriodArgs;
 * import com.pulumi.azure.consumption.inputs.BudgetResourceGroupFilterArgs;
 * import com.pulumi.azure.consumption.inputs.BudgetResourceGroupNotificationArgs;
 * 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 example = new ResourceGroup("example", ResourceGroupArgs.builder()
 *             .name("example")
 *             .location("eastus")
 *             .build());
 *         var exampleActionGroup = new ActionGroup("exampleActionGroup", ActionGroupArgs.builder()
 *             .name("example")
 *             .resourceGroupName(example.name())
 *             .shortName("example")
 *             .build());
 *         var exampleBudgetResourceGroup = new BudgetResourceGroup("exampleBudgetResourceGroup", BudgetResourceGroupArgs.builder()
 *             .name("example")
 *             .resourceGroupId(example.id())
 *             .amount(1000)
 *             .timeGrain("Monthly")
 *             .timePeriod(BudgetResourceGroupTimePeriodArgs.builder()
 *                 .startDate("2022-06-01T00:00:00Z")
 *                 .endDate("2022-07-01T00:00:00Z")
 *                 .build())
 *             .filter(BudgetResourceGroupFilterArgs.builder()
 *                 .dimensions(BudgetResourceGroupFilterDimensionArgs.builder()
 *                     .name("ResourceId")
 *                     .values(exampleActionGroup.id())
 *                     .build())
 *                 .tags(BudgetResourceGroupFilterTagArgs.builder()
 *                     .name("foo")
 *                     .values(
 *                         "bar",
 *                         "baz")
 *                     .build())
 *                 .build())
 *             .notifications(
 *                 BudgetResourceGroupNotificationArgs.builder()
 *                     .enabled(true)
 *                     .threshold(90)
 *                     .operator("EqualTo")
 *                     .thresholdType("Forecasted")
 *                     .contactEmails(
 *                         "[email protected]",
 *                         "[email protected]")
 *                     .contactGroups(exampleActionGroup.id())
 *                     .contactRoles("Owner")
 *                     .build(),
 *                 BudgetResourceGroupNotificationArgs.builder()
 *                     .enabled(false)
 *                     .threshold(100)
 *                     .operator("GreaterThan")
 *                     .contactEmails(
 *                         "[email protected]",
 *                         "[email protected]")
 *                     .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example
 *       location: eastus
 *   exampleActionGroup:
 *     type: azure:monitoring:ActionGroup
 *     name: example
 *     properties:
 *       name: example
 *       resourceGroupName: ${example.name}
 *       shortName: example
 *   exampleBudgetResourceGroup:
 *     type: azure:consumption:BudgetResourceGroup
 *     name: example
 *     properties:
 *       name: example
 *       resourceGroupId: ${example.id}
 *       amount: 1000
 *       timeGrain: Monthly
 *       timePeriod:
 *         startDate: 2022-06-01T00:00:00Z
 *         endDate: 2022-07-01T00:00:00Z
 *       filter:
 *         dimensions:
 *           - name: ResourceId
 *             values:
 *               - ${exampleActionGroup.id}
 *         tags:
 *           - name: foo
 *             values:
 *               - bar
 *               - baz
 *       notifications:
 *         - enabled: true
 *           threshold: 90
 *           operator: EqualTo
 *           thresholdType: Forecasted
 *           contactEmails:
 *             - [email protected]
 *             - [email protected]
 *           contactGroups:
 *             - ${exampleActionGroup.id}
 *           contactRoles:
 *             - Owner
 *         - enabled: false
 *           threshold: 100
 *           operator: GreaterThan
 *           contactEmails:
 *             - [email protected]
 *             - [email protected]
 * ```
 * 
 * ## Import
 * Resource Group Consumption Budgets can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:consumption/budgetResourceGroup:BudgetResourceGroup example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Consumption/budgets/resourceGroup1
 * ```
 */
public class BudgetResourceGroup internal constructor(
    override val javaResource: com.pulumi.azure.consumption.BudgetResourceGroup,
) : KotlinCustomResource(javaResource, BudgetResourceGroupMapper) {
    /**
     * The total amount of cost to track with the budget.
     */
    public val amount: Output
        get() = javaResource.amount().applyValue({ args0 -> args0 })

    /**
     * (Optional) The ETag of the Resource Group Consumption Budget
     */
    public val etag: Output
        get() = javaResource.etag().applyValue({ args0 -> args0 })

    /**
     * A `filter` block as defined below.
     */
    public val filter: Output?
        get() = javaResource.filter().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    budgetResourceGroupFilterToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * The name which should be used for this Resource Group Consumption Budget. Changing this forces a new Resource Group Consumption Budget to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * One or more `notification` blocks as defined below.
     */
    public val notifications: Output>
        get() = javaResource.notifications().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> budgetResourceGroupNotificationToKotlin(args0) })
            })
        })

    /**
     * The ID of the Resource Group to create the consumption budget for in the form of /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1. Changing this forces a new Resource Group Consumption Budget to be created.
     */
    public val resourceGroupId: Output
        get() = javaResource.resourceGroupId().applyValue({ args0 -> args0 })

    /**
     * The time covered by a budget. Tracking of the amount will be reset based on the time grain. Must be one of `BillingAnnual`, `BillingMonth`, `BillingQuarter`, `Annually`, `Monthly` and `Quarterly`. Defaults to `Monthly`. Changing this forces a new resource to be created.
     */
    public val timeGrain: Output?
        get() = javaResource.timeGrain().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * A `time_period` block as defined below.
     */
    public val timePeriod: Output
        get() = javaResource.timePeriod().applyValue({ args0 ->
            args0.let({ args0 ->
                budgetResourceGroupTimePeriodToKotlin(args0)
            })
        })
}

public object BudgetResourceGroupMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.consumption.BudgetResourceGroup::class == javaResource::class

    override fun map(javaResource: Resource): BudgetResourceGroup = BudgetResourceGroup(
        javaResource
            as com.pulumi.azure.consumption.BudgetResourceGroup,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy