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

com.pulumi.azure.managedapplication.kotlin.Definition.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.managedapplication.kotlin

import com.pulumi.azure.managedapplication.kotlin.outputs.DefinitionAuthorization
import com.pulumi.azure.managedapplication.kotlin.outputs.DefinitionAuthorization.Companion.toKotlin
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.List
import kotlin.collections.Map

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

    public var args: DefinitionArgs = DefinitionArgs()

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

/**
 * Manages a Managed Application Definition.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const current = azure.core.getClientConfig({});
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleDefinition = new azure.managedapplication.Definition("example", {
 *     name: "examplemanagedapplicationdefinition",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     lockLevel: "ReadOnly",
 *     packageFileUri: "https://github.com/Azure/azure-managedapp-samples/raw/master/Managed Application Sample Packages/201-managed-storage-account/managedstorage.zip",
 *     displayName: "TestManagedApplicationDefinition",
 *     description: "Test Managed Application Definition",
 *     authorizations: [{
 *         servicePrincipalId: current.then(current => current.objectId),
 *         roleDefinitionId: "a094b430-dad3-424d-ae58-13f72fd72591",
 *     }],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * current = azure.core.get_client_config()
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_definition = azure.managedapplication.Definition("example",
 *     name="examplemanagedapplicationdefinition",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     lock_level="ReadOnly",
 *     package_file_uri="https://github.com/Azure/azure-managedapp-samples/raw/master/Managed Application Sample Packages/201-managed-storage-account/managedstorage.zip",
 *     display_name="TestManagedApplicationDefinition",
 *     description="Test Managed Application Definition",
 *     authorizations=[{
 *         "service_principal_id": current.object_id,
 *         "role_definition_id": "a094b430-dad3-424d-ae58-13f72fd72591",
 *     }])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var current = Azure.Core.GetClientConfig.Invoke();
 *     var example = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example-resources",
 *         Location = "West Europe",
 *     });
 *     var exampleDefinition = new Azure.ManagedApplication.Definition("example", new()
 *     {
 *         Name = "examplemanagedapplicationdefinition",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         LockLevel = "ReadOnly",
 *         PackageFileUri = "https://github.com/Azure/azure-managedapp-samples/raw/master/Managed Application Sample Packages/201-managed-storage-account/managedstorage.zip",
 *         DisplayName = "TestManagedApplicationDefinition",
 *         Description = "Test Managed Application Definition",
 *         Authorizations = new[]
 *         {
 *             new Azure.ManagedApplication.Inputs.DefinitionAuthorizationArgs
 *             {
 *                 ServicePrincipalId = current.Apply(getClientConfigResult => getClientConfigResult.ObjectId),
 *                 RoleDefinitionId = "a094b430-dad3-424d-ae58-13f72fd72591",
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/managedapplication"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		current, err := core.GetClientConfig(ctx, nil, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = managedapplication.NewDefinition(ctx, "example", &managedapplication.DefinitionArgs{
 * 			Name:              pulumi.String("examplemanagedapplicationdefinition"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			LockLevel:         pulumi.String("ReadOnly"),
 * 			PackageFileUri:    pulumi.String("https://github.com/Azure/azure-managedapp-samples/raw/master/Managed Application Sample Packages/201-managed-storage-account/managedstorage.zip"),
 * 			DisplayName:       pulumi.String("TestManagedApplicationDefinition"),
 * 			Description:       pulumi.String("Test Managed Application Definition"),
 * 			Authorizations: managedapplication.DefinitionAuthorizationArray{
 * 				&managedapplication.DefinitionAuthorizationArgs{
 * 					ServicePrincipalId: pulumi.String(current.ObjectId),
 * 					RoleDefinitionId:   pulumi.String("a094b430-dad3-424d-ae58-13f72fd72591"),
 * 				},
 * 			},
 * 		})
 * 		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.CoreFunctions;
 * import com.pulumi.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.managedapplication.Definition;
 * import com.pulumi.azure.managedapplication.DefinitionArgs;
 * import com.pulumi.azure.managedapplication.inputs.DefinitionAuthorizationArgs;
 * 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) {
 *         final var current = CoreFunctions.getClientConfig();
 *         var example = new ResourceGroup("example", ResourceGroupArgs.builder()
 *             .name("example-resources")
 *             .location("West Europe")
 *             .build());
 *         var exampleDefinition = new Definition("exampleDefinition", DefinitionArgs.builder()
 *             .name("examplemanagedapplicationdefinition")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .lockLevel("ReadOnly")
 *             .packageFileUri("https://github.com/Azure/azure-managedapp-samples/raw/master/Managed Application Sample Packages/201-managed-storage-account/managedstorage.zip")
 *             .displayName("TestManagedApplicationDefinition")
 *             .description("Test Managed Application Definition")
 *             .authorizations(DefinitionAuthorizationArgs.builder()
 *                 .servicePrincipalId(current.applyValue(getClientConfigResult -> getClientConfigResult.objectId()))
 *                 .roleDefinitionId("a094b430-dad3-424d-ae58-13f72fd72591")
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleDefinition:
 *     type: azure:managedapplication:Definition
 *     name: example
 *     properties:
 *       name: examplemanagedapplicationdefinition
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       lockLevel: ReadOnly
 *       packageFileUri: https://github.com/Azure/azure-managedapp-samples/raw/master/Managed Application Sample Packages/201-managed-storage-account/managedstorage.zip
 *       displayName: TestManagedApplicationDefinition
 *       description: Test Managed Application Definition
 *       authorizations:
 *         - servicePrincipalId: ${current.objectId}
 *           roleDefinitionId: a094b430-dad3-424d-ae58-13f72fd72591
 * variables:
 *   current:
 *     fn::invoke:
 *       Function: azure:core:getClientConfig
 *       Arguments: {}
 * ```
 * 
 * ## Import
 * Managed Application Definition can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:managedapplication/definition:Definition example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Solutions/applicationDefinitions/appDefinition1
 * ```
 */
public class Definition internal constructor(
    override val javaResource: com.pulumi.azure.managedapplication.Definition,
) : KotlinCustomResource(javaResource, DefinitionMapper) {
    /**
     * One or more `authorization` block defined below.
     */
    public val authorizations: Output>?
        get() = javaResource.authorizations().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0.let({ args0 -> toKotlin(args0) }) })
            }).orElse(null)
        })

    /**
     * Specifies the `createUiDefinition` JSON for the backing template with `Microsoft.Solutions/applications` resource.
     */
    public val createUiDefinition: Output?
        get() = javaResource.createUiDefinition().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Specifies the managed application definition description.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Specifies the managed application definition display name.
     */
    public val displayName: Output
        get() = javaResource.displayName().applyValue({ args0 -> args0 })

    /**
     * Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * Specifies the managed application lock level. Valid values include `CanNotDelete`, `None`, `ReadOnly`. Changing this forces a new resource to be created.
     */
    public val lockLevel: Output
        get() = javaResource.lockLevel().applyValue({ args0 -> args0 })

    /**
     * Specifies the inline main template JSON which has resources to be provisioned.
     */
    public val mainTemplate: Output?
        get() = javaResource.mainTemplate().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Specifies the name of the Managed Application Definition. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * Is the package enabled? Defaults to `true`.
     */
    public val packageEnabled: Output?
        get() = javaResource.packageEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Specifies the managed application definition package file Uri.
     */
    public val packageFileUri: Output?
        get() = javaResource.packageFileUri().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The name of the Resource Group where the Managed Application Definition should exist. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * A mapping of tags to assign to the resource.
     * > **NOTE:** If either `create_ui_definition` or `main_template` is set they both must be set.
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })
}

public object DefinitionMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.managedapplication.Definition::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy