1. Packages
  2. MSSQL
  3. API Docs
  4. getSchemas
Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse

mssql.getSchemas

Explore with Pulumi AI

mssql logo
Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse

    Obtains information about all schemas found in SQL database.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as mssql from "@pulumi/mssql";
    
    const example = mssql.getDatabase({
        name: "example",
    });
    const all = example.then(example => mssql.getSchemas({
        databaseId: example.id,
    }));
    export const allSchemaNames = all.then(all => all.schemas.map(__item => __item.name));
    
    import pulumi
    import pulumi_mssql as mssql
    
    example = mssql.get_database(name="example")
    all = mssql.get_schemas(database_id=example.id)
    pulumi.export("allSchemaNames", [__item.name for __item in all.schemas])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-mssql/sdk/go/mssql"
    )
    func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
    example, err := mssql.LookupDatabase(ctx, &mssql.LookupDatabaseArgs{
    Name: "example",
    }, nil);
    if err != nil {
    return err
    }
    all, err := mssql.GetSchemas(ctx, &mssql.GetSchemasArgs{
    DatabaseId: pulumi.StringRef(example.Id),
    }, nil);
    if err != nil {
    return err
    }
    ctx.Export("allSchemaNames", pulumi.StringArray(%!v(PANIC=Format method: fatal: A failure has occurred: unlowered splat expression @ #-functions-%smssql:index-getSchemas:getSchemas.pp:7,11-30)))
    return nil
    })
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Mssql = Pulumi.Mssql;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Mssql.GetDatabase.Invoke(new()
        {
            Name = "example",
        });
    
        var all = Mssql.GetSchemas.Invoke(new()
        {
            DatabaseId = example.Apply(getDatabaseResult => getDatabaseResult.Id),
        });
    
        return new Dictionary<string, object?>
        {
            ["allSchemaNames"] = all.Apply(getSchemasResult => getSchemasResult.Schemas).Select(__item => __item.Name).ToList(),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.mssql.MssqlFunctions;
    import com.pulumi.mssql.inputs.GetDatabaseArgs;
    import com.pulumi.mssql.inputs.GetSchemasArgs;
    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 = MssqlFunctions.getDatabase(GetDatabaseArgs.builder()
                .name("example")
                .build());
    
            final var all = MssqlFunctions.getSchemas(GetSchemasArgs.builder()
                .databaseId(example.applyValue(getDatabaseResult -> getDatabaseResult.id()))
                .build());
    
            ctx.export("allSchemaNames", all.applyValue(getSchemasResult -> getSchemasResult.schemas()).stream().map(element -> element.name()).collect(toList()));
        }
    }
    
    Coming soon!
    

    Using getSchemas

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getSchemas(args: GetSchemasArgs, opts?: InvokeOptions): Promise<GetSchemasResult>
    function getSchemasOutput(args: GetSchemasOutputArgs, opts?: InvokeOptions): Output<GetSchemasResult>
    def get_schemas(database_id: Optional[str] = None,
                    opts: Optional[InvokeOptions] = None) -> GetSchemasResult
    def get_schemas_output(database_id: Optional[pulumi.Input[str]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetSchemasResult]
    func GetSchemas(ctx *Context, args *GetSchemasArgs, opts ...InvokeOption) (*GetSchemasResult, error)
    func GetSchemasOutput(ctx *Context, args *GetSchemasOutputArgs, opts ...InvokeOption) GetSchemasResultOutput

    > Note: This function is named GetSchemas in the Go SDK.

    public static class GetSchemas 
    {
        public static Task<GetSchemasResult> InvokeAsync(GetSchemasArgs args, InvokeOptions? opts = null)
        public static Output<GetSchemasResult> Invoke(GetSchemasInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetSchemasResult> getSchemas(GetSchemasArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: mssql:index/getSchemas:getSchemas
      arguments:
        # arguments dictionary

    The following arguments are supported:

    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    databaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    database_id str
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.

    getSchemas Result

    The following output properties are available:

    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    Id string
    ID of the data source, equals to database ID
    Schemas List<Pulumiverse.Mssql.Outputs.GetSchemasSchema>
    Set of schemas found in the DB.
    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    Id string
    ID of the data source, equals to database ID
    Schemas []GetSchemasSchema
    Set of schemas found in the DB.
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    id String
    ID of the data source, equals to database ID
    schemas List<GetSchemasSchema>
    Set of schemas found in the DB.
    databaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    id string
    ID of the data source, equals to database ID
    schemas GetSchemasSchema[]
    Set of schemas found in the DB.
    database_id str
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    id str
    ID of the data source, equals to database ID
    schemas Sequence[GetSchemasSchema]
    Set of schemas found in the DB.
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    id String
    ID of the data source, equals to database ID
    schemas List<Property Map>
    Set of schemas found in the DB.

    Supporting Types

    GetSchemasSchema

    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    Id string
    <database_id>/<schema_id>. Schema ID can be retrieved using SELECT SCHEMA_ID('<schema_name>').
    Name string
    Schema name.
    OwnerId string
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    Id string
    <database_id>/<schema_id>. Schema ID can be retrieved using SELECT SCHEMA_ID('<schema_name>').
    Name string
    Schema name.
    OwnerId string
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    id String
    <database_id>/<schema_id>. Schema ID can be retrieved using SELECT SCHEMA_ID('<schema_name>').
    name String
    Schema name.
    ownerId String
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    databaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    id string
    <database_id>/<schema_id>. Schema ID can be retrieved using SELECT SCHEMA_ID('<schema_name>').
    name string
    Schema name.
    ownerId string
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    database_id str
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    id str
    <database_id>/<schema_id>. Schema ID can be retrieved using SELECT SCHEMA_ID('<schema_name>').
    name str
    Schema name.
    owner_id str
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    id String
    <database_id>/<schema_id>. Schema ID can be retrieved using SELECT SCHEMA_ID('<schema_name>').
    name String
    Schema name.
    ownerId String
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal

    Package Details

    Repository
    mssql pulumiverse/pulumi-mssql
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the mssql Terraform Provider.
    mssql logo
    Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse