Grafana

v0.0.3 published on Sunday, Sep 18, 2022 by lbrlabs

DashboardPermission

Example Usage

using System.Collections.Generic;
using System.IO;
using Pulumi;
using Grafana = Lbrlabs.PulumiPackage.Grafana;

return await Deployment.RunAsync(() => 
{
    var team = new Grafana.Team("team");

    var user = new Grafana.User("user", new()
    {
        Email = "user.name@example.com",
    });

    var metrics = new Grafana.Dashboard("metrics", new()
    {
        ConfigJson = File.ReadAllText("grafana-dashboard.json"),
    });

    var collectionPermission = new Grafana.DashboardPermission("collectionPermission", new()
    {
        DashboardId = metrics.DashboardId,
        Permissions = new[]
        {
            new Grafana.Inputs.DashboardPermissionPermissionArgs
            {
                Role = "Editor",
                Permission = "Edit",
            },
            new Grafana.Inputs.DashboardPermissionPermissionArgs
            {
                TeamId = team.Id,
                Permission = "View",
            },
            new Grafana.Inputs.DashboardPermissionPermissionArgs
            {
                UserId = user.Id,
                Permission = "Admin",
            },
        },
    });

});
package main

import (
	"io/ioutil"

	"github.com/lbrlabs/pulumi-grafana/sdk/go/grafana"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func readFileOrPanic(path string) pulumi.StringPtrInput {
	data, err := ioutil.ReadFile(path)
	if err != nil {
		panic(err.Error())
	}
	return pulumi.String(string(data))
}

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		team, err := grafana.NewTeam(ctx, "team", nil)
		if err != nil {
			return err
		}
		user, err := grafana.NewUser(ctx, "user", &grafana.UserArgs{
			Email: pulumi.String("user.name@example.com"),
		})
		if err != nil {
			return err
		}
		metrics, err := grafana.NewDashboard(ctx, "metrics", &grafana.DashboardArgs{
			ConfigJson: readFileOrPanic("grafana-dashboard.json"),
		})
		if err != nil {
			return err
		}
		_, err = grafana.NewDashboardPermission(ctx, "collectionPermission", &grafana.DashboardPermissionArgs{
			DashboardId: metrics.DashboardId,
			Permissions: DashboardPermissionPermissionArray{
				&DashboardPermissionPermissionArgs{
					Role:       pulumi.String("Editor"),
					Permission: pulumi.String("Edit"),
				},
				&DashboardPermissionPermissionArgs{
					TeamId:     team.ID(),
					Permission: pulumi.String("View"),
				},
				&DashboardPermissionPermissionArgs{
					UserId:     user.ID(),
					Permission: pulumi.String("Admin"),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.grafana.Team;
import com.pulumi.grafana.User;
import com.pulumi.grafana.UserArgs;
import com.pulumi.grafana.Dashboard;
import com.pulumi.grafana.DashboardArgs;
import com.pulumi.grafana.DashboardPermission;
import com.pulumi.grafana.DashboardPermissionArgs;
import com.pulumi.grafana.inputs.DashboardPermissionPermissionArgs;
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");

        var user = new User("user", UserArgs.builder()        
            .email("user.name@example.com")
            .build());

        var metrics = new Dashboard("metrics", DashboardArgs.builder()        
            .configJson(Files.readString(Paths.get("grafana-dashboard.json")))
            .build());

        var collectionPermission = new DashboardPermission("collectionPermission", DashboardPermissionArgs.builder()        
            .dashboardId(metrics.dashboardId())
            .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());

    }
}
import pulumi
import lbrlabs_pulumi_grafana as grafana

team = grafana.Team("team")
user = grafana.User("user", email="user.name@example.com")
metrics = grafana.Dashboard("metrics", config_json=(lambda path: open(path).read())("grafana-dashboard.json"))
collection_permission = grafana.DashboardPermission("collectionPermission",
    dashboard_id=metrics.dashboard_id,
    permissions=[
        grafana.DashboardPermissionPermissionArgs(
            role="Editor",
            permission="Edit",
        ),
        grafana.DashboardPermissionPermissionArgs(
            team_id=team.id,
            permission="View",
        ),
        grafana.DashboardPermissionPermissionArgs(
            user_id=user.id,
            permission="Admin",
        ),
    ])
import * as pulumi from "@pulumi/pulumi";
import * as fs from "fs";
import * as grafana from "@lbrlabs/pulumi-grafana";

const team = new grafana.Team("team", {});
const user = new grafana.User("user", {email: "user.name@example.com"});
const metrics = new grafana.Dashboard("metrics", {configJson: fs.readFileSync("grafana-dashboard.json")});
const collectionPermission = new grafana.DashboardPermission("collectionPermission", {
    dashboardId: metrics.dashboardId,
    permissions: [
        {
            role: "Editor",
            permission: "Edit",
        },
        {
            teamId: team.id,
            permission: "View",
        },
        {
            userId: user.id,
            permission: "Admin",
        },
    ],
});

Coming soon!

Create a DashboardPermission Resource

new DashboardPermission(name: string, args: DashboardPermissionArgs, opts?: CustomResourceOptions);
@overload
def DashboardPermission(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        dashboard_id: Optional[int] = None,
                        permissions: Optional[Sequence[DashboardPermissionPermissionArgs]] = None)
@overload
def DashboardPermission(resource_name: str,
                        args: DashboardPermissionArgs,
                        opts: Optional[ResourceOptions] = None)
func NewDashboardPermission(ctx *Context, name string, args DashboardPermissionArgs, opts ...ResourceOption) (*DashboardPermission, error)
public DashboardPermission(string name, DashboardPermissionArgs args, CustomResourceOptions? opts = null)
public DashboardPermission(String name, DashboardPermissionArgs args)
public DashboardPermission(String name, DashboardPermissionArgs args, CustomResourceOptions options)
type: grafana:DashboardPermission
properties: # The arguments to resource properties.
options: # 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.
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.

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

The DashboardPermission resource accepts the following input properties:

DashboardId int

ID of the dashboard to apply permissions to.

Permissions List<Lbrlabs.PulumiPackage.Grafana.Inputs.DashboardPermissionPermissionArgs>

The permission items to add/update. Items that are omitted from the list will be removed.

DashboardId int

ID of the dashboard to apply permissions to.

Permissions []DashboardPermissionPermissionArgs

The permission items to add/update. Items that are omitted from the list will be removed.

dashboardId Integer

ID of the dashboard to apply permissions to.

permissions List<DashboardPermissionPermissionArgs>

The permission items to add/update. Items that are omitted from the list will be removed.

dashboardId number

ID of the dashboard to apply permissions to.

permissions DashboardPermissionPermissionArgs[]

The permission items to add/update. Items that are omitted from the list will be removed.

dashboard_id int

ID of the dashboard to apply permissions to.

permissions Sequence[DashboardPermissionPermissionArgs]

The permission items to add/update. Items that are omitted from the list will be removed.

dashboardId Number

ID of the dashboard to apply permissions to.

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 an 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_id: Optional[int] = 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:
DashboardId int

ID of the dashboard to apply permissions to.

Permissions List<Lbrlabs.PulumiPackage.Grafana.Inputs.DashboardPermissionPermissionArgs>

The permission items to add/update. Items that are omitted from the list will be removed.

DashboardId int

ID of the dashboard to apply permissions to.

Permissions []DashboardPermissionPermissionArgs

The permission items to add/update. Items that are omitted from the list will be removed.

dashboardId Integer

ID of the dashboard to apply permissions to.

permissions List<DashboardPermissionPermissionArgs>

The permission items to add/update. Items that are omitted from the list will be removed.

dashboardId number

ID of the dashboard to apply permissions to.

permissions DashboardPermissionPermissionArgs[]

The permission items to add/update. Items that are omitted from the list will be removed.

dashboard_id int

ID of the dashboard to apply permissions to.

permissions Sequence[DashboardPermissionPermissionArgs]

The permission items to add/update. Items that are omitted from the list will be removed.

dashboardId Number

ID of the dashboard to apply permissions to.

permissions List<Property Map>

The permission items to add/update. Items that are omitted from the list will be removed.

Supporting Types

DashboardPermissionPermission

Permission string

Permission to associate with item. Must be one of View, Edit, or Admin.

Role string

Manage permissions for Viewer or Editor roles.

TeamId int

ID of the team to manage permissions for. Defaults to 0.

UserId int

ID of the user to manage permissions for. Defaults to 0.

Permission string

Permission to associate with item. Must be one of View, Edit, or Admin.

Role string

Manage permissions for Viewer or Editor roles.

TeamId int

ID of the team to manage permissions for. Defaults to 0.

UserId int

ID of the user to manage permissions for. Defaults to 0.

permission String

Permission to associate with item. Must be one of View, Edit, or Admin.

role String

Manage permissions for Viewer or Editor roles.

teamId Integer

ID of the team to manage permissions for. Defaults to 0.

userId Integer

ID of the user to manage permissions for. Defaults to 0.

permission string

Permission to associate with item. Must be one of View, Edit, or Admin.

role string

Manage permissions for Viewer or Editor roles.

teamId number

ID of the team to manage permissions for. Defaults to 0.

userId number

ID of the user to manage permissions for. Defaults to 0.

permission str

Permission to associate with item. Must be one of View, Edit, or Admin.

role str

Manage permissions for Viewer or Editor roles.

team_id int

ID of the team to manage permissions for. Defaults to 0.

user_id int

ID of the user to manage permissions for. Defaults to 0.

permission String

Permission to associate with item. Must be one of View, Edit, or Admin.

role String

Manage permissions for Viewer or Editor roles.

teamId Number

ID of the team to manage permissions for. Defaults to 0.

userId Number

ID of the user to manage permissions for. Defaults to 0.

Package Details

Repository
https://github.com/lbrlabs/pulumi-grafana
License
Apache-2.0
Notes

This Pulumi package is based on the grafana Terraform Provider.