1. Packages
  2. Grafana Cloud
  3. API Docs
  4. DataSourcePermission
Grafana v0.1.0 published on Monday, Sep 11, 2023 by lbrlabs

grafana.DataSourcePermission

Explore with Pulumi AI

grafana logo
Grafana v0.1.0 published on Monday, Sep 11, 2023 by lbrlabs

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Grafana = Lbrlabs.PulumiPackage.Grafana;
    
    return await Deployment.RunAsync(() => 
    {
        var team = new Grafana.Team("team");
    
        var foo = new Grafana.DataSource("foo", new()
        {
            Type = "cloudwatch",
            JsonDataEncoded = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["defaultRegion"] = "us-east-1",
                ["authType"] = "keys",
            }),
            SecureJsonDataEncoded = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["accessKey"] = "123",
                ["secretKey"] = "456",
            }),
        });
    
        var fooPermissions = new Grafana.DataSourcePermission("fooPermissions", new()
        {
            DatasourceId = foo.Id,
            Permissions = new[]
            {
                new Grafana.Inputs.DataSourcePermissionPermissionArgs
                {
                    TeamId = team.Id,
                    Permission = "Query",
                },
                new Grafana.Inputs.DataSourcePermissionPermissionArgs
                {
                    UserId = 3,
                    Permission = "Edit",
                },
                new Grafana.Inputs.DataSourcePermissionPermissionArgs
                {
                    BuiltInRole = "Viewer",
                    Permission = "Query",
                },
            },
        });
    
    });
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/lbrlabs/pulumi-grafana/sdk/go/grafana"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		team, err := grafana.NewTeam(ctx, "team", nil)
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"defaultRegion": "us-east-1",
    			"authType":      "keys",
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		tmpJSON1, err := json.Marshal(map[string]interface{}{
    			"accessKey": "123",
    			"secretKey": "456",
    		})
    		if err != nil {
    			return err
    		}
    		json1 := string(tmpJSON1)
    		foo, err := grafana.NewDataSource(ctx, "foo", &grafana.DataSourceArgs{
    			Type:                  pulumi.String("cloudwatch"),
    			JsonDataEncoded:       pulumi.String(json0),
    			SecureJsonDataEncoded: pulumi.String(json1),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = grafana.NewDataSourcePermission(ctx, "fooPermissions", &grafana.DataSourcePermissionArgs{
    			DatasourceId: foo.ID(),
    			Permissions: grafana.DataSourcePermissionPermissionArray{
    				&grafana.DataSourcePermissionPermissionArgs{
    					TeamId:     team.ID(),
    					Permission: pulumi.String("Query"),
    				},
    				&grafana.DataSourcePermissionPermissionArgs{
    					UserId:     pulumi.Int(3),
    					Permission: pulumi.String("Edit"),
    				},
    				&grafana.DataSourcePermissionPermissionArgs{
    					BuiltInRole: pulumi.String("Viewer"),
    					Permission:  pulumi.String("Query"),
    				},
    			},
    		})
    		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.DataSource;
    import com.pulumi.grafana.DataSourceArgs;
    import com.pulumi.grafana.DataSourcePermission;
    import com.pulumi.grafana.DataSourcePermissionArgs;
    import com.pulumi.grafana.inputs.DataSourcePermissionPermissionArgs;
    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");
    
            var foo = new DataSource("foo", DataSourceArgs.builder()        
                .type("cloudwatch")
                .jsonDataEncoded(serializeJson(
                    jsonObject(
                        jsonProperty("defaultRegion", "us-east-1"),
                        jsonProperty("authType", "keys")
                    )))
                .secureJsonDataEncoded(serializeJson(
                    jsonObject(
                        jsonProperty("accessKey", "123"),
                        jsonProperty("secretKey", "456")
                    )))
                .build());
    
            var fooPermissions = new DataSourcePermission("fooPermissions", DataSourcePermissionArgs.builder()        
                .datasourceId(foo.id())
                .permissions(            
                    DataSourcePermissionPermissionArgs.builder()
                        .teamId(team.id())
                        .permission("Query")
                        .build(),
                    DataSourcePermissionPermissionArgs.builder()
                        .userId(3)
                        .permission("Edit")
                        .build(),
                    DataSourcePermissionPermissionArgs.builder()
                        .builtInRole("Viewer")
                        .permission("Query")
                        .build())
                .build());
    
        }
    }
    
    import pulumi
    import json
    import lbrlabs_pulumi_grafana as grafana
    
    team = grafana.Team("team")
    foo = grafana.DataSource("foo",
        type="cloudwatch",
        json_data_encoded=json.dumps({
            "defaultRegion": "us-east-1",
            "authType": "keys",
        }),
        secure_json_data_encoded=json.dumps({
            "accessKey": "123",
            "secretKey": "456",
        }))
    foo_permissions = grafana.DataSourcePermission("fooPermissions",
        datasource_id=foo.id,
        permissions=[
            grafana.DataSourcePermissionPermissionArgs(
                team_id=team.id,
                permission="Query",
            ),
            grafana.DataSourcePermissionPermissionArgs(
                user_id=3,
                permission="Edit",
            ),
            grafana.DataSourcePermissionPermissionArgs(
                built_in_role="Viewer",
                permission="Query",
            ),
        ])
    
    import * as pulumi from "@pulumi/pulumi";
    import * as grafana from "@lbrlabs/pulumi-grafana";
    
    const team = new grafana.Team("team", {});
    const foo = new grafana.DataSource("foo", {
        type: "cloudwatch",
        jsonDataEncoded: JSON.stringify({
            defaultRegion: "us-east-1",
            authType: "keys",
        }),
        secureJsonDataEncoded: JSON.stringify({
            accessKey: "123",
            secretKey: "456",
        }),
    });
    const fooPermissions = new grafana.DataSourcePermission("fooPermissions", {
        datasourceId: foo.id,
        permissions: [
            {
                teamId: team.id,
                permission: "Query",
            },
            {
                userId: 3,
                permission: "Edit",
            },
            {
                builtInRole: "Viewer",
                permission: "Query",
            },
        ],
    });
    
    resources:
      team:
        type: grafana:Team
      foo:
        type: grafana:DataSource
        properties:
          type: cloudwatch
          jsonDataEncoded:
            fn::toJSON:
              defaultRegion: us-east-1
              authType: keys
          secureJsonDataEncoded:
            fn::toJSON:
              accessKey: '123'
              secretKey: '456'
      fooPermissions:
        type: grafana:DataSourcePermission
        properties:
          datasourceId: ${foo.id}
          permissions:
            - teamId: ${team.id}
              permission: Query
            - userId: 3
              permission: Edit
            - builtInRole: Viewer
              permission: Query
    

    Create DataSourcePermission Resource

    new DataSourcePermission(name: string, args: DataSourcePermissionArgs, opts?: CustomResourceOptions);
    @overload
    def DataSourcePermission(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             datasource_id: Optional[str] = None,
                             org_id: Optional[str] = None,
                             permissions: Optional[Sequence[DataSourcePermissionPermissionArgs]] = None)
    @overload
    def DataSourcePermission(resource_name: str,
                             args: DataSourcePermissionArgs,
                             opts: Optional[ResourceOptions] = None)
    func NewDataSourcePermission(ctx *Context, name string, args DataSourcePermissionArgs, opts ...ResourceOption) (*DataSourcePermission, error)
    public DataSourcePermission(string name, DataSourcePermissionArgs args, CustomResourceOptions? opts = null)
    public DataSourcePermission(String name, DataSourcePermissionArgs args)
    public DataSourcePermission(String name, DataSourcePermissionArgs args, CustomResourceOptions options)
    
    type: grafana:DataSourcePermission
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args DataSourcePermissionArgs
    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 DataSourcePermissionArgs
    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 DataSourcePermissionArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args DataSourcePermissionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args DataSourcePermissionArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    DataSourcePermission 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 DataSourcePermission resource accepts the following input properties:

    DatasourceId string

    ID of the datasource to apply permissions to.

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

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

    OrgId string

    The Organization ID. If not set, the Org ID defined in the provider block will be used.

    DatasourceId string

    ID of the datasource to apply permissions to.

    Permissions []DataSourcePermissionPermissionArgs

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

    OrgId string

    The Organization ID. If not set, the Org ID defined in the provider block will be used.

    datasourceId String

    ID of the datasource to apply permissions to.

    permissions List<DataSourcePermissionPermission>

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

    orgId String

    The Organization ID. If not set, the Org ID defined in the provider block will be used.

    datasourceId string

    ID of the datasource to apply permissions to.

    permissions DataSourcePermissionPermission[]

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

    orgId string

    The Organization ID. If not set, the Org ID defined in the provider block will be used.

    datasource_id str

    ID of the datasource to apply permissions to.

    permissions Sequence[DataSourcePermissionPermissionArgs]

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

    org_id str

    The Organization ID. If not set, the Org ID defined in the provider block will be used.

    datasourceId String

    ID of the datasource to apply permissions to.

    permissions List<Property Map>

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

    orgId String

    The Organization ID. If not set, the Org ID defined in the provider block will be used.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the DataSourcePermission 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 DataSourcePermission Resource

    Get an existing DataSourcePermission 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?: DataSourcePermissionState, opts?: CustomResourceOptions): DataSourcePermission
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            datasource_id: Optional[str] = None,
            org_id: Optional[str] = None,
            permissions: Optional[Sequence[DataSourcePermissionPermissionArgs]] = None) -> DataSourcePermission
    func GetDataSourcePermission(ctx *Context, name string, id IDInput, state *DataSourcePermissionState, opts ...ResourceOption) (*DataSourcePermission, error)
    public static DataSourcePermission Get(string name, Input<string> id, DataSourcePermissionState? state, CustomResourceOptions? opts = null)
    public static DataSourcePermission get(String name, Output<String> id, DataSourcePermissionState 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:
    DatasourceId string

    ID of the datasource 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<Lbrlabs.PulumiPackage.Grafana.Inputs.DataSourcePermissionPermission>

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

    DatasourceId string

    ID of the datasource to apply permissions to.

    OrgId string

    The Organization ID. If not set, the Org ID defined in the provider block will be used.

    Permissions []DataSourcePermissionPermissionArgs

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

    datasourceId String

    ID of the datasource 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<DataSourcePermissionPermission>

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

    datasourceId string

    ID of the datasource to apply permissions to.

    orgId string

    The Organization ID. If not set, the Org ID defined in the provider block will be used.

    permissions DataSourcePermissionPermission[]

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

    datasource_id str

    ID of the datasource 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[DataSourcePermissionPermissionArgs]

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

    datasourceId String

    ID of the datasource 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

    DataSourcePermissionPermission, DataSourcePermissionPermissionArgs

    Permission string

    Permission to associate with item. Options: Query or Edit (Edit can only be used with Grafana v9.2.3+).

    BuiltInRole string

    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin. Can only be set from Grafana v9.2.3+. Defaults to ``.

    TeamId string

    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. Options: Query or Edit (Edit can only be used with Grafana v9.2.3+).

    BuiltInRole string

    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin. Can only be set from Grafana v9.2.3+. Defaults to ``.

    TeamId string

    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. Options: Query or Edit (Edit can only be used with Grafana v9.2.3+).

    builtInRole String

    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin. Can only be set from Grafana v9.2.3+. Defaults to ``.

    teamId String

    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. Options: Query or Edit (Edit can only be used with Grafana v9.2.3+).

    builtInRole string

    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin. Can only be set from Grafana v9.2.3+. Defaults to ``.

    teamId string

    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. Options: Query or Edit (Edit can only be used with Grafana v9.2.3+).

    built_in_role str

    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin. Can only be set from Grafana v9.2.3+. Defaults to ``.

    team_id str

    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. Options: Query or Edit (Edit can only be used with Grafana v9.2.3+).

    builtInRole String

    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin. Can only be set from Grafana v9.2.3+. Defaults to ``.

    teamId String

    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
    grafana lbrlabs/pulumi-grafana
    License
    Apache-2.0
    Notes

    This Pulumi package is based on the grafana Terraform Provider.

    grafana logo
    Grafana v0.1.0 published on Monday, Sep 11, 2023 by lbrlabs