@pulumi/databricks
Version:
A Pulumi package for creating and managing databricks cloud resources.
189 lines • 7.95 kB
JavaScript
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.SqlQuery = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* !> This resource is deprecated! Please switch to databricks_query.
*
* To manage [SQLA resources](https://docs.databricks.com/sql/get-started/concepts.html) you must have `databricksSqlAccess` on your databricks.Group or databricks_user.
*
* > documentation for this resource is a work in progress.
*
* A query may have one or more visualizations.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as databricks from "@pulumi/databricks";
*
* const sharedDir = new databricks.Directory("shared_dir", {path: "/Shared/Queries"});
* const q1 = new databricks.SqlQuery("q1", {
* dataSourceId: example.dataSourceId,
* name: "My Query Name",
* query: ` SELECT {{ p1 }} AS p1
* WHERE 1=1
* AND p2 in ({{ p2 }})
* AND event_date > date '{{ p3 }}'
* `,
* parent: pulumi.interpolate`folders/${sharedDir.objectId}`,
* runAsRole: "viewer",
* parameters: [
* {
* name: "p1",
* title: "Title for p1",
* text: {
* value: "default",
* },
* },
* {
* name: "p2",
* title: "Title for p2",
* "enum": {
* options: [
* "default",
* "foo",
* "bar",
* ],
* value: "default",
* multiple: {
* prefix: "\"",
* suffix: "\"",
* separator: ",",
* },
* },
* },
* {
* name: "p3",
* title: "Title for p3",
* date: {
* value: "2022-01-01",
* },
* },
* ],
* tags: [
* "t1",
* "t2",
* ],
* });
* ```
*
* Example permission to share query with all users:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as databricks from "@pulumi/databricks";
*
* const q1 = new databricks.Permissions("q1", {
* sqlQueryId: q1DatabricksSqlQuery.id,
* accessControls: [
* {
* groupName: users.displayName,
* permissionLevel: "CAN_RUN",
* },
* {
* groupName: team.displayName,
* permissionLevel: "CAN_EDIT",
* },
* ],
* });
* ```
*
* ## Troubleshooting
*
* In case you see `Error: cannot create sql query: Internal Server Error` during `pulumi up`; double check that you are using the correct `dataSourceId`
*
* Operations on `databricks.SqlQuery` schedules are ⛔️ deprecated. You can create, update or delete a schedule for SQLA and other Databricks resources using the databricks.Job resource.
*
* ## Related Resources
*
* The following resources are often used in the same context:
*
* * End to end workspace management guide.
* * databricks.SqlDashboard to manage Databricks SQL [Dashboards](https://docs.databricks.com/sql/user/dashboards/index.html).
* * databricks.SqlEndpoint to manage Databricks SQL [Endpoints](https://docs.databricks.com/sql/admin/sql-endpoints.html).
* * databricks.SqlGlobalConfig to configure the security policy, databricks_instance_profile, and [data access properties](https://docs.databricks.com/sql/admin/data-access-configuration.html) for all databricks.SqlEndpoint of workspace.
* * databricks.SqlPermissions to manage data object access control lists in Databricks workspaces for things like tables, views, databases, and [more](https://docs.databricks.com/security/access-control/table-acls/object-privileges.html).
* * databricks.Job to schedule Databricks SQL queries (as well as dashboards and alerts) using Databricks Jobs.
*
* ## Import
*
* You can import a `databricks_sql_query` resource with ID like the following:
*
* bash
*
* ```sh
* $ pulumi import databricks:index/sqlQuery:SqlQuery this <query-id>
* ```
*/
class SqlQuery extends pulumi.CustomResource {
/**
* Get an existing SqlQuery resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new SqlQuery(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of SqlQuery. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === SqlQuery.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["createdAt"] = state ? state.createdAt : undefined;
resourceInputs["dataSourceId"] = state ? state.dataSourceId : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["parameters"] = state ? state.parameters : undefined;
resourceInputs["parent"] = state ? state.parent : undefined;
resourceInputs["query"] = state ? state.query : undefined;
resourceInputs["runAsRole"] = state ? state.runAsRole : undefined;
resourceInputs["schedule"] = state ? state.schedule : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["updatedAt"] = state ? state.updatedAt : undefined;
}
else {
const args = argsOrState;
if ((!args || args.dataSourceId === undefined) && !opts.urn) {
throw new Error("Missing required property 'dataSourceId'");
}
if ((!args || args.query === undefined) && !opts.urn) {
throw new Error("Missing required property 'query'");
}
resourceInputs["createdAt"] = args ? args.createdAt : undefined;
resourceInputs["dataSourceId"] = args ? args.dataSourceId : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["parameters"] = args ? args.parameters : undefined;
resourceInputs["parent"] = args ? args.parent : undefined;
resourceInputs["query"] = args ? args.query : undefined;
resourceInputs["runAsRole"] = args ? args.runAsRole : undefined;
resourceInputs["schedule"] = args ? args.schedule : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["updatedAt"] = args ? args.updatedAt : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(SqlQuery.__pulumiType, name, resourceInputs, opts);
}
}
exports.SqlQuery = SqlQuery;
/** @internal */
SqlQuery.__pulumiType = 'databricks:index/sqlQuery:SqlQuery';
//# sourceMappingURL=sqlQuery.js.map
;