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

com.pulumi.azure.containerservice.kotlin.RegistryCacheRule.kt Maven / Gradle / Ivy

@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 [RegistryCacheRule].
 */
@PulumiTagMarker
public class RegistryCacheRuleResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: RegistryCacheRuleArgs = RegistryCacheRuleArgs()

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

/**
 * Manages an Azure Container Registry Cache Rule.
 * > **Note:** All arguments including the access key will be stored in the raw state as plain-text.
 * [Read more about sensitive data in state](https://www.terraform.io/docs/state/sensitive-data.html).
 * ## 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 acr = new azure.containerservice.Registry("acr", {
 *     name: "containerRegistry1",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     sku: "Basic",
 * });
 * const cacheRule = new azure.containerservice.RegistryCacheRule("cache_rule", {
 *     name: "cacherule",
 *     containerRegistryId: acr.id,
 *     targetRepo: "target",
 *     sourceRepo: "docker.io/hello-world",
 *     credentialSetId: pulumi.interpolate`${acr.id}/credentialSets/example`,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * acr = azure.containerservice.Registry("acr",
 *     name="containerRegistry1",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     sku="Basic")
 * cache_rule = azure.containerservice.RegistryCacheRule("cache_rule",
 *     name="cacherule",
 *     container_registry_id=acr.id,
 *     target_repo="target",
 *     source_repo="docker.io/hello-world",
 *     credential_set_id=acr.id.apply(lambda id: f"{id}/credentialSets/example"))
 * ```
 * ```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 acr = new Azure.ContainerService.Registry("acr", new()
 *     {
 *         Name = "containerRegistry1",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         Sku = "Basic",
 *     });
 *     var cacheRule = new Azure.ContainerService.RegistryCacheRule("cache_rule", new()
 *     {
 *         Name = "cacherule",
 *         ContainerRegistryId = acr.Id,
 *         TargetRepo = "target",
 *         SourceRepo = "docker.io/hello-world",
 *         CredentialSetId = acr.Id.Apply(id => $"{id}/credentialSets/example"),
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"fmt"
 * 	"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-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		acr, err := containerservice.NewRegistry(ctx, "acr", &containerservice.RegistryArgs{
 * 			Name:              pulumi.String("containerRegistry1"),
 * 			ResourceGroupName: example.Name,
 * 			Location:          example.Location,
 * 			Sku:               pulumi.String("Basic"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = containerservice.NewRegistryCacheRule(ctx, "cache_rule", &containerservice.RegistryCacheRuleArgs{
 * 			Name:                pulumi.String("cacherule"),
 * 			ContainerRegistryId: acr.ID(),
 * 			TargetRepo:          pulumi.String("target"),
 * 			SourceRepo:          pulumi.String("docker.io/hello-world"),
 * 			CredentialSetId: acr.ID().ApplyT(func(id string) (string, error) {
 * 				return fmt.Sprintf("%v/credentialSets/example", id), nil
 * 			}).(pulumi.StringOutput),
 * 		})
 * 		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.RegistryCacheRule;
 * import com.pulumi.azure.containerservice.RegistryCacheRuleArgs;
 * 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 acr = new Registry("acr", RegistryArgs.builder()
 *             .name("containerRegistry1")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .sku("Basic")
 *             .build());
 *         var cacheRule = new RegistryCacheRule("cacheRule", RegistryCacheRuleArgs.builder()
 *             .name("cacherule")
 *             .containerRegistryId(acr.id())
 *             .targetRepo("target")
 *             .sourceRepo("docker.io/hello-world")
 *             .credentialSetId(acr.id().applyValue(id -> String.format("%s/credentialSets/example", id)))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   acr:
 *     type: azure:containerservice:Registry
 *     properties:
 *       name: containerRegistry1
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       sku: Basic
 *   cacheRule:
 *     type: azure:containerservice:RegistryCacheRule
 *     name: cache_rule
 *     properties:
 *       name: cacherule
 *       containerRegistryId: ${acr.id}
 *       targetRepo: target
 *       sourceRepo: docker.io/hello-world
 *       credentialSetId: ${acr.id}/credentialSets/example
 * ```
 * 
 * ## Import
 * Container Registry Cache Rules can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:containerservice/registryCacheRule:RegistryCacheRule example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/cacheRules/myCacheRule
 * ```
 */
public class RegistryCacheRule internal constructor(
    override val javaResource: com.pulumi.azure.containerservice.RegistryCacheRule,
) : KotlinCustomResource(javaResource, RegistryCacheRuleMapper) {
    /**
     * The ID of the Container Registry where the Cache Rule should apply. Changing this forces a new resource to be created.
     */
    public val containerRegistryId: Output
        get() = javaResource.containerRegistryId().applyValue({ args0 -> args0 })

    /**
     * The ARM resource ID of the Credential Store which is associated with the Cache Rule.
     */
    public val credentialSetId: Output?
        get() = javaResource.credentialSetId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Specifies the name of the Container Registry Cache Rule. Only Alphanumeric characters allowed. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

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

    /**
     * The name of the new repository path to store artifacts. Changing this forces a new resource to be created.
     */
    public val targetRepo: Output
        get() = javaResource.targetRepo().applyValue({ args0 -> args0 })
}

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

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy