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

com.pulumi.azure.sql.kotlin.SqlFunctions.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.sql.kotlin

import com.pulumi.azure.sql.SqlFunctions.getDatabasePlain
import com.pulumi.azure.sql.SqlFunctions.getServerPlain
import com.pulumi.azure.sql.SqlFunctions.getSqlManagedInstancePlain
import com.pulumi.azure.sql.kotlin.inputs.GetDatabasePlainArgs
import com.pulumi.azure.sql.kotlin.inputs.GetDatabasePlainArgsBuilder
import com.pulumi.azure.sql.kotlin.inputs.GetServerPlainArgs
import com.pulumi.azure.sql.kotlin.inputs.GetServerPlainArgsBuilder
import com.pulumi.azure.sql.kotlin.inputs.GetSqlManagedInstancePlainArgs
import com.pulumi.azure.sql.kotlin.inputs.GetSqlManagedInstancePlainArgsBuilder
import com.pulumi.azure.sql.kotlin.outputs.GetDatabaseResult
import com.pulumi.azure.sql.kotlin.outputs.GetServerResult
import com.pulumi.azure.sql.kotlin.outputs.GetSqlManagedInstanceResult
import kotlinx.coroutines.future.await
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map
import com.pulumi.azure.sql.kotlin.outputs.GetDatabaseResult.Companion.toKotlin as getDatabaseResultToKotlin
import com.pulumi.azure.sql.kotlin.outputs.GetServerResult.Companion.toKotlin as getServerResultToKotlin
import com.pulumi.azure.sql.kotlin.outputs.GetSqlManagedInstanceResult.Companion.toKotlin as getSqlManagedInstanceResultToKotlin

public object SqlFunctions {
    /**
     * Use this data source to access information about an existing SQL Azure Database.
     * > **Note:** The `azure.sql.Database` data source is deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use the `azure.mssql.Database` data source instead.
     * ## Example Usage
     * 
     * ```typescript
     * import * as pulumi from "@pulumi/pulumi";
     * import * as azure from "@pulumi/azure";
     * const example = azure.sql.getDatabase({
     *     name: "example_db",
     *     serverName: "example_db_server",
     *     resourceGroupName: "example-resources",
     * });
     * export const sqlDatabaseId = example.then(example => example.id);
     * ```
     * ```python
     * import pulumi
     * import pulumi_azure as azure
     * example = azure.sql.get_database(name="example_db",
     *     server_name="example_db_server",
     *     resource_group_name="example-resources")
     * pulumi.export("sqlDatabaseId", example.id)
     * ```
     * ```csharp
     * using System.Collections.Generic;
     * using System.Linq;
     * using Pulumi;
     * using Azure = Pulumi.Azure;
     * return await Deployment.RunAsync(() =>
     * {
     *     var example = Azure.Sql.GetDatabase.Invoke(new()
     *     {
     *         Name = "example_db",
     *         ServerName = "example_db_server",
     *         ResourceGroupName = "example-resources",
     *     });
     *     return new Dictionary
     *     {
     *         ["sqlDatabaseId"] = example.Apply(getDatabaseResult => getDatabaseResult.Id),
     *     };
     * });
     * ```
     * ```go
     * package main
     * import (
     * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/sql"
     * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
     * )
     * func main() {
     * 	pulumi.Run(func(ctx *pulumi.Context) error {
     * 		example, err := sql.LookupDatabase(ctx, &sql.LookupDatabaseArgs{
     * 			Name:              "example_db",
     * 			ServerName:        "example_db_server",
     * 			ResourceGroupName: "example-resources",
     * 		}, nil)
     * 		if err != nil {
     * 			return err
     * 		}
     * 		ctx.Export("sqlDatabaseId", example.Id)
     * 		return nil
     * 	})
     * }
     * ```
     * ```java
     * package generated_program;
     * import com.pulumi.Context;
     * import com.pulumi.Pulumi;
     * import com.pulumi.core.Output;
     * import com.pulumi.azure.sql.SqlFunctions;
     * import com.pulumi.azure.sql.inputs.GetDatabaseArgs;
     * 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) {
     *         final var example = SqlFunctions.getDatabase(GetDatabaseArgs.builder()
     *             .name("example_db")
     *             .serverName("example_db_server")
     *             .resourceGroupName("example-resources")
     *             .build());
     *         ctx.export("sqlDatabaseId", example.applyValue(getDatabaseResult -> getDatabaseResult.id()));
     *     }
     * }
     * ```
     * ```yaml
     * variables:
     *   example:
     *     fn::invoke:
     *       Function: azure:sql:getDatabase
     *       Arguments:
     *         name: example_db
     *         serverName: example_db_server
     *         resourceGroupName: example-resources
     * outputs:
     *   sqlDatabaseId: ${example.id}
     * ```
     * 
     * @param argument A collection of arguments for invoking getDatabase.
     * @return A collection of values returned by getDatabase.
     */
    public suspend fun getDatabase(argument: GetDatabasePlainArgs): GetDatabaseResult =
        getDatabaseResultToKotlin(getDatabasePlain(argument.toJava()).await())

    /**
     * @see [getDatabase].
     * @param name The name of the SQL Database.
     * @param resourceGroupName Specifies the name of the Resource Group where the Azure SQL Database exists.
     * @param serverName The name of the SQL Server.
     * @param tags A mapping of tags assigned to the resource.
     * @return A collection of values returned by getDatabase.
     */
    public suspend fun getDatabase(
        name: String,
        resourceGroupName: String,
        serverName: String,
        tags: Map? = null,
    ): GetDatabaseResult {
        val argument = GetDatabasePlainArgs(
            name = name,
            resourceGroupName = resourceGroupName,
            serverName = serverName,
            tags = tags,
        )
        return getDatabaseResultToKotlin(getDatabasePlain(argument.toJava()).await())
    }

    /**
     * @see [getDatabase].
     * @param argument Builder for [com.pulumi.azure.sql.kotlin.inputs.GetDatabasePlainArgs].
     * @return A collection of values returned by getDatabase.
     */
    public suspend fun getDatabase(argument: suspend GetDatabasePlainArgsBuilder.() -> Unit): GetDatabaseResult {
        val builder = GetDatabasePlainArgsBuilder()
        builder.argument()
        val builtArgument = builder.build()
        return getDatabaseResultToKotlin(getDatabasePlain(builtArgument.toJava()).await())
    }

    /**
     * Use this data source to access information about an existing SQL Azure Database Server.
     * > **Note:** The `azure.sql.SqlServer` data source is deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use the `azure.mssql.Server` data source instead.
     * ## Example Usage
     * 
     * ```typescript
     * import * as pulumi from "@pulumi/pulumi";
     * import * as azure from "@pulumi/azure";
     * const example = azure.sql.getServer({
     *     name: "examplesqlservername",
     *     resourceGroupName: "example-resources",
     * });
     * export const sqlServerId = example.then(example => example.id);
     * ```
     * ```python
     * import pulumi
     * import pulumi_azure as azure
     * example = azure.sql.get_server(name="examplesqlservername",
     *     resource_group_name="example-resources")
     * pulumi.export("sqlServerId", example.id)
     * ```
     * ```csharp
     * using System.Collections.Generic;
     * using System.Linq;
     * using Pulumi;
     * using Azure = Pulumi.Azure;
     * return await Deployment.RunAsync(() =>
     * {
     *     var example = Azure.Sql.GetServer.Invoke(new()
     *     {
     *         Name = "examplesqlservername",
     *         ResourceGroupName = "example-resources",
     *     });
     *     return new Dictionary
     *     {
     *         ["sqlServerId"] = example.Apply(getServerResult => getServerResult.Id),
     *     };
     * });
     * ```
     * ```go
     * package main
     * import (
     * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/sql"
     * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
     * )
     * func main() {
     * 	pulumi.Run(func(ctx *pulumi.Context) error {
     * 		example, err := sql.GetServer(ctx, &sql.GetServerArgs{
     * 			Name:              "examplesqlservername",
     * 			ResourceGroupName: "example-resources",
     * 		}, nil)
     * 		if err != nil {
     * 			return err
     * 		}
     * 		ctx.Export("sqlServerId", example.Id)
     * 		return nil
     * 	})
     * }
     * ```
     * ```java
     * package generated_program;
     * import com.pulumi.Context;
     * import com.pulumi.Pulumi;
     * import com.pulumi.core.Output;
     * import com.pulumi.azure.sql.SqlFunctions;
     * import com.pulumi.azure.sql.inputs.GetServerArgs;
     * 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) {
     *         final var example = SqlFunctions.getServer(GetServerArgs.builder()
     *             .name("examplesqlservername")
     *             .resourceGroupName("example-resources")
     *             .build());
     *         ctx.export("sqlServerId", example.applyValue(getServerResult -> getServerResult.id()));
     *     }
     * }
     * ```
     * ```yaml
     * variables:
     *   example:
     *     fn::invoke:
     *       Function: azure:sql:getServer
     *       Arguments:
     *         name: examplesqlservername
     *         resourceGroupName: example-resources
     * outputs:
     *   sqlServerId: ${example.id}
     * ```
     * 
     * @param argument A collection of arguments for invoking getServer.
     * @return A collection of values returned by getServer.
     */
    public suspend fun getServer(argument: GetServerPlainArgs): GetServerResult =
        getServerResultToKotlin(getServerPlain(argument.toJava()).await())

    /**
     * @see [getServer].
     * @param name The name of the SQL Server.
     * @param resourceGroupName Specifies the name of the Resource Group where the SQL Server exists.
     * @return A collection of values returned by getServer.
     */
    public suspend fun getServer(name: String, resourceGroupName: String): GetServerResult {
        val argument = GetServerPlainArgs(
            name = name,
            resourceGroupName = resourceGroupName,
        )
        return getServerResultToKotlin(getServerPlain(argument.toJava()).await())
    }

    /**
     * @see [getServer].
     * @param argument Builder for [com.pulumi.azure.sql.kotlin.inputs.GetServerPlainArgs].
     * @return A collection of values returned by getServer.
     */
    public suspend fun getServer(argument: suspend GetServerPlainArgsBuilder.() -> Unit): GetServerResult {
        val builder = GetServerPlainArgsBuilder()
        builder.argument()
        val builtArgument = builder.build()
        return getServerResultToKotlin(getServerPlain(builtArgument.toJava()).await())
    }

