1. Packages
  2. MSSQL
  3. API Docs
  4. getServerPermissions
Microsoft SQL Server v0.0.8 published on Wednesday, Nov 1, 2023 by pulumiverse

mssql.getServerPermissions

Explore with Pulumi AI

mssql logo
Microsoft SQL Server v0.0.8 published on Wednesday, Nov 1, 2023 by pulumiverse

    Returns all permissions grated to given principal

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Mssql = Pulumi.Mssql;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleSqlLogin = Mssql.GetSqlLogin.Invoke(new()
        {
            Name = "example_login",
        });
    
        var exampleServerPermissions = Mssql.GetServerPermissions.Invoke(new()
        {
            PrincipalId = exampleSqlLogin.Apply(getSqlLoginResult => getSqlLoginResult.PrincipalId),
        });
    
        return new Dictionary<string, object?>
        {
            ["permissions"] = exampleServerPermissions.Apply(getServerPermissionsResult => getServerPermissionsResult.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 {
    		exampleSqlLogin, err := mssql.LookupSqlLogin(ctx, &mssql.LookupSqlLoginArgs{
    			Name: "example_login",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		exampleServerPermissions, err := mssql.GetServerPermissions(ctx, &mssql.GetServerPermissionsArgs{
    			PrincipalId: exampleSqlLogin.PrincipalId,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("permissions", exampleServerPermissions.Permissions)
    		return nil
    	})
    }
    
    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.GetSqlLoginArgs;
    import com.pulumi.mssql.inputs.GetServerPermissionsArgs;
    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 exampleSqlLogin = MssqlFunctions.getSqlLogin(GetSqlLoginArgs.builder()
                .name("example_login")
                .build());
    
            final var exampleServerPermissions = MssqlFunctions.getServerPermissions(GetServerPermissionsArgs.builder()
                .principalId(exampleSqlLogin.applyValue(getSqlLoginResult -> getSqlLoginResult.principalId()))
                .build());
    
            ctx.export("permissions", exampleServerPermissions.applyValue(getServerPermissionsResult -> getServerPermissionsResult.permissions()));
        }
    }
    
    import pulumi
    import pulumi_mssql as mssql
    
    example_sql_login = mssql.get_sql_login(name="example_login")
    example_server_permissions = mssql.get_server_permissions(principal_id=example_sql_login.principal_id)
    pulumi.export("permissions", example_server_permissions.permissions)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as mssql from "@pulumi/mssql";
    
    const exampleSqlLogin = mssql.getSqlLogin({
        name: "example_login",
    });
    const exampleServerPermissions = exampleSqlLogin.then(exampleSqlLogin => mssql.getServerPermissions({
        principalId: exampleSqlLogin.principalId,
    }));
    export const permissions = exampleServerPermissions.then(exampleServerPermissions => exampleServerPermissions.permissions);
    
    variables:
      exampleSqlLogin:
        fn::invoke:
          Function: mssql:getSqlLogin
          Arguments:
            name: example_login
      exampleServerPermissions:
        fn::invoke:
          Function: mssql:getServerPermissions
          Arguments:
            principalId: ${exampleSqlLogin.principalId}
    outputs:
      permissions: ${exampleServerPermissions.permissions}
    

    Using getServerPermissions

    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 getServerPermissions(args: GetServerPermissionsArgs, opts?: InvokeOptions): Promise<GetServerPermissionsResult>
    function getServerPermissionsOutput(args: GetServerPermissionsOutputArgs, opts?: InvokeOptions): Output<GetServerPermissionsResult>
    def get_server_permissions(principal_id: Optional[str] = None,
                               opts: Optional[InvokeOptions] = None) -> GetServerPermissionsResult
    def get_server_permissions_output(principal_id: Optional[pulumi.Input[str]] = None,
                               opts: Optional[InvokeOptions] = None) -> Output[GetServerPermissionsResult]
    func GetServerPermissions(ctx *Context, args *GetServerPermissionsArgs, opts ...InvokeOption) (*GetServerPermissionsResult, error)
    func GetServerPermissionsOutput(ctx *Context, args *GetServerPermissionsOutputArgs, opts ...InvokeOption) GetServerPermissionsResultOutput

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

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

    The following arguments are supported:

    PrincipalId string
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    PrincipalId string
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    principalId String
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    principalId string
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    principal_id str
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    principalId String
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.

    getServerPermissions Result

    The following output properties are available:

    Id string
    Equals to principal_id.
    Permissions List<Pulumiverse.Mssql.Outputs.GetServerPermissionsPermission>
    Set of permissions granted to the principal
    PrincipalId string
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    Id string
    Equals to principal_id.
    Permissions []GetServerPermissionsPermission
    Set of permissions granted to the principal
    PrincipalId string
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    id String
    Equals to principal_id.
    permissions List<GetServerPermissionsPermission>
    Set of permissions granted to the principal
    principalId String
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    id string
    Equals to principal_id.
    permissions GetServerPermissionsPermission[]
    Set of permissions granted to the principal
    principalId string
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    id str
    Equals to principal_id.
    permissions Sequence[GetServerPermissionsPermission]
    Set of permissions granted to the principal
    principal_id str
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    id String
    Equals to principal_id.
    permissions List<Property Map>
    Set of permissions granted to the principal
    principalId String
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.

    Supporting Types

    GetServerPermissionsPermission

    Permission string
    Name of server-level 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 server-level 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 server-level 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 server-level 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 server-level 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 server-level 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.0.8 published on Wednesday, Nov 1, 2023 by pulumiverse