1. Packages
  2. Grafana Cloud
  3. API Docs
  4. oss
  5. DashboardPermission
Grafana v0.7.0 published on Tuesday, Nov 5, 2024 by pulumiverse

grafana.oss.DashboardPermission

Explore with Pulumi AI

grafana logo
Grafana v0.7.0 published on Tuesday, Nov 5, 2024 by pulumiverse

    Manages the entire set of permissions for a dashboard. Permissions that aren’t specified when applying this resource will be removed.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as grafana from "@pulumiverse/grafana";
    
    const team = new grafana.oss.Team("team", {name: "Team Name"});
    const user = new grafana.oss.User("user", {
        email: "user.name@example.com",
        password: "my-password",
        login: "user.name",
    });
    const metrics = new grafana.oss.Dashboard("metrics", {configJson: JSON.stringify({
        title: "My Dashboard",
        uid: "my-dashboard-uid",
    })});
    const collectionPermission = new grafana.oss.DashboardPermission("collectionPermission", {
        dashboardUid: metrics.uid,
        permissions: [
            {
                role: "Editor",
                permission: "Edit",
            },
            {
                teamId: team.id,
                permission: "View",
            },
            {
                userId: user.id,
                permission: "Admin",
            },
        ],
    });
    
    import pulumi
    import json
    import pulumiverse_grafana as grafana
    
    team = grafana.oss.Team("team", name="Team Name")
    user = grafana.oss.User("user",
        email="user.name@example.com",
        password="my-password",
        login="user.name")
    metrics = grafana.oss.Dashboard("metrics", config_json=json.dumps({
        "title": "My Dashboard",
        "uid": "my-dashboard-uid",
    }))
    collection_permission = grafana.oss.DashboardPermission("collectionPermission",
        dashboard_uid=metrics.uid,
        permissions=[
            {
                "role": "Editor",
                "permission": "Edit",
            },
            {
                "team_id": team.id,
                "permission": "View",
            },
            {
                "user_id": user.id,
                "permission": "Admin",
            },
        ])
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-grafana/sdk/go/grafana/oss"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		team, err := oss.NewTeam(ctx, "team", &oss.TeamArgs{
    			Name: pulumi.String("Team Name"),
    		})
    		if err != nil {
    			return err
    		}
    		user, err := oss.NewUser(ctx, "user", &oss.UserArgs{
    			Email:    pulumi.String("user.name@example.com"),
    			Password: pulumi.String("my-password"),
    			Login:    pulumi.String("user.name"),
    		})
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"title": "My Dashboard",
    			"uid":   "my-dashboard-uid",
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		metrics, err := oss.NewDashboard(ctx, "metrics", &oss.DashboardArgs{
    			ConfigJson: pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = oss.NewDashboardPermission(ctx, "collectionPermission", &oss.DashboardPermissionArgs{
    			DashboardUid: metrics.Uid,
    			Permissions: oss.DashboardPermissionPermissionArray{
    				&oss.DashboardPermissionPermissionArgs{
    					Role:       pulumi.String("Editor"),
    					Permission: pulumi.String("Edit"),
    				},
    				&oss.DashboardPermissionPermissionArgs{
    					TeamId:     team.ID(),
    					Permission: pulumi.String("View"),
    				},
    				&oss.DashboardPermissionPermissionArgs{
    					UserId:     user.ID(),
    					Permission: pulumi.String("Admin"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Grafana = Pulumiverse.Grafana;
    
    return await Deployment.RunAsync(() => 
    {
        var team = new Grafana.Oss.Team("team", new()
        {
            Name = "Team Name",
        });
    
        var user = new Grafana.Oss.User("user", new()
        {
            Email = "user.name@example.com",
            Password = "my-password",
            Login = "user.name",
        });
    
        var metrics = new Grafana.Oss.Dashboard("metrics", new()
        {
            ConfigJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["title"] = "My Dashboard",
                ["uid"] = "my-dashboard-uid",
            }),
        });
    
        var collectionPermission = new Grafana.Oss.DashboardPermission("collectionPermission", new()
        {
            DashboardUid = metrics.Uid,
            Permissions = new[]
            {
                new Grafana.Oss.Inputs.DashboardPermissionPermissionArgs
                {
                    Role = "Editor",
                    Permission = "Edit",
                },
                new Grafana.Oss.Inputs.DashboardPermissionPermissionArgs
                {
                    TeamId = team.Id,
                    Permission = "View",
                },
                new Grafana.Oss.Inputs.DashboardPermissionPermissionArgs
                {
                    UserId = user.Id,
                    Permission = "Admin",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.grafana.oss.Team;
    import com.pulumi.grafana.oss.TeamArgs;
    import com.pulumi.grafana.oss.User;
    import com.pulumi.grafana.oss.UserArgs;
    import com.pulumi.grafana.oss.Dashboard;
    import com.pulumi.grafana.oss.DashboardArgs;
    import com.pulumi.grafana.oss.DashboardPermission;
    import com.pulumi.grafana.oss.DashboardPermissionArgs;
    import com.pulumi.grafana.oss.inputs.DashboardPermissionPermissionArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    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 team = new Team("team", TeamArgs.builder()
                .name("Team Name")
                .build());
    
            var user = new User("user", UserArgs.builder()
                .email("user.name@example.com")
                .password("my-password")
                .login("user.name")
                .build());
    
            var metrics = new Dashboard("metrics", DashboardArgs.builder()
                .configJson(serializeJson(
                    jsonObject(
                        jsonProperty("title", "My Dashboard"),
                        jsonProperty("uid", "my-dashboard-uid")
                    )))
                .build());
    
            var collectionPermission = new DashboardPermission("collectionPermission", DashboardPermissionArgs.builder()
                .dashboardUid(metrics.uid())
                .permissions(            
                    DashboardPermissionPermissionArgs.builder()
                        .role("Editor")
                        .permission("Edit")
                        .build(),
                    DashboardPermissionPermissionArgs.builder()
                        .teamId(team.id())
                        .permission("View")
                        .build(),
                    DashboardPermissionPermissionArgs.builder()
                        .userId(user.id())
                        .permission("Admin")
                        .build())
                .build());
    
        }
    }
    
    resources:
      team:
        type: grafana:oss:Team
        properties:
          name: Team Name
      user:
        type: grafana:oss:User
        properties:
          email: user.name@example.com
          password: my-password
          login: user.name
      metrics:
        type: grafana:oss:Dashboard
        properties:
          configJson:
            fn::toJSON:
              title: My Dashboard
              uid: my-dashboard-uid
      collectionPermission:
        type: grafana:oss:DashboardPermission
        properties:
          dashboardUid: ${metrics.uid}
          permissions:
            - role: Editor
              permission: Edit
            - teamId: ${team.id}
              permission: View
            - userId: ${user.id}
              permission: Admin
    

    Create DashboardPermission Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new DashboardPermission(name: string, args?: DashboardPermissionArgs, opts?: CustomResourceOptions);
    @overload
    def DashboardPermission(resource_name: str,
                            args: Optional[DashboardPermissionArgs] = None,
                            opts: Optional[ResourceOptions] = None)
    
    @overload
    def DashboardPermission(resource_name: str,
                            opts: Optional[ResourceOptions] = None,
                            dashboard_uid: Optional[str] = None,
                            org_id: Optional[str] = None,
                            permissions: Optional[Sequence[DashboardPermissionPermissionArgs]] = None)
    func NewDashboardPermission(ctx *Context, name string, args *DashboardPermissionArgs, opts ...ResourceOption) (*DashboardPermission, error)
    public DashboardPermission(string name, DashboardPermissionArgs? args = null, CustomResourceOptions? opts = null)
    public DashboardPermission(String name, DashboardPermissionArgs args)
    public DashboardPermission(String name, DashboardPermissionArgs args, CustomResourceOptions options)
    
    type: grafana:oss:DashboardPermission
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args DashboardPermissionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args DashboardPermissionArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args DashboardPermissionArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args DashboardPermissionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args DashboardPermissionArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var dashboardPermissionResource = new Grafana.Oss.DashboardPermission("dashboardPermissionResource", new()
    {
        DashboardUid = "string",
        OrgId = "string",
        Permissions = new[]
        {
            new Grafana.Oss.Inputs.DashboardPermissionPermissionArgs
            {
                Permission = "string",
                Role = "string",
                TeamId = "string",
                UserId = "string",
            },
        },
    });
    
    example, err := oss.NewDashboardPermission(ctx, "dashboardPermissionResource", &oss.DashboardPermissionArgs{
    	DashboardUid: pulumi.String("string"),
    	OrgId:        pulumi.String("string"),
    	Permissions: oss.DashboardPermissionPermissionArray{
    		&oss.DashboardPermissionPermissionArgs{
    			Permission: pulumi.String("string"),
    			Role:       pulumi.String("string"),
    			TeamId:     pulumi.String("string"),
    			UserId:     pulumi.String("string"),
    		},
    	},
    })
    
    var dashboardPermissionResource = new DashboardPermission("dashboardPermissionResource", DashboardPermissionArgs.builder()
        .dashboardUid("string")
        .orgId("string")
        .permissions(DashboardPermissionPermissionArgs.builder()
            .permission("string")
            .role("string")
            .teamId("string")
            .userId("string")
            .build())
        .build());
    
    dashboard_permission_resource = grafana.oss.DashboardPermission("dashboardPermissionResource",
        dashboard_uid="string",
        org_id="string",
        permissions=[{
            "permission": "string",
            "role": "string",
            "team_id": "string",
            "user_id": "string",
        }])
    
    const dashboardPermissionResource = new grafana.oss.DashboardPermission("dashboardPermissionResource", {
        dashboardUid: "string",
        orgId: "string",
        permissions: [{
            permission: "string",
            role: "string",
            teamId: "string",
            userId: "string",
        }],
    });
    
    type: grafana:oss:DashboardPermission
    properties:
        dashboardUid: string
        orgId: string
        permissions:
            - permission: string
              role: string
              teamId: string
              userId: string
    

    DashboardPermission Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The DashboardPermission resource accepts the following input properties:

    DashboardUid string
    UID of the dashboard to apply permissions to.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Permissions List<Pulumiverse.Grafana.Oss.Inputs.DashboardPermissionPermission>
    The permission items to add/update. Items that are omitted from the list will be removed.
    DashboardUid string
    UID of the dashboard to apply permissions to.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Permissions []DashboardPermissionPermissionArgs
    The permission items to add/update. Items that are omitted from the list will be removed.
    dashboardUid String
    UID of the dashboard to apply permissions to.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions List<DashboardPermissionPermission>
    The permission items to add/update. Items that are omitted from the list will be removed.
    dashboardUid string
    UID of the dashboard to apply permissions to.
    orgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions DashboardPermissionPermission[]
    The permission items to add/update. Items that are omitted from the list will be removed.
    dashboard_uid str
    UID of the dashboard to apply permissions to.
    org_id str
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions Sequence[DashboardPermissionPermissionArgs]
    The permission items to add/update. Items that are omitted from the list will be removed.
    dashboardUid String
    UID of the dashboard to apply permissions to.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions List<Property Map>
    The permission items to add/update. Items that are omitted from the list will be removed.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the DashboardPermission resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing DashboardPermission Resource

    Get an existing DashboardPermission resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: DashboardPermissionState, opts?: CustomResourceOptions): DashboardPermission
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            dashboard_uid: Optional[str] = None,
            org_id: Optional[str] = None,
            permissions: Optional[Sequence[DashboardPermissionPermissionArgs]] = None) -> DashboardPermission
    func GetDashboardPermission(ctx *Context, name string, id IDInput, state *DashboardPermissionState, opts ...ResourceOption) (*DashboardPermission, error)
    public static DashboardPermission Get(string name, Input<string> id, DashboardPermissionState? state, CustomResourceOptions? opts = null)
    public static DashboardPermission get(String name, Output<String> id, DashboardPermissionState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    DashboardUid string
    UID of the dashboard to apply permissions to.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Permissions List<Pulumiverse.Grafana.Oss.Inputs.DashboardPermissionPermission>
    The permission items to add/update. Items that are omitted from the list will be removed.
    DashboardUid string
    UID of the dashboard to apply permissions to.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Permissions []DashboardPermissionPermissionArgs
    The permission items to add/update. Items that are omitted from the list will be removed.
    dashboardUid String
    UID of the dashboard to apply permissions to.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions List<DashboardPermissionPermission>
    The permission items to add/update. Items that are omitted from the list will be removed.
    dashboardUid string
    UID of the dashboard to apply permissions to.
    orgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions DashboardPermissionPermission[]
    The permission items to add/update. Items that are omitted from the list will be removed.
    dashboard_uid str
    UID of the dashboard to apply permissions to.
    org_id str
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions Sequence[DashboardPermissionPermissionArgs]
    The permission items to add/update. Items that are omitted from the list will be removed.
    dashboardUid String
    UID of the dashboard to apply permissions to.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions List<Property Map>
    The permission items to add/update. Items that are omitted from the list will be removed.

    Supporting Types

    DashboardPermissionPermission, DashboardPermissionPermissionArgs

    Permission string
    Permission to associate with item. Must be one of View, Edit, or Admin.
    Role string
    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin.
    TeamId string
    ID of the team to manage permissions for. Defaults to 0.
    UserId string
    ID of the user or service account to manage permissions for. Defaults to 0.
    Permission string
    Permission to associate with item. Must be one of View, Edit, or Admin.
    Role string
    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin.
    TeamId string
    ID of the team to manage permissions for. Defaults to 0.
    UserId string
    ID of the user or service account to manage permissions for. Defaults to 0.
    permission String
    Permission to associate with item. Must be one of View, Edit, or Admin.
    role String
    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin.
    teamId String
    ID of the team to manage permissions for. Defaults to 0.
    userId String
    ID of the user or service account to manage permissions for. Defaults to 0.
    permission string
    Permission to associate with item. Must be one of View, Edit, or Admin.
    role string
    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin.
    teamId string
    ID of the team to manage permissions for. Defaults to 0.
    userId string
    ID of the user or service account to manage permissions for. Defaults to 0.
    permission str
    Permission to associate with item. Must be one of View, Edit, or Admin.
    role str
    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin.
    team_id str
    ID of the team to manage permissions for. Defaults to 0.
    user_id str
    ID of the user or service account to manage permissions for. Defaults to 0.
    permission String
    Permission to associate with item. Must be one of View, Edit, or Admin.
    role String
    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin.
    teamId String
    ID of the team to manage permissions for. Defaults to 0.
    userId String
    ID of the user or service account to manage permissions for. Defaults to 0.

    Import

    $ pulumi import grafana:oss/dashboardPermission:DashboardPermission name "{{ dashboardUID }}"
    
    $ pulumi import grafana:oss/dashboardPermission:DashboardPermission name "{{ orgID }}:{{ dashboardUID }}"
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    grafana pulumiverse/pulumi-grafana
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the grafana Terraform Provider.
    grafana logo
    Grafana v0.7.0 published on Tuesday, Nov 5, 2024 by pulumiverse