    /**
     * Use this data source to access information about an existing SQL Managed Instance.
     * > **Note:** The `azure.sql.ManagedInstance` data source is deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use the `azure.mssql.ManagedInstance` data source instead.
     * ## Example Usage
     * 
     * ```typescript
     * import * as pulumi from "@pulumi/pulumi";
     * import * as azure from "@pulumi/azure";
     * const example = azure.sql.getSqlManagedInstance({
     *     name: "example_mi",
     *     resourceGroupName: "example-resources",
     * });
     * export const sqlInstanceId = example.then(example => example.id);
     * ```
     * ```python
     * import pulumi
     * import pulumi_azure as azure
     * example = azure.sql.get_sql_managed_instance(name="example_mi",
     *     resource_group_name="example-resources")
     * pulumi.export("sqlInstanceId", example.id)
     * ```
     * ```csharp
     * using System.Collections.Generic;
     * using System.Linq;
     * using Pulumi;
     * using Azure = Pulumi.Azure;
     * return await Deployment.RunAsync(() =>
     * {
     *     var example = Azure.Sql.GetSqlManagedInstance.Invoke(new()
     *     {
     *         Name = "example_mi",
     *         ResourceGroupName = "example-resources",
     *     });
     *     return new Dictionary
     *     {
     *         ["sqlInstanceId"] = example.Apply(getSqlManagedInstanceResult => getSqlManagedInstanceResult.Id),
     *     };
     * });
     * ```
     * ```go
     * package main
     * import (
     * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/sql"
     * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
     * )
     * func main() {
     * 	pulumi.Run(func(ctx *pulumi.Context) error {
     * 		example, err := sql.GetSqlManagedInstance(ctx, &sql.GetSqlManagedInstanceArgs{
     * 			Name:              "example_mi",
     * 			ResourceGroupName: "example-resources",
     * 		}, nil)
     * 		if err != nil {
     * 			return err
     * 		}
     * 		ctx.Export("sqlInstanceId", example.Id)
     * 		return nil
     * 	})
     * }
     * ```
     * ```java
     * package generated_program;
     * import com.pulumi.Context;
     * import com.pulumi.Pulumi;
     * import com.pulumi.core.Output;
     * import com.pulumi.azure.sql.SqlFunctions;
     * import com.pulumi.azure.sql.inputs.GetSqlManagedInstanceArgs;
     * 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) {
     *         final var example = SqlFunctions.getSqlManagedInstance(GetSqlManagedInstanceArgs.builder()
     *             .name("example_mi")
     *             .resourceGroupName("example-resources")
     *             .build());
     *         ctx.export("sqlInstanceId", example.applyValue(getSqlManagedInstanceResult -> getSqlManagedInstanceResult.id()));
     *     }
     * }
     * ```
     * ```yaml
     * variables:
     *   example:
     *     fn::invoke:
     *       Function: azure:sql:getSqlManagedInstance
     *       Arguments:
     *         name: example_mi
     *         resourceGroupName: example-resources
     * outputs:
     *   sqlInstanceId: ${example.id}
     * ```
     * 
     * @param argument A collection of arguments for invoking getSqlManagedInstance.
     * @return A collection of values returned by getSqlManagedInstance.
     */
    public suspend fun getSqlManagedInstance(argument: GetSqlManagedInstancePlainArgs): GetSqlManagedInstanceResult =
        getSqlManagedInstanceResultToKotlin(getSqlManagedInstancePlain(argument.toJava()).await())

    /**
     * @see [getSqlManagedInstance].
     * @param name The name of the SQL Managed Instance.
     * @param resourceGroupName The name of the Resource Group in which the SQL Managed Instance exists.
     * @param tags A mapping of tags assigned to the resource.
     * @return A collection of values returned by getSqlManagedInstance.
     */
    public suspend fun getSqlManagedInstance(
        name: String,
        resourceGroupName: String,
        tags: Map? = null,
    ): GetSqlManagedInstanceResult {
        val argument = GetSqlManagedInstancePlainArgs(
            name = name,
            resourceGroupName = resourceGroupName,
            tags = tags,
        )
        return getSqlManagedInstanceResultToKotlin(getSqlManagedInstancePlain(argument.toJava()).await())
    }

    /**
     * @see [getSqlManagedInstance].
     * @param argument Builder for [com.pulumi.azure.sql.kotlin.inputs.GetSqlManagedInstancePlainArgs].
     * @return A collection of values returned by getSqlManagedInstance.
     */
    public suspend fun getSqlManagedInstance(argument: suspend GetSqlManagedInstancePlainArgsBuilder.() -> Unit): GetSqlManagedInstanceResult {
        val builder = GetSqlManagedInstancePlainArgsBuilder()
        builder.argument()
        val builtArgument = builder.build()
        return getSqlManagedInstanceResultToKotlin(getSqlManagedInstancePlain(builtArgument.toJava()).await())
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy