@pulumi/databricks
Version:
A Pulumi package for creating and managing databricks cloud resources.
156 lines • 6.84 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.MlflowWebhook = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* This resource allows you to create [MLflow Model Registry Webhooks](https://docs.databricks.com/applications/mlflow/model-registry-webhooks.html) in Databricks. Webhooks enable you to listen for Model Registry events so your integrations can automatically trigger actions. You can use webhooks to automate and integrate your machine learning pipeline with existing CI/CD tools and workflows. Webhooks allow trigger execution of a Databricks job or call a web service on specific event(s) that is generated in the MLflow Registry - stage transitioning, creation of registered model, creation of transition request, etc.
*
* ## Example Usage
*
* ### Triggering Databricks job
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as databricks from "@pulumi/databricks";
* import * as std from "@pulumi/std";
*
* const me = databricks.getCurrentUser({});
* const latest = databricks.getSparkVersion({});
* const smallest = databricks.getNodeType({
* localDisk: true,
* });
* const _this = new databricks.Notebook("this", {
* path: me.then(me => `${me.home}/MLFlowWebhook`),
* language: "PYTHON",
* contentBase64: std.base64encode({
* input: `import json
*
* event_message = dbutils.widgets.get("event_message")
* event_message_dict = json.loads(event_message)
* print(f"event data={event_message_dict}")
* `,
* }).then(invoke => invoke.result),
* });
* const thisJob = new databricks.Job("this", {
* name: me.then(me => `Pulumi MLflowWebhook Demo (${me.alphanumeric})`),
* tasks: [{
* taskKey: "task1",
* newCluster: {
* numWorkers: 1,
* sparkVersion: latest.then(latest => latest.id),
* nodeTypeId: smallest.then(smallest => smallest.id),
* },
* notebookTask: {
* notebookPath: _this.path,
* },
* }],
* });
* const patForWebhook = new databricks.Token("pat_for_webhook", {
* comment: "MLflow Webhook",
* lifetimeSeconds: 86400000,
* });
* const job = new databricks.MlflowWebhook("job", {
* events: ["TRANSITION_REQUEST_CREATED"],
* description: "Databricks Job webhook trigger",
* status: "ACTIVE",
* jobSpec: {
* jobId: thisJob.id,
* workspaceUrl: me.then(me => me.workspaceUrl),
* accessToken: patForWebhook.tokenValue,
* },
* });
* ```
*
* ### POSTing to URL
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as databricks from "@pulumi/databricks";
*
* const url = new databricks.MlflowWebhook("url", {
* events: ["TRANSITION_REQUEST_CREATED"],
* description: "URL webhook trigger",
* httpUrlSpec: {
* url: "https://my_cool_host/webhook",
* },
* });
* ```
*
* ## Access Control
*
* * MLflow webhooks could be configured only by workspace admins.
*
* ## Related Resources
*
* The following resources are often used in the same context:
*
* * End to end workspace management guide.
* * databricks.Directory to manage directories in [Databricks Workpace](https://docs.databricks.com/workspace/workspace-objects.html).
* * databricks.MlflowExperiment to manage [MLflow experiments](https://docs.databricks.com/data/data-sources/mlflow-experiment.html) in Databricks.
* * databricks.MlflowModel to create [MLflow models](https://docs.databricks.com/applications/mlflow/models.html) in Databricks.
* * databricks.Notebook to manage [Databricks Notebooks](https://docs.databricks.com/notebooks/index.html).
* * databricks.Notebook data to export a notebook from Databricks Workspace.
* * databricks.Repo to manage [Databricks Repos](https://docs.databricks.com/repos.html).
*
* ## Import
*
* !> Importing this resource is not currently supported.
*/
class MlflowWebhook extends pulumi.CustomResource {
/**
* Get an existing MlflowWebhook 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 MlflowWebhook(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of MlflowWebhook. 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'] === MlflowWebhook.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["events"] = state ? state.events : undefined;
resourceInputs["httpUrlSpec"] = state ? state.httpUrlSpec : undefined;
resourceInputs["jobSpec"] = state ? state.jobSpec : undefined;
resourceInputs["modelName"] = state ? state.modelName : undefined;
resourceInputs["status"] = state ? state.status : undefined;
}
else {
const args = argsOrState;
if ((!args || args.events === undefined) && !opts.urn) {
throw new Error("Missing required property 'events'");
}
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["events"] = args ? args.events : undefined;
resourceInputs["httpUrlSpec"] = args ? args.httpUrlSpec : undefined;
resourceInputs["jobSpec"] = args ? args.jobSpec : undefined;
resourceInputs["modelName"] = args ? args.modelName : undefined;
resourceInputs["status"] = args ? args.status : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(MlflowWebhook.__pulumiType, name, resourceInputs, opts);
}
}
exports.MlflowWebhook = MlflowWebhook;
/** @internal */
MlflowWebhook.__pulumiType = 'databricks:index/mlflowWebhook:MlflowWebhook';
//# sourceMappingURL=mlflowWebhook.js.map
;