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

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

    public var args: RegistryTokenArgs = RegistryTokenArgs()

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

/**
 * Manages an Azure Container Registry token. Tokens are a preview feature only available in Premium SKU Container registries.
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resource-group",
 *     location: "West Europe",
 * });
 * const exampleRegistry = new azure.containerservice.Registry("example", {
 *     name: "example",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     sku: "Premium",
 *     adminEnabled: false,
 *     georeplications: [
 *         {
 *             location: "East US",
 *         },
 *         {
 *             location: "West Europe",
 *         },
 *     ],
 * });
 * const exampleRegistryScopeMap = new azure.containerservice.RegistryScopeMap("example", {
 *     name: "example-scope-map",
 *     containerRegistryName: exampleRegistry.name,
 *     resourceGroupName: example.name,
 *     actions: [
 *         "repositories/repo1/content/read",
 *         "repositories/repo1/content/write",
 *     ],
 * });
 * const exampleRegistryToken = new azure.containerservice.RegistryToken("example", {
 *     name: "exampletoken",
 *     containerRegistryName: exampleRegistry.name,
 *     resourceGroupName: example.name,
 *     scopeMapId: exampleRegistryScopeMap.id,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resource-group",
 *     location="West Europe")
 * example_registry = azure.containerservice.Registry("example",
 *     name="example",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     sku="Premium",
 *     admin_enabled=False,
 *     georeplications=[
 *         azure.containerservice.RegistryGeoreplicationArgs(
 *             location="East US",
 *         ),
 *         azure.containerservice.RegistryGeoreplicationArgs(
 *             location="West Europe",
 *         ),
 *     ])
 * example_registry_scope_map = azure.containerservice.RegistryScopeMap("example",
 *     name="example-scope-map",
 *     container_registry_name=example_registry.name,
 *     resource_group_name=example.name,
 *     actions=[
 *         "repositories/repo1/content/read",
 *         "repositories/repo1/content/write",
 *     ])
 * example_registry_token = azure.containerservice.RegistryToken("example",
 *     name="exampletoken",
 *     container_registry_name=example_registry.name,
 *     resource_group_name=example.name,
 *     scope_map_id=example_registry_scope_map.id)
 * ```
 * ```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-resource-group",
 *         Location = "West Europe",
 *     });
 *     var exampleRegistry = new Azure.ContainerService.Registry("example", new()
 *     {
 *         Name = "example",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         Sku = "Premium",
 *         AdminEnabled = false,
 *         Georeplications = new[]
 *         {
 *             new Azure.ContainerService.Inputs.RegistryGeoreplicationArgs
 *             {
 *                 Location = "East US",
 *             },
 *             new Azure.ContainerService.Inputs.RegistryGeoreplicationArgs
 *             {
 *                 Location = "West Europe",
 *             },
 *         },
 *     });
 *     var exampleRegistryScopeMap = new Azure.ContainerService.RegistryScopeMap("example", new()
 *     {
 *         Name = "example-scope-map",
 *         ContainerRegistryName = exampleRegistry.Name,
 *         ResourceGroupName = example.Name,
 *         Actions = new[]
 *         {
 *             "repositories/repo1/content/read",
 *             "repositories/repo1/content/write",
 *         },
 *     });
 *     var exampleRegistryToken = new Azure.ContainerService.RegistryToken("example", new()
 *     {
 *         Name = "exampletoken",
 *         ContainerRegistryName = exampleRegistry.Name,
 *         ResourceGroupName = example.Name,
 *         ScopeMapId = exampleRegistryScopeMap.Id,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/containerservice"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"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-resource-group"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleRegistry, err := containerservice.NewRegistry(ctx, "example", &containerservice.RegistryArgs{
 * 			Name:              pulumi.String("example"),
 * 			ResourceGroupName: example.Name,
 * 			Location:          example.Location,
 * 			Sku:               pulumi.String("Premium"),
 * 			AdminEnabled:      pulumi.Bool(false),
 * 			Georeplications: containerservice.RegistryGeoreplicationArray{
 * 				&containerservice.RegistryGeoreplicationArgs{
 * 					Location: pulumi.String("East US"),
 * 				},
 * 				&containerservice.RegistryGeoreplicationArgs{
 * 					Location: pulumi.String("West Europe"),
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleRegistryScopeMap, err := containerservice.NewRegistryScopeMap(ctx, "example", &containerservice.RegistryScopeMapArgs{
 * 			Name:                  pulumi.String("example-scope-map"),
 * 			ContainerRegistryName: exampleRegistry.Name,
 * 			ResourceGroupName:     example.Name,
 * 			Actions: pulumi.StringArray{
 * 				pulumi.String("repositories/repo1/content/read"),
 * 				pulumi.String("repositories/repo1/content/write"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = containerservice.NewRegistryToken(ctx, "example", &containerservice.RegistryTokenArgs{
 * 			Name:                  pulumi.String("exampletoken"),
 * 			ContainerRegistryName: exampleRegistry.Name,
 * 			ResourceGroupName:     example.Name,
 * 			ScopeMapId:            exampleRegistryScopeMap.ID(),
 * 		})
 * 		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.containerservice.Registry;
 * import com.pulumi.azure.containerservice.RegistryArgs;
 * import com.pulumi.azure.containerservice.inputs.RegistryGeoreplicationArgs;
 * import com.pulumi.azure.containerservice.RegistryScopeMap;
 * import com.pulumi.azure.containerservice.RegistryScopeMapArgs;
 * import com.pulumi.azure.containerservice.RegistryToken;
 * import com.pulumi.azure.containerservice.RegistryTokenArgs;
 * 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-resource-group")
 *             .location("West Europe")
 *             .build());
 *         var exampleRegistry = new Registry("exampleRegistry", RegistryArgs.builder()
 *             .name("example")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .sku("Premium")
 *             .adminEnabled(false)
 *             .georeplications(
 *                 RegistryGeoreplicationArgs.builder()
 *                     .location("East US")
 *                     .build(),
 *                 RegistryGeoreplicationArgs.builder()
 *                     .location("West Europe")
 *                     .build())
 *             .build());
 *         var exampleRegistryScopeMap = new RegistryScopeMap("exampleRegistryScopeMap", RegistryScopeMapArgs.builder()
 *             .name("example-scope-map")
 *             .containerRegistryName(exampleRegistry.name())
 *             .resourceGroupName(example.name())
 *             .actions(
 *                 "repositories/repo1/content/read",
 *                 "repositories/repo1/content/write")
 *             .build());
 *         var exampleRegistryToken = new RegistryToken("exampleRegistryToken", RegistryTokenArgs.builder()
 *             .name("exampletoken")
 *             .containerRegistryName(exampleRegistry.name())
 *             .resourceGroupName(example.name())
 *             .scopeMapId(exampleRegistryScopeMap.id())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resource-group
 *       location: West Europe
 *   exampleRegistry:
 *     type: azure:containerservice:Registry
 *     name: example
 *     properties:
 *       name: example
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       sku: Premium
 *       adminEnabled: false
 *       georeplications:
 *         - location: East US
 *         - location: West Europe
 *   exampleRegistryScopeMap:
 *     type: azure:containerservice:RegistryScopeMap
 *     name: example
 *     properties:
 *       name: example-scope-map
 *       containerRegistryName: ${exampleRegistry.name}
 *       resourceGroupName: ${example.name}
 *       actions:
 *         - repositories/repo1/content/read
 *         - repositories/repo1/content/write
 *   exampleRegistryToken:
 *     type: azure:containerservice:RegistryToken
 *     name: example
 *     properties:
 *       name: exampletoken
 *       containerRegistryName: ${exampleRegistry.name}
 *       resourceGroupName: ${example.name}
 *       scopeMapId: ${exampleRegistryScopeMap.id}
 * ```
 * 
 * ## Import
 * Container Registries can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:containerservice/registryToken:RegistryToken example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.ContainerRegistry/registries/myregistry1/tokens/token1
 * ```
 */
public class RegistryToken internal constructor(
    override val javaResource: com.pulumi.azure.containerservice.RegistryToken,
) : KotlinCustomResource(javaResource, RegistryTokenMapper) {
    /**
     * The name of the Container Registry. Changing this forces a new resource to be created.
     */
    public val containerRegistryName: Output
        get() = javaResource.containerRegistryName().applyValue({ args0 -> args0 })

    /**
     * Should the Container Registry token be enabled? Defaults to `true`.
     */
    public val enabled: Output?
        get() = javaResource.enabled().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

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

    /**
     * The name of the resource group in which to create the Container Registry token. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * The ID of the Container Registry Scope Map associated with the token.
     */
    public val scopeMapId: Output
        get() = javaResource.scopeMapId().applyValue({ args0 -> args0 })
}

public object RegistryTokenMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.containerservice.RegistryToken::class == javaResource::class

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy