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

com.pulumi.azure.iot.kotlin.SharedAccessPolicy.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.iot.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 [SharedAccessPolicy].
 */
@PulumiTagMarker
public class SharedAccessPolicyResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: SharedAccessPolicyArgs = SharedAccessPolicyArgs()

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

/**
 * Manages an IotHub Shared Access Policy
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleIoTHub = new azure.iot.IoTHub("example", {
 *     name: "example",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     sku: {
 *         name: "S1",
 *         capacity: 1,
 *     },
 * });
 * const exampleSharedAccessPolicy = new azure.iot.SharedAccessPolicy("example", {
 *     name: "example",
 *     resourceGroupName: example.name,
 *     iothubName: exampleIoTHub.name,
 *     registryRead: true,
 *     registryWrite: true,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_io_t_hub = azure.iot.IoTHub("example",
 *     name="example",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     sku={
 *         "name": "S1",
 *         "capacity": 1,
 *     })
 * example_shared_access_policy = azure.iot.SharedAccessPolicy("example",
 *     name="example",
 *     resource_group_name=example.name,
 *     iothub_name=example_io_t_hub.name,
 *     registry_read=True,
 *     registry_write=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 = "example-resources",
 *         Location = "West Europe",
 *     });
 *     var exampleIoTHub = new Azure.Iot.IoTHub("example", new()
 *     {
 *         Name = "example",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         Sku = new Azure.Iot.Inputs.IoTHubSkuArgs
 *         {
 *             Name = "S1",
 *             Capacity = 1,
 *         },
 *     });
 *     var exampleSharedAccessPolicy = new Azure.Iot.SharedAccessPolicy("example", new()
 *     {
 *         Name = "example",
 *         ResourceGroupName = example.Name,
 *         IothubName = exampleIoTHub.Name,
 *         RegistryRead = true,
 *         RegistryWrite = true,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/iot"
 * 	"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-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleIoTHub, err := iot.NewIoTHub(ctx, "example", &iot.IoTHubArgs{
 * 			Name:              pulumi.String("example"),
 * 			ResourceGroupName: example.Name,
 * 			Location:          example.Location,
 * 			Sku: &iot.IoTHubSkuArgs{
 * 				Name:     pulumi.String("S1"),
 * 				Capacity: pulumi.Int(1),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = iot.NewSharedAccessPolicy(ctx, "example", &iot.SharedAccessPolicyArgs{
 * 			Name:              pulumi.String("example"),
 * 			ResourceGroupName: example.Name,
 * 			IothubName:        exampleIoTHub.Name,
 * 			RegistryRead:      pulumi.Bool(true),
 * 			RegistryWrite:     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.iot.IoTHub;
 * import com.pulumi.azure.iot.IoTHubArgs;
 * import com.pulumi.azure.iot.inputs.IoTHubSkuArgs;
 * import com.pulumi.azure.iot.SharedAccessPolicy;
 * import com.pulumi.azure.iot.SharedAccessPolicyArgs;
 * 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-resources")
 *             .location("West Europe")
 *             .build());
 *         var exampleIoTHub = new IoTHub("exampleIoTHub", IoTHubArgs.builder()
 *             .name("example")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .sku(IoTHubSkuArgs.builder()
 *                 .name("S1")
 *                 .capacity("1")
 *                 .build())
 *             .build());
 *         var exampleSharedAccessPolicy = new SharedAccessPolicy("exampleSharedAccessPolicy", SharedAccessPolicyArgs.builder()
 *             .name("example")
 *             .resourceGroupName(example.name())
 *             .iothubName(exampleIoTHub.name())
 *             .registryRead(true)
 *             .registryWrite(true)
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleIoTHub:
 *     type: azure:iot:IoTHub
 *     name: example
 *     properties:
 *       name: example
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       sku:
 *         name: S1
 *         capacity: '1'
 *   exampleSharedAccessPolicy:
 *     type: azure:iot:SharedAccessPolicy
 *     name: example
 *     properties:
 *       name: example
 *       resourceGroupName: ${example.name}
 *       iothubName: ${exampleIoTHub.name}
 *       registryRead: true
 *       registryWrite: true
 * ```
 * 
 * ## Import
 * IoTHub Shared Access Policies can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:iot/sharedAccessPolicy:SharedAccessPolicy shared_access_policy1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Devices/iotHubs/hub1/iotHubKeys/shared_access_policy1
 * ```
 */
public class SharedAccessPolicy internal constructor(
    override val javaResource: com.pulumi.azure.iot.SharedAccessPolicy,
) : KotlinCustomResource(javaResource, SharedAccessPolicyMapper) {
    /**
     * Adds `DeviceConnect` permission to this Shared Access Account. It allows sending and receiving on the device-side endpoints.
     * > **NOTE** At least one of `registry_read`, `registry_write`, `service_connect`, `device_connect` permissions must be set to `true`.
     */
    public val deviceConnect: Output?
        get() = javaResource.deviceConnect().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The name of the IoTHub to which this Shared Access Policy belongs. Changing this forces a new resource to be created.
     */
    public val iothubName: Output
        get() = javaResource.iothubName().applyValue({ args0 -> args0 })

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

    /**
     * The primary connection string of the Shared Access Policy.
     */
    public val primaryConnectionString: Output
        get() = javaResource.primaryConnectionString().applyValue({ args0 -> args0 })

    /**
     * The primary key used to create the authentication token.
     */
    public val primaryKey: Output
        get() = javaResource.primaryKey().applyValue({ args0 -> args0 })

    /**
     * Adds `RegistryRead` permission to this Shared Access Account. It allows read access to the identity registry.
     */
    public val registryRead: Output?
        get() = javaResource.registryRead().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Adds `RegistryWrite` permission to this Shared Access Account. It allows write access to the identity registry.
     * > **NOTE** When `registry_write` is set to `true`, `registry_read` must also be set to true. This is a limitation of the Azure REST API
     */
    public val registryWrite: Output?
        get() = javaResource.registryWrite().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The name of the resource group under which the IotHub Shared Access Policy resource has to be created. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * The secondary connection string of the Shared Access Policy.
     */
    public val secondaryConnectionString: Output
        get() = javaResource.secondaryConnectionString().applyValue({ args0 -> args0 })

    /**
     * The secondary key used to create the authentication token.
     */
    public val secondaryKey: Output
        get() = javaResource.secondaryKey().applyValue({ args0 -> args0 })

    /**
     * Adds `ServiceConnect` permission to this Shared Access Account. It allows sending and receiving on the cloud-side endpoints.
     */
    public val serviceConnect: Output?
        get() = javaResource.serviceConnect().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

public object SharedAccessPolicyMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.iot.SharedAccessPolicy::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy