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

com.pulumi.azure.connections.kotlin.ApiConnection.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.connections.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
import kotlin.collections.Map

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

    public var args: ApiConnectionArgs = ApiConnectionArgs()

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

/**
 * Manages an API Connection.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const exampleResourceGroup = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const example = azure.connections.getManagedApiOutput({
 *     name: "servicebus",
 *     location: exampleResourceGroup.location,
 * });
 * const exampleNamespace = new azure.servicebus.Namespace("example", {
 *     name: "acctestsbn-conn-example",
 *     location: exampleResourceGroup.location,
 *     resourceGroupName: exampleResourceGroup.name,
 *     sku: "Basic",
 * });
 * const exampleApiConnection = new azure.connections.ApiConnection("example", {
 *     name: "example-connection",
 *     resourceGroupName: exampleResourceGroup.name,
 *     managedApiId: example.apply(example => example.id),
 *     displayName: "Example 1",
 *     parameterValues: {
 *         connectionString: exampleNamespace.defaultPrimaryConnectionString,
 *     },
 *     tags: {
 *         Hello: "World",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example_resource_group = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example = azure.connections.get_managed_api_output(name="servicebus",
 *     location=example_resource_group.location)
 * example_namespace = azure.servicebus.Namespace("example",
 *     name="acctestsbn-conn-example",
 *     location=example_resource_group.location,
 *     resource_group_name=example_resource_group.name,
 *     sku="Basic")
 * example_api_connection = azure.connections.ApiConnection("example",
 *     name="example-connection",
 *     resource_group_name=example_resource_group.name,
 *     managed_api_id=example.id,
 *     display_name="Example 1",
 *     parameter_values={
 *         "connectionString": example_namespace.default_primary_connection_string,
 *     },
 *     tags={
 *         "Hello": "World",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var exampleResourceGroup = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example-resources",
 *         Location = "West Europe",
 *     });
 *     var example = Azure.Connections.GetManagedApi.Invoke(new()
 *     {
 *         Name = "servicebus",
 *         Location = exampleResourceGroup.Location,
 *     });
 *     var exampleNamespace = new Azure.ServiceBus.Namespace("example", new()
 *     {
 *         Name = "acctestsbn-conn-example",
 *         Location = exampleResourceGroup.Location,
 *         ResourceGroupName = exampleResourceGroup.Name,
 *         Sku = "Basic",
 *     });
 *     var exampleApiConnection = new Azure.Connections.ApiConnection("example", new()
 *     {
 *         Name = "example-connection",
 *         ResourceGroupName = exampleResourceGroup.Name,
 *         ManagedApiId = example.Apply(getManagedApiResult => getManagedApiResult.Id),
 *         DisplayName = "Example 1",
 *         ParameterValues =
 *         {
 *             { "connectionString", exampleNamespace.DefaultPrimaryConnectionString },
 *         },
 *         Tags =
 *         {
 *             { "Hello", "World" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/connections"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/servicebus"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		exampleResourceGroup, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		example := connections.GetManagedApiOutput(ctx, connections.GetManagedApiOutputArgs{
 * 			Name:     pulumi.String("servicebus"),
 * 			Location: exampleResourceGroup.Location,
 * 		}, nil)
 * 		exampleNamespace, err := servicebus.NewNamespace(ctx, "example", &servicebus.NamespaceArgs{
 * 			Name:              pulumi.String("acctestsbn-conn-example"),
 * 			Location:          exampleResourceGroup.Location,
 * 			ResourceGroupName: exampleResourceGroup.Name,
 * 			Sku:               pulumi.String("Basic"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = connections.NewApiConnection(ctx, "example", &connections.ApiConnectionArgs{
 * 			Name:              pulumi.String("example-connection"),
 * 			ResourceGroupName: exampleResourceGroup.Name,
 * 			ManagedApiId: pulumi.String(example.ApplyT(func(example connections.GetManagedApiResult) (*string, error) {
 * 				return &example.Id, nil
 * 			}).(pulumi.StringPtrOutput)),
 * 			DisplayName: pulumi.String("Example 1"),
 * 			ParameterValues: pulumi.StringMap{
 * 				"connectionString": exampleNamespace.DefaultPrimaryConnectionString,
 * 			},
 * 			Tags: pulumi.StringMap{
 * 				"Hello": pulumi.String("World"),
 * 			},
 * 		})
 * 		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.connections.ConnectionsFunctions;
 * import com.pulumi.azure.connections.inputs.GetManagedApiArgs;
 * import com.pulumi.azure.servicebus.Namespace;
 * import com.pulumi.azure.servicebus.NamespaceArgs;
 * import com.pulumi.azure.connections.ApiConnection;
 * import com.pulumi.azure.connections.ApiConnectionArgs;
 * 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 exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()
 *             .name("example-resources")
 *             .location("West Europe")
 *             .build());
 *         final var example = ConnectionsFunctions.getManagedApi(GetManagedApiArgs.builder()
 *             .name("servicebus")
 *             .location(exampleResourceGroup.location())
 *             .build());
 *         var exampleNamespace = new Namespace("exampleNamespace", NamespaceArgs.builder()
 *             .name("acctestsbn-conn-example")
 *             .location(exampleResourceGroup.location())
 *             .resourceGroupName(exampleResourceGroup.name())
 *             .sku("Basic")
 *             .build());
 *         var exampleApiConnection = new ApiConnection("exampleApiConnection", ApiConnectionArgs.builder()
 *             .name("example-connection")
 *             .resourceGroupName(exampleResourceGroup.name())
 *             .managedApiId(example.applyValue(getManagedApiResult -> getManagedApiResult).applyValue(example -> example.applyValue(getManagedApiResult -> getManagedApiResult.id())))
 *             .displayName("Example 1")
 *             .parameterValues(Map.of("connectionString", exampleNamespace.defaultPrimaryConnectionString()))
 *             .tags(Map.of("Hello", "World"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   exampleResourceGroup:
 *     type: azure:core:ResourceGroup
 *     name: example
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleNamespace:
 *     type: azure:servicebus:Namespace
 *     name: example
 *     properties:
 *       name: acctestsbn-conn-example
 *       location: ${exampleResourceGroup.location}
 *       resourceGroupName: ${exampleResourceGroup.name}
 *       sku: Basic
 *   exampleApiConnection:
 *     type: azure:connections:ApiConnection
 *     name: example
 *     properties:
 *       name: example-connection
 *       resourceGroupName: ${exampleResourceGroup.name}
 *       managedApiId: ${example.id}
 *       displayName: Example 1
 *       parameterValues:
 *         connectionString: ${exampleNamespace.defaultPrimaryConnectionString}
 *       tags:
 *         Hello: World
 * variables:
 *   example:
 *     fn::invoke:
 *       Function: azure:connections:getManagedApi
 *       Arguments:
 *         name: servicebus
 *         location: ${exampleResourceGroup.location}
 * ```
 * 
 * ## Import
 * API Connections can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:connections/apiConnection:ApiConnection example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example/providers/Microsoft.Web/connections/example-connection
 * ```
 */
public class ApiConnection internal constructor(
    override val javaResource: com.pulumi.azure.connections.ApiConnection,
) : KotlinCustomResource(javaResource, ApiConnectionMapper) {
    /**
     * A display name for this API Connection. Changing this forces a new API Connection to be created.
     */
    public val displayName: Output
        get() = javaResource.displayName().applyValue({ args0 -> args0 })

    /**
     * The ID of the Managed API which this API Connection is linked to. Changing this forces a new API Connection to be created.
     */
    public val managedApiId: Output
        get() = javaResource.managedApiId().applyValue({ args0 -> args0 })

    /**
     * The Name which should be used for this API Connection. Changing this forces a new API Connection to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    public val parameterValues: Output>?
        get() = javaResource.parameterValues().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0.key.to(args0.value) }).toMap()
            }).orElse(null)
        })

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

    /**
     * A mapping of tags which should be assigned to the API Connection.
     */
    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 ApiConnectionMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.connections.ApiConnection::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy