@lbrlabs/pulumi-grafana
Version:
A Pulumi package for creating and managing grafana.
141 lines • 5.76 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.NotificationPolicy = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Sets the global notification policy for Grafana.
*
* !> This resource manages the entire notification policy tree, and will overwrite any existing policies.
*
* * [Official documentation](https://grafana.com/docs/grafana/latest/alerting/manage-notifications/)
* * [HTTP API](https://grafana.com/docs/grafana/latest/developers/http_api/alerting_provisioning/)
*
* This resource requires Grafana 9.1.0 or later.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as grafana from "@lbrlabs/pulumi-grafana";
*
* const aContactPoint = new grafana.ContactPoint("aContactPoint", {emails: [{
* addresses: [
* "one@company.org",
* "two@company.org",
* ],
* message: "{{ len .Alerts.Firing }} firing.",
* }]});
* const aMuteTiming = new grafana.MuteTiming("aMuteTiming", {intervals: [{
* weekdays: ["monday"],
* }]});
* const myNotificationPolicy = new grafana.NotificationPolicy("myNotificationPolicy", {
* groupBies: ["..."],
* contactPoint: aContactPoint.name,
* groupWait: "45s",
* groupInterval: "6m",
* repeatInterval: "3h",
* policies: [
* {
* matchers: [{
* label: "mylabel",
* match: "=",
* value: "myvalue",
* }],
* contactPoint: aContactPoint.name,
* "continue": true,
* muteTimings: [aMuteTiming.name],
* groupWait: "45s",
* groupInterval: "6m",
* repeatInterval: "3h",
* policies: [{
* matchers: [{
* label: "sublabel",
* match: "=",
* value: "subvalue",
* }],
* contactPoint: aContactPoint.name,
* groupBies: ["..."],
* }],
* },
* {
* matchers: [{
* label: "anotherlabel",
* match: "=~",
* value: "another value.*",
* }],
* contactPoint: aContactPoint.name,
* groupBies: ["..."],
* },
* ],
* });
* ```
*
* ## Import
*
* The policy is a singleton, so the ID is a constant "policy" value.
*
* ```sh
* $ pulumi import grafana:index/notificationPolicy:NotificationPolicy notification_policy_name "policy"
* ```
*/
class NotificationPolicy extends pulumi.CustomResource {
/**
* Get an existing NotificationPolicy 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 NotificationPolicy(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of NotificationPolicy. 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'] === NotificationPolicy.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["contactPoint"] = state ? state.contactPoint : undefined;
resourceInputs["groupBies"] = state ? state.groupBies : undefined;
resourceInputs["groupInterval"] = state ? state.groupInterval : undefined;
resourceInputs["groupWait"] = state ? state.groupWait : undefined;
resourceInputs["policies"] = state ? state.policies : undefined;
resourceInputs["repeatInterval"] = state ? state.repeatInterval : undefined;
}
else {
const args = argsOrState;
if ((!args || args.contactPoint === undefined) && !opts.urn) {
throw new Error("Missing required property 'contactPoint'");
}
if ((!args || args.groupBies === undefined) && !opts.urn) {
throw new Error("Missing required property 'groupBies'");
}
resourceInputs["contactPoint"] = args ? args.contactPoint : undefined;
resourceInputs["groupBies"] = args ? args.groupBies : undefined;
resourceInputs["groupInterval"] = args ? args.groupInterval : undefined;
resourceInputs["groupWait"] = args ? args.groupWait : undefined;
resourceInputs["policies"] = args ? args.policies : undefined;
resourceInputs["repeatInterval"] = args ? args.repeatInterval : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(NotificationPolicy.__pulumiType, name, resourceInputs, opts);
}
}
exports.NotificationPolicy = NotificationPolicy;
/** @internal */
NotificationPolicy.__pulumiType = 'grafana:index/notificationPolicy:NotificationPolicy';
//# sourceMappingURL=notificationPolicy.js.map