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

com.pulumi.azure.notificationhub.kotlin.AuthorizationRule.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.notificationhub.kotlin

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

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

    public var args: AuthorizationRuleArgs = AuthorizationRuleArgs()

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

/**
 * Manages an Authorization Rule associated with a Notification Hub within a Notification Hub Namespace.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "notificationhub-resources",
 *     location: "West Europe",
 * });
 * const exampleNamespace = new azure.notificationhub.Namespace("example", {
 *     name: "myappnamespace",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     namespaceType: "NotificationHub",
 *     skuName: "Free",
 * });
 * const exampleHub = new azure.notificationhub.Hub("example", {
 *     name: "mynotificationhub",
 *     namespaceName: exampleNamespace.name,
 *     resourceGroupName: example.name,
 *     location: example.location,
 * });
 * const exampleAuthorizationRule = new azure.notificationhub.AuthorizationRule("example", {
 *     name: "management-auth-rule",
 *     notificationHubName: exampleHub.name,
 *     namespaceName: exampleNamespace.name,
 *     resourceGroupName: example.name,
 *     manage: true,
 *     send: true,
 *     listen: true,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="notificationhub-resources",
 *     location="West Europe")
 * example_namespace = azure.notificationhub.Namespace("example",
 *     name="myappnamespace",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     namespace_type="NotificationHub",
 *     sku_name="Free")
 * example_hub = azure.notificationhub.Hub("example",
 *     name="mynotificationhub",
 *     namespace_name=example_namespace.name,
 *     resource_group_name=example.name,
 *     location=example.location)
 * example_authorization_rule = azure.notificationhub.AuthorizationRule("example",
 *     name="management-auth-rule",
 *     notification_hub_name=example_hub.name,
 *     namespace_name=example_namespace.name,
 *     resource_group_name=example.name,
 *     manage=True,
 *     send=True,
 *     listen=True)
 * ```
 * ```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 = "notificationhub-resources",
 *         Location = "West Europe",
 *     });
 *     var exampleNamespace = new Azure.NotificationHub.Namespace("example", new()
 *     {
 *         Name = "myappnamespace",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         NamespaceType = "NotificationHub",
 *         SkuName = "Free",
 *     });
 *     var exampleHub = new Azure.NotificationHub.Hub("example", new()
 *     {
 *         Name = "mynotificationhub",
 *         NamespaceName = exampleNamespace.Name,
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *     });
 *     var exampleAuthorizationRule = new Azure.NotificationHub.AuthorizationRule("example", new()
 *     {
 *         Name = "management-auth-rule",
 *         NotificationHubName = exampleHub.Name,
 *         NamespaceName = exampleNamespace.Name,
 *         ResourceGroupName = example.Name,
 *         Manage = true,
 *         Send = true,
 *         Listen = true,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/notificationhub"
 * 	"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("notificationhub-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleNamespace, err := notificationhub.NewNamespace(ctx, "example", ¬ificationhub.NamespaceArgs{
 * 			Name:              pulumi.String("myappnamespace"),
 * 			ResourceGroupName: example.Name,
 * 			Location:          example.Location,
 * 			NamespaceType:     pulumi.String("NotificationHub"),
 * 			SkuName:           pulumi.String("Free"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleHub, err := notificationhub.NewHub(ctx, "example", ¬ificationhub.HubArgs{
 * 			Name:              pulumi.String("mynotificationhub"),
 * 			NamespaceName:     exampleNamespace.Name,
 * 			ResourceGroupName: example.Name,
 * 			Location:          example.Location,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = notificationhub.NewAuthorizationRule(ctx, "example", ¬ificationhub.AuthorizationRuleArgs{
 * 			Name:                pulumi.String("management-auth-rule"),
 * 			NotificationHubName: exampleHub.Name,
 * 			NamespaceName:       exampleNamespace.Name,
 * 			ResourceGroupName:   example.Name,
 * 			Manage:              pulumi.Bool(true),
 * 			Send:                pulumi.Bool(true),
 * 			Listen:              pulumi.Bool(true),
 * 		})
 * 		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.notificationhub.Namespace;
 * import com.pulumi.azure.notificationhub.NamespaceArgs;
 * import com.pulumi.azure.notificationhub.Hub;
 * import com.pulumi.azure.notificationhub.HubArgs;
 * import com.pulumi.azure.notificationhub.AuthorizationRule;
 * import com.pulumi.azure.notificationhub.AuthorizationRuleArgs;
 * 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("notificationhub-resources")
 *             .location("West Europe")
 *             .build());
 *         var exampleNamespace = new Namespace("exampleNamespace", NamespaceArgs.builder()
 *             .name("myappnamespace")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .namespaceType("NotificationHub")
 *             .skuName("Free")
 *             .build());
 *         var exampleHub = new Hub("exampleHub", HubArgs.builder()
 *             .name("mynotificationhub")
 *             .namespaceName(exampleNamespace.name())
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .build());
 *         var exampleAuthorizationRule = new AuthorizationRule("exampleAuthorizationRule", AuthorizationRuleArgs.builder()
 *             .name("management-auth-rule")
 *             .notificationHubName(exampleHub.name())
 *             .namespaceName(exampleNamespace.name())
 *             .resourceGroupName(example.name())
 *             .manage(true)
 *             .send(true)
 *             .listen(true)
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: notificationhub-resources
 *       location: West Europe
 *   exampleNamespace:
 *     type: azure:notificationhub:Namespace
 *     name: example
 *     properties:
 *       name: myappnamespace
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       namespaceType: NotificationHub
 *       skuName: Free
 *   exampleHub:
 *     type: azure:notificationhub:Hub
 *     name: example
 *     properties:
 *       name: mynotificationhub
 *       namespaceName: ${exampleNamespace.name}
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *   exampleAuthorizationRule:
 *     type: azure:notificationhub:AuthorizationRule
 *     name: example
 *     properties:
 *       name: management-auth-rule
 *       notificationHubName: ${exampleHub.name}
 *       namespaceName: ${exampleNamespace.name}
 *       resourceGroupName: ${example.name}
 *       manage: true
 *       send: true
 *       listen: true
 * ```
 * 
 * ## Import
 * Notification Hub Authorization Rule can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:notificationhub/authorizationRule:AuthorizationRule rule1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.NotificationHubs/namespaces/namespace1/notificationHubs/hub1/authorizationRules/rule1
 * ```
 */
