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

com.pulumi.azure.policy.kotlin.PolicySetDefinitionArgs.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.

There is a newer version: 6.15.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.policy.kotlin

import com.pulumi.azure.policy.PolicySetDefinitionArgs.builder
import com.pulumi.azure.policy.kotlin.inputs.PolicySetDefinitionPolicyDefinitionGroupArgs
import com.pulumi.azure.policy.kotlin.inputs.PolicySetDefinitionPolicyDefinitionGroupArgsBuilder
import com.pulumi.azure.policy.kotlin.inputs.PolicySetDefinitionPolicyDefinitionReferenceArgs
import com.pulumi.azure.policy.kotlin.inputs.PolicySetDefinitionPolicyDefinitionReferenceArgsBuilder
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.jvm.JvmName

/**
 * Manages a policy set definition.
 * > **NOTE:**  Policy set definitions (also known as policy initiatives) do not take effect until they are assigned to a scope using a Policy Set Assignment.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.policy.PolicySetDefinition("example", {
 *     name: "testPolicySet",
 *     policyType: "Custom",
 *     displayName: "Test Policy Set",
 *     parameters: `    {
 *         "allowedLocations": {
 *             "type": "Array",
 *             "metadata": {
 *                 "description": "The list of allowed locations for resources.",
 *                 "displayName": "Allowed locations",
 *                 "strongType": "location"
 *             }
 *         }
 *     }
 * `,
 *     policyDefinitionReferences: [{
 *         policyDefinitionId: "/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988",
 *         parameterValues: `    {
 *       "listOfAllowedLocations": {"value": "[parameters('allowedLocations')]"}
 *     }
 * `,
 *     }],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.policy.PolicySetDefinition("example",
 *     name="testPolicySet",
 *     policy_type="Custom",
 *     display_name="Test Policy Set",
 *     parameters="""    {
 *         "allowedLocations": {
 *             "type": "Array",
 *             "metadata": {
 *                 "description": "The list of allowed locations for resources.",
 *                 "displayName": "Allowed locations",
 *                 "strongType": "location"
 *             }
 *         }
 *     }
 * """,
 *     policy_definition_references=[azure.policy.PolicySetDefinitionPolicyDefinitionReferenceArgs(
 *         policy_definition_id="/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988",
 *         parameter_values="""    {
 *       "listOfAllowedLocations": {"value": "[parameters('allowedLocations')]"}
 *     }
 * """,
 *     )])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Azure.Policy.PolicySetDefinition("example", new()
 *     {
 *         Name = "testPolicySet",
 *         PolicyType = "Custom",
 *         DisplayName = "Test Policy Set",
 *         Parameters = @"    {
 *         ""allowedLocations"": {
 *             ""type"": ""Array"",
 *             ""metadata"": {
 *                 ""description"": ""The list of allowed locations for resources."",
 *                 ""displayName"": ""Allowed locations"",
 *                 ""strongType"": ""location""
 *             }
 *         }
 *     }
 * ",
 *         PolicyDefinitionReferences = new[]
 *         {
 *             new Azure.Policy.Inputs.PolicySetDefinitionPolicyDefinitionReferenceArgs
 *             {
 *                 PolicyDefinitionId = "/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988",
 *                 ParameterValues = @"    {
 *       ""listOfAllowedLocations"": {""value"": ""[parameters('allowedLocations')]""}
 *     }
 * ",
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/policy"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := policy.NewPolicySetDefinition(ctx, "example", &policy.PolicySetDefinitionArgs{
 * 			Name:        pulumi.String("testPolicySet"),
 * 			PolicyType:  pulumi.String("Custom"),
 * 			DisplayName: pulumi.String("Test Policy Set"),
 * 			Parameters: pulumi.String(`    {
 *         "allowedLocations": {
 *             "type": "Array",
 *             "metadata": {
 *                 "description": "The list of allowed locations for resources.",
 *                 "displayName": "Allowed locations",
 *                 "strongType": "location"
 *             }
 *         }
 *     }
 * `),
 * 			PolicyDefinitionReferences: policy.PolicySetDefinitionPolicyDefinitionReferenceArray{
 * 				&policy.PolicySetDefinitionPolicyDefinitionReferenceArgs{
 * 					PolicyDefinitionId: pulumi.String("/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988"),
 * 					ParameterValues:    pulumi.String("    {\n      \"listOfAllowedLocations\": {\"value\": \"[parameters('allowedLocations')]\"}\n    }\n"),
 * 				},
 * 			},
 * 		})
 * 		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.policy.PolicySetDefinition;
 * import com.pulumi.azure.policy.PolicySetDefinitionArgs;
 * import com.pulumi.azure.policy.inputs.PolicySetDefinitionPolicyDefinitionReferenceArgs;
 * 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 PolicySetDefinition("example", PolicySetDefinitionArgs.builder()
 *             .name("testPolicySet")
 *             .policyType("Custom")
 *             .displayName("Test Policy Set")
 *             .parameters("""
 *     {
 *         "allowedLocations": {
 *             "type": "Array",
 *             "metadata": {
 *                 "description": "The list of allowed locations for resources.",
 *                 "displayName": "Allowed locations",
 *                 "strongType": "location"
 *             }
 *         }
 *     }
 *             """)
 *             .policyDefinitionReferences(PolicySetDefinitionPolicyDefinitionReferenceArgs.builder()
 *                 .policyDefinitionId("/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988")
 *                 .parameterValues("""
 *     {
 *       "listOfAllowedLocations": {"value": "[parameters('allowedLocations')]"}
 *     }
 *                 """)
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:policy:PolicySetDefinition
 *     properties:
 *       name: testPolicySet
 *       policyType: Custom
 *       displayName: Test Policy Set
 *       parameters: |2
 *             {
 *                 "allowedLocations": {
 *                     "type": "Array",
 *                     "metadata": {
 *                         "description": "The list of allowed locations for resources.",
 *                         "displayName": "Allowed locations",
 *                         "strongType": "location"
 *                     }
 *                 }
 *             }
 *       policyDefinitionReferences:
 *         - policyDefinitionId: /providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988
 *           parameterValues: |2
 *                 {
 *                   "listOfAllowedLocations": {"value": "[parameters('allowedLocations')]"}
 *                 }
 * ```
 * 
 * ## Import
 * Policy Set Definitions can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:policy/policySetDefinition:PolicySetDefinition example /subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/policySetDefinitions/testPolicySet
 * ```
 * or
 * ```sh
 * $ pulumi import azure:policy/policySetDefinition:PolicySetDefinition example /providers/Microsoft.Management/managementGroups/my-mgmt-group-id/providers/Microsoft.Authorization/policySetDefinitions/testPolicySet
 * ```
 * @property description The description of the policy set definition.
 * @property displayName The display name of the policy set definition.
 * @property managementGroupId The id of the Management Group where this policy set definition should be defined. Changing this forces a new resource to be created.
 * @property metadata The metadata for the policy set definition. This is a JSON object representing additional metadata that should be stored with the policy definition.
 * @property name The name of the policy set definition. Changing this forces a new resource to be created.
 * @property parameters Parameters for the policy set definition. This field is a JSON object that allows you to parameterize your policy definition.
 * @property policyDefinitionGroups One or more `policy_definition_group` blocks as defined below.
 * @property policyDefinitionReferences One or more `policy_definition_reference` blocks as defined below.
 * @property policyType The policy set type. Possible values are `BuiltIn`, `Custom`, `NotSpecified` and `Static`. Changing this forces a new resource to be created.
 */
public data class PolicySetDefinitionArgs(
    public val description: Output? = null,
    public val displayName: Output? = null,
    public val managementGroupId: Output? = null,
    public val metadata: Output? = null,
    public val name: Output? = null,
    public val parameters: Output? = null,
    public val policyDefinitionGroups: Output>? =
        null,
    public val policyDefinitionReferences:
    Output>? = null,
    public val policyType: Output? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.azure.policy.PolicySetDefinitionArgs =
        com.pulumi.azure.policy.PolicySetDefinitionArgs.builder()
            .description(description?.applyValue({ args0 -> args0 }))
            .displayName(displayName?.applyValue({ args0 -> args0 }))
            .managementGroupId(managementGroupId?.applyValue({ args0 -> args0 }))
            .metadata(metadata?.applyValue({ args0 -> args0 }))
            .name(name?.applyValue({ args0 -> args0 }))
            .parameters(parameters?.applyValue({ args0 -> args0 }))
            .policyDefinitionGroups(
                policyDefinitionGroups?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.let({ args0 -> args0.toJava() })
                    })
                }),
            )
            .policyDefinitionReferences(
                policyDefinitionReferences?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.let({ args0 -> args0.toJava() })
                    })
                }),
            )
            .policyType(policyType?.applyValue({ args0 -> args0 })).build()
}

/**
 * Builder for [PolicySetDefinitionArgs].
 */
@PulumiTagMarker
public class PolicySetDefinitionArgsBuilder internal constructor() {
    private var description: Output? = null

    private var displayName: Output? = null

    private var managementGroupId: Output? = null

    private var metadata: Output? = null

    private var name: Output? = null

    private var parameters: Output? = null

    private var policyDefinitionGroups: Output>? =
        null

    private var policyDefinitionReferences:
        Output>? = null

    private var policyType: Output? = null

    /**
     * @param value The description of the policy set definition.
     */
    @JvmName("tcjamvlxlccxokwr")
    public suspend fun description(`value`: Output) {
        this.description = value
    }

    /**
     * @param value The display name of the policy set definition.
     */
    @JvmName("sbpubnohliawjail")
    public suspend fun displayName(`value`: Output) {
        this.displayName = value
    }

    /**
     * @param value The id of the Management Group where this policy set definition should be defined. Changing this forces a new resource to be created.
     */
    @JvmName("sbrisqdcvsvbjqhu")
    public suspend fun managementGroupId(`value`: Output) {
        this.managementGroupId = value
    }

    /**
     * @param value The metadata for the policy set definition. This is a JSON object representing additional metadata that should be stored with the policy definition.
     */
    @JvmName("ttggsbysnhubigdy")
    public suspend fun metadata(`value`: Output) {
        this.metadata = value
    }

    /**
     * @param value The name of the policy set definition. Changing this forces a new resource to be created.
     */
    @JvmName("vkxuvhmuyngkjysn")
    public suspend fun name(`value`: Output) {
        this.name = value
    }

    /**
     * @param value Parameters for the policy set definition. This field is a JSON object that allows you to parameterize your policy definition.
     */
    @JvmName("ygoijbkhliqhcffo")
    public suspend fun parameters(`value`: Output) {
        this.parameters = value
    }

    /**
     * @param value One or more `policy_definition_group` blocks as defined below.
     */
    @JvmName("pqnqtioswjhpnjxv")
    public suspend
    fun policyDefinitionGroups(`value`: Output>) {
        this.policyDefinitionGroups = value
    }

    @JvmName("mpnlabjsagehxgsg")
    public suspend fun policyDefinitionGroups(
        vararg
        values: Output,
    ) {
        this.policyDefinitionGroups = Output.all(values.asList())
    }

    /**
     * @param values One or more `policy_definition_group` blocks as defined below.
     */
    @JvmName("cywkhtlrxcmlgogw")
    public suspend
    fun policyDefinitionGroups(values: List>) {
        this.policyDefinitionGroups = Output.all(values)
    }

    /**
     * @param value One or more `policy_definition_reference` blocks as defined below.
     */
    @JvmName("movjsljikadwkwhw")
    public suspend
    fun policyDefinitionReferences(`value`: Output>) {
        this.policyDefinitionReferences = value
    }

    @JvmName("ddcxlljyilvymcjq")
    public suspend fun policyDefinitionReferences(
        vararg
        values: Output,
    ) {
        this.policyDefinitionReferences = Output.all(values.asList())
    }

    /**
     * @param values One or more `policy_definition_reference` blocks as defined below.
     */
    @JvmName("bdbxuuwcpydqnsjr")
    public suspend
    fun policyDefinitionReferences(values: List>) {
        this.policyDefinitionReferences = Output.all(values)
    }

    /**
     * @param value The policy set type. Possible values are `BuiltIn`, `Custom`, `NotSpecified` and `Static`. Changing this forces a new resource to be created.
     */
    @JvmName("uddsjsmxgpdaxsjm")
    public suspend fun policyType(`value`: Output) {
        this.policyType = value
    }

    /**
     * @param value The description of the policy set definition.
     */
    @JvmName("ufqoobobrnymqyyc")
    public suspend fun description(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.description = mapped
    }

    /**
     * @param value The display name of the policy set definition.
     */
    @JvmName("ulytqmaujugikwlo")
    public suspend fun displayName(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.displayName = mapped
    }

    /**
     * @param value The id of the Management Group where this policy set definition should be defined. Changing this forces a new resource to be created.
     */
    @JvmName("tomthqvqdnlajufo")
    public suspend fun managementGroupId(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.managementGroupId = mapped
    }

    /**
     * @param value The metadata for the policy set definition. This is a JSON object representing additional metadata that should be stored with the policy definition.
     */
    @JvmName("ubxhaskdvchvtwjo")
    public suspend fun metadata(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.metadata = mapped
    }

    /**
     * @param value The name of the policy set definition. Changing this forces a new resource to be created.
     */
    @JvmName("aejsnyfrifeivqyv")
    public suspend fun name(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.name = mapped
    }

    /**
     * @param value Parameters for the policy set definition. This field is a JSON object that allows you to parameterize your policy definition.
     */
    @JvmName("ebucmkonnosywuqc")
    public suspend fun parameters(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.parameters = mapped
    }

    /**
     * @param value One or more `policy_definition_group` blocks as defined below.
     */
    @JvmName("cmjqadwvxendppxm")
    public suspend
    fun policyDefinitionGroups(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.policyDefinitionGroups = mapped
    }

    /**
     * @param argument One or more `policy_definition_group` blocks as defined below.
     */
    @JvmName("guckvaqreobxmolh")
    public suspend
    fun policyDefinitionGroups(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            PolicySetDefinitionPolicyDefinitionGroupArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.policyDefinitionGroups = mapped
    }

    /**
     * @param argument One or more `policy_definition_group` blocks as defined below.
     */
    @JvmName("tnlqsxqbbbhvxkvm")
    public suspend fun policyDefinitionGroups(
        vararg
        argument: suspend PolicySetDefinitionPolicyDefinitionGroupArgsBuilder.() -> Unit,
    ) {
        val toBeMapped = argument.toList().map {
            PolicySetDefinitionPolicyDefinitionGroupArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.policyDefinitionGroups = mapped
    }

    /**
     * @param argument One or more `policy_definition_group` blocks as defined below.
     */
    @JvmName("kketlechbexgilxk")
    public suspend
    fun policyDefinitionGroups(argument: suspend PolicySetDefinitionPolicyDefinitionGroupArgsBuilder.() -> Unit) {
        val toBeMapped = listOf(
            PolicySetDefinitionPolicyDefinitionGroupArgsBuilder().applySuspend {
                argument()
            }.build(),
        )
        val mapped = of(toBeMapped)
        this.policyDefinitionGroups = mapped
    }

    /**
     * @param values One or more `policy_definition_group` blocks as defined below.
     */
    @JvmName("kptwbymnfgsrffjw")
    public suspend fun policyDefinitionGroups(
        vararg
        values: PolicySetDefinitionPolicyDefinitionGroupArgs,
    ) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.policyDefinitionGroups = mapped
    }

    /**
     * @param value One or more `policy_definition_reference` blocks as defined below.
     */
    @JvmName("bkgqmaynexwvqfeo")
    public suspend
    fun policyDefinitionReferences(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.policyDefinitionReferences = mapped
    }

    /**
     * @param argument One or more `policy_definition_reference` blocks as defined below.
     */
    @JvmName("qxigaogvapxpctoi")
    public suspend
    fun policyDefinitionReferences(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            PolicySetDefinitionPolicyDefinitionReferenceArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.policyDefinitionReferences = mapped
    }

    /**
     * @param argument One or more `policy_definition_reference` blocks as defined below.
     */
    @JvmName("immicsjjamhdywdn")
    public suspend fun policyDefinitionReferences(
        vararg
        argument: suspend PolicySetDefinitionPolicyDefinitionReferenceArgsBuilder.() -> Unit,
    ) {
        val toBeMapped = argument.toList().map {
            PolicySetDefinitionPolicyDefinitionReferenceArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.policyDefinitionReferences = mapped
    }

    /**
     * @param argument One or more `policy_definition_reference` blocks as defined below.
     */
    @JvmName("axpkdurlpolbujok")
    public suspend
    fun policyDefinitionReferences(argument: suspend PolicySetDefinitionPolicyDefinitionReferenceArgsBuilder.() -> Unit) {
        val toBeMapped = listOf(
            PolicySetDefinitionPolicyDefinitionReferenceArgsBuilder().applySuspend {
                argument()
            }.build(),
        )
        val mapped = of(toBeMapped)
        this.policyDefinitionReferences = mapped
    }

    /**
     * @param values One or more `policy_definition_reference` blocks as defined below.
     */
    @JvmName("rdnsmwdtpxeqekma")
    public suspend fun policyDefinitionReferences(
        vararg
        values: PolicySetDefinitionPolicyDefinitionReferenceArgs,
    ) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.policyDefinitionReferences = mapped
    }

    /**
     * @param value The policy set type. Possible values are `BuiltIn`, `Custom`, `NotSpecified` and `Static`. Changing this forces a new resource to be created.
     */
    @JvmName("bdjfkpmouemqyfwf")
    public suspend fun policyType(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.policyType = mapped
    }

    internal fun build(): PolicySetDefinitionArgs = PolicySetDefinitionArgs(
        description = description,
        displayName = displayName,
        managementGroupId = managementGroupId,
        metadata = metadata,
        name = name,
        parameters = parameters,
        policyDefinitionGroups = policyDefinitionGroups,
        policyDefinitionReferences = policyDefinitionReferences,
        policyType = policyType,
    )
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy