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

mssql.getSchemaPermissions

Explore with Pulumi AI

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

    Returns all permissions granted in a schema to given principal

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as mssql from "@pulumi/mssql";
    
    const exampleDatabase = mssql.getDatabase({
        name: "example",
    });
    const exampleSqlUser = exampleDatabase.then(exampleDatabase => mssql.getSqlUser({
        name: "example_user",
        databaseId: exampleDatabase.id,
    }));
    const exampleSchema = exampleDatabase.then(exampleDatabase => mssql.getSchema({
        name: "example_schema",
        databaseId: exampleDatabase.id,
    }));
    const exampleSchemaPermissions = Promise.all([exampleSchema, exampleSqlUser]).then(([exampleSchema, exampleSqlUser]) => mssql.getSchemaPermissions({
        schemaId: exampleSchema.id,
        principalId: exampleSqlUser.id,
    }));
    export const permissions = exampleSchemaPermissions.then(exampleSchemaPermissions => exampleSchemaPermissions.permissions);
    
    import pulumi
    import pulumi_mssql as mssql
    
    example_database = mssql.get_database(name="example")
    example_sql_user = mssql.get_sql_user(name="example_user",
        database_id=example_database.id)
    example_schema = mssql.get_schema(name="example_schema",
        database_id=example_database.id)
    example_schema_permissions = mssql.get_schema_permissions(schema_id=example_schema.id,
        principal_id=example_sql_user.id)
    pulumi.export("permissions", example_schema_permissions.permissions)
    
    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 {
    		exampleDatabase, err := mssql.LookupDatabase(ctx, &mssql.LookupDatabaseArgs{
    			Name: "example",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		exampleSqlUser, err := mssql.LookupSqlUser(ctx, &mssql.LookupSqlUserArgs{
    			Name:       "example_user",
    			DatabaseId: pulumi.StringRef(exampleDatabase.Id),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		exampleSchema, err := mssql.LookupSchema(ctx, &mssql.LookupSchemaArgs{
    			Name:       pulumi.StringRef("example_schema"),
    			DatabaseId: pulumi.StringRef(exampleDatabase.Id),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		exampleSchemaPermissions, err := mssql.GetSchemaPermissions(ctx, &mssql.GetSchemaPermissionsArgs{
    			SchemaId:    exampleSchema.Id,
    			PrincipalId: exampleSqlUser.Id,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("permissions", exampleSchemaPermissions.Permissions)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Mssql = Pulumi.Mssql;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleDatabase = Mssql.GetDatabase.Invoke(new()
        {
            Name = "example",
        });
    
        var exampleSqlUser = Mssql.GetSqlUser.Invoke(new()
        {
            Name = "example_user",
            DatabaseId = exampleDatabase.Apply(getDatabaseResult => getDatabaseResult.Id),
        });
    
        var exampleSchema = Mssql.GetSchema.Invoke(new()
        {
            Name = "example_schema",
            DatabaseId = exampleDatabase.Apply(getDatabaseResult => getDatabaseResult.Id),
        });
    
        var exampleSchemaPermissions = Mssql.GetSchemaPermissions.Invoke(new()
        {
            SchemaId = exampleSchema.Apply(getSchemaResult => getSchemaResult.Id),
            PrincipalId = exampleSqlUser.Apply(getSqlUserResult => getSqlUserResult.Id),
        });
    
        return new Dictionary<string, object?>
        {
            ["permissions"] = exampleSchemaPermissions.Apply(getSchemaPermissionsResult => getSchemaPermissionsResult.Permissions),
        };
    });
    
    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.GetSqlUserArgs;
    import com.pulumi.mssql.inputs.GetSchemaArgs;
    import com.pulumi.mssql.inputs.GetSchemaPermissionsArgs;
    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 exampleDatabase = MssqlFunctions.getDatabase(GetDatabaseArgs.builder()
                .name("example")
                .build());
    
            final var exampleSqlUser = MssqlFunctions.getSqlUser(GetSqlUserArgs.builder()
                .name("example_user")
                .databaseId(exampleDatabase.applyValue(getDatabaseResult -> getDatabaseResult.id()))
                .build());
    
            final var exampleSchema = MssqlFunctions.getSchema(GetSchemaArgs.builder()
                .name("example_schema")
                .databaseId(exampleDatabase.applyValue(getDatabaseResult -> getDatabaseResult.id()))
                .build());
    
            final var exampleSchemaPermissions = MssqlFunctions.getSchemaPermissions(GetSchemaPermissionsArgs.builder()
                .schemaId(exampleSchema.applyValue(getSchemaResult -> getSchemaResult.id()))
                .principalId(exampleSqlUser.applyValue(getSqlUserResult -> getSqlUserResult.id()))
                .build());
    
            ctx.export("permissions", exampleSchemaPermissions.applyValue(getSchemaPermissionsResult -> getSchemaPermissionsResult.permissions()));
        }
    }
    
    variables:
      exampleDatabase:
        fn::invoke:
          Function: mssql:getDatabase
          Arguments:
            name: example
      exampleSqlUser:
        fn::invoke:
          Function: mssql:getSqlUser
          Arguments:
            name: example_user
            databaseId: ${exampleDatabase.id}
      exampleSchema:
        fn::invoke:
          Function: mssql:getSchema
          Arguments:
            name: example_schema
            databaseId: ${exampleDatabase.id}
      exampleSchemaPermissions:
        fn::invoke:
          Function: mssql:getSchemaPermissions
          Arguments:
            schemaId: ${exampleSchema.id}
            principalId: ${exampleSqlUser.id}
    outputs:
      permissions: ${exampleSchemaPermissions.permissions}
    

    Using getSchemaPermissions

    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 getSchemaPermissions(args: GetSchemaPermissionsArgs, opts?: InvokeOptions): Promise<GetSchemaPermissionsResult>
    function getSchemaPermissionsOutput(args: GetSchemaPermissionsOutputArgs, opts?: InvokeOptions): Output<GetSchemaPermissionsResult>
    def get_schema_permissions(principal_id: Optional[str] = None,
                               schema_id: Optional[str] = None,
                               opts: Optional[InvokeOptions] = None) -> GetSchemaPermissionsResult
    def get_schema_permissions_output(principal_id: Optional[pulumi.Input[str]] = None,
                               schema_id: Optional[pulumi.Input[str]] = None,
                               opts: Optional[InvokeOptions] = None) -> Output[GetSchemaPermissionsResult]
    func GetSchemaPermissions(ctx *Context, args *GetSchemaPermissionsArgs, opts ...InvokeOption) (*GetSchemaPermissionsResult, error)
    func GetSchemaPermissionsOutput(ctx *Context, args *GetSchemaPermissionsOutputArgs, opts ...InvokeOption) GetSchemaPermissionsResultOutput

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

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

    The following arguments are supported:

    PrincipalId string
    <database_id>/<principal_id>. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal.
    SchemaId string
    <database_id>/<schema_id>. Can be retrieved using mssql.Schema.
    PrincipalId string
    <database_id>/<principal_id>. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal.
    SchemaId string
    <database_id>/<schema_id>. Can be retrieved using mssql.Schema.
    principalId String
    <database_id>/<principal_id>. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal.
    schemaId String
    <database_id>/<schema_id>. Can be retrieved using mssql.Schema.
    principalId string
    <database_id>/<principal_id>. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal.
    schemaId string
    <database_id>/<schema_id>. Can be retrieved using mssql.Schema.
    principal_id str
    <database_id>/<principal_id>. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal.
    schema_id str
    <database_id>/<schema_id>. Can be retrieved using mssql.Schema.
    principalId String
    <database_id>/<principal_id>. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal.
    schemaId String
    <database_id>/<schema_id>. Can be retrieved using mssql.Schema.

    getSchemaPermissions Result

    The following output properties are available:

    Id string
    <database_id>/<schema_id>/<principal_id>.
    Permissions List<Pulumiverse.Mssql.Outputs.GetSchemaPermissionsPermission>
    Set of permissions granted to the principal
    PrincipalId string
    <database_id>/<principal_id>. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal.
    SchemaId string
    <database_id>/<schema_id>. Can be retrieved using mssql.Schema.
    Id string
    <database_id>/<schema_id>/<principal_id>.
    Permissions []GetSchemaPermissionsPermission
    Set of permissions granted to the principal
    PrincipalId string
    <database_id>/<principal_id>. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal.
    SchemaId string
    <database_id>/<schema_id>. Can be retrieved using mssql.Schema.
    id String
    <database_id>/<schema_id>/<principal_id>.
    permissions List<GetSchemaPermissionsPermission>
    Set of permissions granted to the principal
    principalId String
    <database_id>/<principal_id>. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal.
    schemaId String
    <database_id>/<schema_id>. Can be retrieved using mssql.Schema.
    id string
    <database_id>/<schema_id>/<principal_id>.
    permissions GetSchemaPermissionsPermission[]
    Set of permissions granted to the principal
    principalId string
    <database_id>/<principal_id>. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal.
    schemaId string
    <database_id>/<schema_id>. Can be retrieved using mssql.Schema.
    id str
    <database_id>/<schema_id>/<principal_id>.
    permissions Sequence[GetSchemaPermissionsPermission]
    Set of permissions granted to the principal
    principal_id str
    <database_id>/<principal_id>. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal.
    schema_id str
    <database_id>/<schema_id>. Can be retrieved using mssql.Schema.
    id String
    <database_id>/<schema_id>/<principal_id>.
    permissions List<Property Map>
    Set of permissions granted to the principal
    principalId String
    <database_id>/<principal_id>. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal.
    schemaId String
    <database_id>/<schema_id>. Can be retrieved using mssql.Schema.

    Supporting Types

    GetSchemaPermissionsPermission

    Permission string
    Name of schema SQL permission. For full list of supported permissions, see docs
    WithGrantOption bool
    When set to true, principal_id will be allowed to grant the permission to other principals.
    Permission string
    Name of schema SQL permission. For full list of supported permissions, see docs
    WithGrantOption bool
    When set to true, principal_id will be allowed to grant the permission to other principals.
    permission String
    Name of schema SQL permission. For full list of supported permissions, see docs
    withGrantOption Boolean
    When set to true, principal_id will be allowed to grant the permission to other principals.
    permission string
    Name of schema SQL permission. For full list of supported permissions, see docs
    withGrantOption boolean
    When set to true, principal_id will be allowed to grant the permission to other principals.
    permission str
    Name of schema SQL permission. For full list of supported permissions, see docs
    with_grant_option bool
    When set to true, principal_id will be allowed to grant the permission to other principals.
    permission String
    Name of schema SQL permission. For full list of supported permissions, see docs
    withGrantOption Boolean
    When set to true, principal_id will be allowed to grant the permission to other principals.

    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