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

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

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

package com.pulumi.azure.consumption.kotlin

import com.pulumi.azure.consumption.kotlin.outputs.BudgetManagementGroupFilter
import com.pulumi.azure.consumption.kotlin.outputs.BudgetManagementGroupNotification
import com.pulumi.azure.consumption.kotlin.outputs.BudgetManagementGroupTimePeriod
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.BudgetManagementGroupFilter.Companion.toKotlin as budgetManagementGroupFilterToKotlin
import com.pulumi.azure.consumption.kotlin.outputs.BudgetManagementGroupNotification.Companion.toKotlin as budgetManagementGroupNotificationToKotlin
import com.pulumi.azure.consumption.kotlin.outputs.BudgetManagementGroupTimePeriod.Companion.toKotlin as budgetManagementGroupTimePeriodToKotlin

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

    public var args: BudgetManagementGroupArgs = BudgetManagementGroupArgs()

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

/**
 * Manages a Consumption Budget for a Management Group.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.management.Group("example", {displayName: "example"});
 * const exampleResourceGroup = new azure.core.ResourceGroup("example", {
 *     name: "example",
 *     location: "eastus",
 * });
 * const exampleBudgetManagementGroup = new azure.consumption.BudgetManagementGroup("example", {
 *     name: "example",
 *     managementGroupId: example.id,
 *     amount: 1000,
 *     timeGrain: "Monthly",
 *     timePeriod: {
 *         startDate: "2022-06-01T00:00:00Z",
 *         endDate: "2022-07-01T00:00:00Z",
 *     },
 *     filter: {
 *         dimensions: [{
 *             name: "ResourceGroupName",
 *             values: [exampleResourceGroup.name],
 *         }],
 *         tags: [{
 *             name: "foo",
 *             values: [
 *                 "bar",
 *                 "baz",
 *             ],
 *         }],
 *     },
 *     notifications: [
 *         {
 *             enabled: true,
 *             threshold: 90,
 *             operator: "EqualTo",
 *             contactEmails: [
 *                 "[email protected]",
 *                 "[email protected]",
 *             ],
 *         },
 *         {
 *             enabled: false,
 *             threshold: 100,
 *             operator: "GreaterThan",
 *             thresholdType: "Forecasted",
 *             contactEmails: [
 *                 "[email protected]",
 *                 "[email protected]",
 *             ],
 *         },
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.management.Group("example", display_name="example")
 * example_resource_group = azure.core.ResourceGroup("example",
 *     name="example",
 *     location="eastus")
 * example_budget_management_group = azure.consumption.BudgetManagementGroup("example",
 *     name="example",
 *     management_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": "ResourceGroupName",
 *             "values": [example_resource_group.name],
 *         }],
 *         "tags": [{
 *             "name": "foo",
 *             "values": [
 *                 "bar",
 *                 "baz",
 *             ],
 *         }],
 *     },
 *     notifications=[
 *         {
 *             "enabled": True,
 *             "threshold": 90,
 *             "operator": "EqualTo",
 *             "contact_emails": [
 *                 "[email protected]",
 *                 "[email protected]",
 *             ],
 *         },
 *         {
 *             "enabled": False,
 *             "threshold": 100,
 *             "operator": "GreaterThan",
 *             "threshold_type": "Forecasted",
 *             "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.Management.Group("example", new()
 *     {
 *         DisplayName = "example",
 *     });
 *     var exampleResourceGroup = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example",
 *         Location = "eastus",
 *     });
 *     var exampleBudgetManagementGroup = new Azure.Consumption.BudgetManagementGroup("example", new()
 *     {
 *         Name = "example",
 *         ManagementGroupId = example.Id,
 *         Amount = 1000,
 *         TimeGrain = "Monthly",
 *         TimePeriod = new Azure.Consumption.Inputs.BudgetManagementGroupTimePeriodArgs
 *         {
 *             StartDate = "2022-06-01T00:00:00Z",
 *             EndDate = "2022-07-01T00:00:00Z",
 *         },
 *         Filter = new Azure.Consumption.Inputs.BudgetManagementGroupFilterArgs
 *         {
 *             Dimensions = new[]
 *             {
 *                 new Azure.Consumption.Inputs.BudgetManagementGroupFilterDimensionArgs
 *                 {
 *                     Name = "ResourceGroupName",
 *                     Values = new[]
 *                     {
 *                         exampleResourceGroup.Name,
 *                     },
 *                 },
 *             },
 *             Tags = new[]
 *             {
 *                 new Azure.Consumption.Inputs.BudgetManagementGroupFilterTagArgs
 *                 {
 *                     Name = "foo",
 *                     Values = new[]
 *                     {
 *                         "bar",
 *                         "baz",
 *                     },
 *                 },
 *             },
 *         },
 *         Notifications = new[]
 *         {
 *             new Azure.Consumption.Inputs.BudgetManagementGroupNotificationArgs
 *             {
 *                 Enabled = true,
 *                 Threshold = 90,
 *                 Operator = "EqualTo",
 *                 ContactEmails = new[]
 *                 {
 *                     "[email protected]",
 *                     "[email protected]",
 *                 },
 *             },
 *             new Azure.Consumption.Inputs.BudgetManagementGroupNotificationArgs
 *             {
 *                 Enabled = false,
 *                 Threshold = 100,
 *                 Operator = "GreaterThan",
 *                 ThresholdType = "Forecasted",
 *                 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/management"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := management.NewGroup(ctx, "example", &management.GroupArgs{
 * 			DisplayName: pulumi.String("example"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleResourceGroup, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example"),
 * 			Location: pulumi.String("eastus"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = consumption.NewBudgetManagementGroup(ctx, "example", &consumption.BudgetManagementGroupArgs{
 * 			Name:              pulumi.String("example"),
 * 			ManagementGroupId: example.ID(),
 * 			Amount:            pulumi.Float64(1000),
 * 			TimeGrain:         pulumi.String("Monthly"),
 * 			TimePeriod: &consumption.BudgetManagementGroupTimePeriodArgs{
 * 				StartDate: pulumi.String("2022-06-01T00:00:00Z"),
 * 				EndDate:   pulumi.String("2022-07-01T00:00:00Z"),
 * 			},
 * 			Filter: &consumption.BudgetManagementGroupFilterArgs{
 * 				Dimensions: consumption.BudgetManagementGroupFilterDimensionArray{
 * 					&consumption.BudgetManagementGroupFilterDimensionArgs{
 * 						Name: pulumi.String("ResourceGroupName"),
 * 						Values: pulumi.StringArray{
 * 							exampleResourceGroup.Name,
 * 						},
 * 					},
 * 				},
 * 				Tags: consumption.BudgetManagementGroupFilterTagArray{
 * 					&consumption.BudgetManagementGroupFilterTagArgs{
 * 						Name: pulumi.String("foo"),
 * 						Values: pulumi.StringArray{
 * 							pulumi.String("bar"),
 * 							pulumi.String("baz"),
 * 						},
 * 					},
 * 				},
 * 			},
 * 			Notifications: consumption.BudgetManagementGroupNotificationArray{
 * 				&consumption.BudgetManagementGroupNotificationArgs{
 * 					Enabled:   pulumi.Bool(true),
 * 					Threshold: pulumi.Int(90),
 * 					Operator:  pulumi.String("EqualTo"),
 * 					ContactEmails: pulumi.StringArray{
 * 						pulumi.String("[email protected]"),
 * 						pulumi.String("[email protected]"),
 * 					},
 * 				},
 * 				&consumption.BudgetManagementGroupNotificationArgs{
 * 					Enabled:       pulumi.Bool(false),
 * 					Threshold:     pulumi.Int(100),
 * 					Operator:      pulumi.String("GreaterThan"),
 * 					ThresholdType: pulumi.String("Forecasted"),
 * 					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.management.Group;
 * import com.pulumi.azure.management.GroupArgs;
 * import com.pulumi.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.consumption.BudgetManagementGroup;
 * import com.pulumi.azure.consumption.BudgetManagementGroupArgs;
 * import com.pulumi.azure.consumption.inputs.BudgetManagementGroupTimePeriodArgs;
 * import com.pulumi.azure.consumption.inputs.BudgetManagementGroupFilterArgs;
 * import com.pulumi.azure.consumption.inputs.BudgetManagementGroupNotificationArgs;
 * 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 Group("example", GroupArgs.builder()
 *             .displayName("example")
 *             .build());
 *         var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()
 *             .name("example")
 *             .location("eastus")
 *             .build());
 *         var exampleBudgetManagementGroup = new BudgetManagementGroup("exampleBudgetManagementGroup", BudgetManagementGroupArgs.builder()
 *             .name("example")
 *             .managementGroupId(example.id())
 *             .amount(1000)
 *             .timeGrain("Monthly")
 *             .timePeriod(BudgetManagementGroupTimePeriodArgs.builder()
 *                 .startDate("2022-06-01T00:00:00Z")
 *                 .endDate("2022-07-01T00:00:00Z")
 *                 .build())
 *             .filter(BudgetManagementGroupFilterArgs.builder()
 *                 .dimensions(BudgetManagementGroupFilterDimensionArgs.builder()
 *                     .name("ResourceGroupName")
 *                     .values(exampleResourceGroup.name())
 *                     .build())
 *                 .tags(BudgetManagementGroupFilterTagArgs.builder()
 *                     .name("foo")
 *                     .values(
 *                         "bar",
 *                         "baz")
 *                     .build())
 *                 .build())
 *             .notifications(
 *                 BudgetManagementGroupNotificationArgs.builder()
 *                     .enabled(true)
 *                     .threshold(90)
 *                     .operator("EqualTo")
 *                     .contactEmails(
 *                         "[email protected]",
 *                         "[email protected]")
 *                     .build(),
 *                 BudgetManagementGroupNotificationArgs.builder()
 *                     .enabled(false)
 *                     .threshold(100)
 *                     .operator("GreaterThan")
 *                     .thresholdType("Forecasted")
 *                     .contactEmails(
 *                         "[email protected]",
 *                         "[email protected]")
 *                     .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:management:Group
 *     properties:
 *       displayName: example
 *   exampleResourceGroup:
 *     type: azure:core:ResourceGroup
 *     name: example
 *     properties:
 *       name: example
 *       location: eastus
 *   exampleBudgetManagementGroup:
 *     type: azure:consumption:BudgetManagementGroup
 *     name: example
 *     properties:
 *       name: example
 *       managementGroupId: ${example.id}
 *       amount: 1000
 *       timeGrain: Monthly
 *       timePeriod:
 *         startDate: 2022-06-01T00:00:00Z
 *         endDate: 2022-07-01T00:00:00Z
 *       filter:
 *         dimensions:
 *           - name: ResourceGroupName
 *             values:
 *               - ${exampleResourceGroup.name}
 *         tags:
 *           - name: foo
 *             values:
 *               - bar
 *               - baz
 *       notifications:
 *         - enabled: true
 *           threshold: 90
 *           operator: EqualTo
 *           contactEmails:
 *             - [email protected]
 *             - [email protected]
 *         - enabled: false
 *           threshold: 100
 *           operator: GreaterThan
 *           thresholdType: Forecasted
 *           contactEmails:
 *             - [email protected]
 *             - [email protected]
 * ```
 * 
 * ## Import
 * Management Group Consumption Budgets can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:consumption/budgetManagementGroup:BudgetManagementGroup example /providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/budgets/budget1
 * ```
 */
public class BudgetManagementGroup internal constructor(
    override val javaResource: com.pulumi.azure.consumption.BudgetManagementGroup,
) : KotlinCustomResource(javaResource, BudgetManagementGroupMapper) {
    /**
     * 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 Management 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 ->
                    budgetManagementGroupFilterToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * The ID of the Management Group. Changing this forces a new resource to be created.
     */
    public val managementGroupId: Output
        get() = javaResource.managementGroupId().applyValue({ args0 -> args0 })

    /**
     * The name which should be used for this Management Group Consumption Budget. Changing this forces a new resource 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 -> budgetManagementGroupNotificationToKotlin(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 ->
                budgetManagementGroupTimePeriodToKotlin(args0)
            })
        })
}

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy