databricks.getViews
Explore with Pulumi AI
Note If you have a fully automated setup with workspaces created by databricks.MwsWorkspaces or azurerm_databricks_workspace, please make sure to add depends_on attribute in order to prevent default auth: cannot configure default credentials errors.
Retrieves a list of view full names in Unity Catalog, that were created by Pulumi or manually. Use databricks.getTables for retrieving a list of tables.
Example Usage
Granting SELECT
and MODIFY
to sensitive
group on all views in a things databricks.Schema from sandbox databricks_catalog.
import * as pulumi from "@pulumi/pulumi";
import * as databricks from "@pulumi/databricks";
export = async () => {
const things = await databricks.getViews({
catalogName: "sandbox",
schemaName: "things",
});
const thingsGrants: databricks.Grants[] = [];
for (const range of things.ids.map((v, k) => ({key: k, value: v}))) {
thingsGrants.push(new databricks.Grants(`things-${range.key}`, {
table: range.value,
grants: [{
principal: "sensitive",
privileges: [
"SELECT",
"MODIFY",
],
}],
}));
}
}
import pulumi
import pulumi_databricks as databricks
things = databricks.get_views(catalog_name="sandbox",
schema_name="things")
things_grants = []
for range in [{"key": k, "value": v} for [k, v] in enumerate(things.ids)]:
things_grants.append(databricks.Grants(f"things-{range['key']}",
table=range["value"],
grants=[{
"principal": "sensitive",
"privileges": [
"SELECT",
"MODIFY",
],
}]))
package main
import (
"github.com/pulumi/pulumi-databricks/sdk/go/databricks"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
things, err := databricks.GetViews(ctx, &databricks.GetViewsArgs{
CatalogName: "sandbox",
SchemaName: "things",
}, nil)
if err != nil {
return err
}
var thingsGrants []*databricks.Grants
for key0, val0 := range things.Ids {
__res, err := databricks.NewGrants(ctx, fmt.Sprintf("things-%v", key0), &databricks.GrantsArgs{
Table: pulumi.String(val0),
Grants: databricks.GrantsGrantArray{
&databricks.GrantsGrantArgs{
Principal: pulumi.String("sensitive"),
Privileges: pulumi.StringArray{
pulumi.String("SELECT"),
pulumi.String("MODIFY"),
},
},
},
})
if err != nil {
return err
}
thingsGrants = append(thingsGrants, __res)
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Pulumi;
using Databricks = Pulumi.Databricks;
return await Deployment.RunAsync(async() =>
{
var things = await Databricks.GetViews.InvokeAsync(new()
{
CatalogName = "sandbox",
SchemaName = "things",
});
var thingsGrants = new List<Databricks.Grants>();
foreach (var range in )
{
thingsGrants.Add(new Databricks.Grants($"things-{range.Key}", new()
{
Table = range.Value,
GrantDetails = new[]
{
new Databricks.Inputs.GrantsGrantArgs
{
Principal = "sensitive",
Privileges = new[]
{
"SELECT",
"MODIFY",
},
},
},
}));
}
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.databricks.DatabricksFunctions;
import com.pulumi.databricks.inputs.GetViewsArgs;
import com.pulumi.databricks.Grants;
import com.pulumi.databricks.GrantsArgs;
import com.pulumi.databricks.inputs.GrantsGrantArgs;
import com.pulumi.codegen.internal.KeyedValue;
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 things = DatabricksFunctions.getViews(GetViewsArgs.builder()
.catalogName("sandbox")
.schemaName("things")
.build());
final var thingsGrants = things.applyValue(getViewsResult -> {
final var resources = new ArrayList<Grants>();
for (var range : KeyedValue.of(getViewsResult.ids()) {
var resource = new Grants("thingsGrants-" + range.key(), GrantsArgs.builder()
.table(range.value())
.grants(GrantsGrantArgs.builder()
.principal("sensitive")
.privileges(
"SELECT",
"MODIFY")
.build())
.build());
resources.add(resource);
}
return resources;
});
}
}
resources:
thingsGrants:
type: databricks:Grants
name: things
properties:
table: ${range.value}
grants:
- principal: sensitive
privileges:
- SELECT
- MODIFY
options: {}
variables:
things:
fn::invoke:
Function: databricks:getViews
Arguments:
catalogName: sandbox
schemaName: things
Related Resources
The following resources are used in the same context:
- databricks.Schema to manage schemas within Unity Catalog.
- databricks.Catalog to manage catalogs within Unity Catalog.
Using getViews
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 getViews(args: GetViewsArgs, opts?: InvokeOptions): Promise<GetViewsResult>
function getViewsOutput(args: GetViewsOutputArgs, opts?: InvokeOptions): Output<GetViewsResult>
def get_views(catalog_name: Optional[str] = None,
ids: Optional[Sequence[str]] = None,
schema_name: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetViewsResult
def get_views_output(catalog_name: Optional[pulumi.Input[str]] = None,
ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
schema_name: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetViewsResult]
func GetViews(ctx *Context, args *GetViewsArgs, opts ...InvokeOption) (*GetViewsResult, error)
func GetViewsOutput(ctx *Context, args *GetViewsOutputArgs, opts ...InvokeOption) GetViewsResultOutput
> Note: This function is named GetViews
in the Go SDK.
public static class GetViews
{
public static Task<GetViewsResult> InvokeAsync(GetViewsArgs args, InvokeOptions? opts = null)
public static Output<GetViewsResult> Invoke(GetViewsInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetViewsResult> getViews(GetViewsArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: databricks:index/getViews:getViews
arguments:
# arguments dictionary
The following arguments are supported:
- Catalog
Name string - Name of databricks_catalog
- Schema
Name string - Name of databricks_schema
- Ids List<string>
- set of databricks_view full names:
catalog
.schema
.view
- Catalog
Name string - Name of databricks_catalog
- Schema
Name string - Name of databricks_schema
- Ids []string
- set of databricks_view full names:
catalog
.schema
.view
- catalog
Name String - Name of databricks_catalog
- schema
Name String - Name of databricks_schema
- ids List<String>
- set of databricks_view full names:
catalog
.schema
.view
- catalog
Name string - Name of databricks_catalog
- schema
Name string - Name of databricks_schema
- ids string[]
- set of databricks_view full names:
catalog
.schema
.view
- catalog_
name str - Name of databricks_catalog
- schema_
name str - Name of databricks_schema
- ids Sequence[str]
- set of databricks_view full names:
catalog
.schema
.view
- catalog
Name String - Name of databricks_catalog
- schema
Name String - Name of databricks_schema
- ids List<String>
- set of databricks_view full names:
catalog
.schema
.view
getViews Result
The following output properties are available:
- Catalog
Name string - Id string
- The provider-assigned unique ID for this managed resource.
- Ids List<string>
- set of databricks_view full names:
catalog
.schema
.view
- Schema
Name string
- Catalog
Name string - Id string
- The provider-assigned unique ID for this managed resource.
- Ids []string
- set of databricks_view full names:
catalog
.schema
.view
- Schema
Name string
- catalog
Name String - id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- set of databricks_view full names:
catalog
.schema
.view
- schema
Name String
- catalog
Name string - id string
- The provider-assigned unique ID for this managed resource.
- ids string[]
- set of databricks_view full names:
catalog
.schema
.view
- schema
Name string
- catalog_
name str - id str
- The provider-assigned unique ID for this managed resource.
- ids Sequence[str]
- set of databricks_view full names:
catalog
.schema
.view
- schema_
name str
- catalog
Name String - id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- set of databricks_view full names:
catalog
.schema
.view
- schema
Name String
Package Details
- Repository
- databricks pulumi/pulumi-databricks
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
databricks
Terraform Provider.