public class AuthorizationRule internal constructor(
    override val javaResource: com.pulumi.azure.notificationhub.AuthorizationRule,
) : KotlinCustomResource(javaResource, AuthorizationRuleMapper) {
    /**
     * Does this Authorization Rule have Listen access to the Notification Hub? Defaults to `false`.
     */
    public val listen: Output?
        get() = javaResource.listen().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * Does this Authorization Rule have Manage access to the Notification Hub? Defaults to `false`.
     * > **NOTE:** If `manage` is set to `true` then both `send` and `listen` must also be set to `true`.
     */
    public val manage: Output?
        get() = javaResource.manage().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The name to use for this Authorization Rule. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The name of the Notification Hub Namespace in which the Notification Hub exists. Changing this forces a new resource to be created.
     */
    public val namespaceName: Output
        get() = javaResource.namespaceName().applyValue({ args0 -> args0 })

    /**
     * The name of the Notification Hub for which the Authorization Rule should be created. Changing this forces a new resource to be created.
     */
    public val notificationHubName: Output
        get() = javaResource.notificationHubName().applyValue({ args0 -> args0 })

    /**
     * The Primary Access Key associated with this Authorization Rule.
     */
    public val primaryAccessKey: Output
        get() = javaResource.primaryAccessKey().applyValue({ args0 -> args0 })

    /**
     * The Primary Connetion String associated with this Authorization Rule.
     */
    public val primaryConnectionString: Output
        get() = javaResource.primaryConnectionString().applyValue({ args0 -> args0 })

    /**
     * The name of the Resource Group in which the Notification Hub Namespace exists. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * The Secondary Access Key associated with this Authorization Rule.
     */
    public val secondaryAccessKey: Output
        get() = javaResource.secondaryAccessKey().applyValue({ args0 -> args0 })

    /**
     * The Secondary Connetion String associated with this Authorization Rule.
     */
    public val secondaryConnectionString: Output
        get() = javaResource.secondaryConnectionString().applyValue({ args0 -> args0 })

    /**
     * Does this Authorization Rule have Send access to the Notification Hub? Defaults to `false`.
     */
    public val send: Output?
        get() = javaResource.send().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
}

public object AuthorizationRuleMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.notificationhub.AuthorizationRule::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy