@pulumiverse/grafana
Version:
A Pulumi package for creating and managing grafana.
172 lines • 7.6 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 overwrites its policies. However, it does not overwrite internal policies created when alert rules directly set a contact point for notifications.
*
* * Official documentation
* * [HTTP API](https://grafana.com/docs/grafana/latest/developers/http_api/alerting_provisioning/#notification-policies)
*
* This resource requires Grafana 9.1.0 or later.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as grafana from "@pulumiverse/grafana";
*
* const aContactPoint = new grafana.alerting.ContactPoint("a_contact_point", {
* name: "A Contact Point",
* emails: [{
* addresses: [
* "one@company.org",
* "two@company.org",
* ],
* message: "{{ len .Alerts.Firing }} firing.",
* }],
* });
* const aMuteTiming = new grafana.alerting.MuteTiming("a_mute_timing", {
* name: "Some Mute Timing",
* intervals: [{
* weekdays: ["monday"],
* }],
* });
* const myNotificationPolicy = new grafana.alerting.NotificationPolicy("my_notification_policy", {
* groupBies: ["..."],
* contactPoint: aContactPoint.name,
* groupWait: "45s",
* groupInterval: "6m",
* repeatInterval: "3h",
* policies: [
* {
* matchers: [
* {
* label: "mylabel",
* match: "=",
* value: "myvalue",
* },
* {
* label: "alertname",
* match: "=",
* value: "CPU Usage",
* },
* {
* label: "Name",
* match: "=~",
* value: "host.*|host-b.*",
* },
* ],
* 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
*
* ```sh
* $ pulumi import grafana:index/notificationPolicy:NotificationPolicy name "{{ anyString }}"
* ```
*
* ```sh
* $ pulumi import grafana:index/notificationPolicy:NotificationPolicy name "{{ orgID }}:{{ anyString }}"
* ```
*
* @deprecated grafana.index/notificationpolicy.NotificationPolicy has been deprecated in favor of grafana.alerting/notificationpolicy.NotificationPolicy
*/
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) {
pulumi.log.warn("NotificationPolicy is deprecated: grafana.index/notificationpolicy.NotificationPolicy has been deprecated in favor of grafana.alerting/notificationpolicy.NotificationPolicy");
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;
}
/** @deprecated grafana.index/notificationpolicy.NotificationPolicy has been deprecated in favor of grafana.alerting/notificationpolicy.NotificationPolicy */
constructor(name, argsOrState, opts) {
pulumi.log.warn("NotificationPolicy is deprecated: grafana.index/notificationpolicy.NotificationPolicy has been deprecated in favor of grafana.alerting/notificationpolicy.NotificationPolicy");
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["contactPoint"] = state ? state.contactPoint : undefined;
resourceInputs["disableProvenance"] = state ? state.disableProvenance : undefined;
resourceInputs["groupBies"] = state ? state.groupBies : undefined;
resourceInputs["groupInterval"] = state ? state.groupInterval : undefined;
resourceInputs["groupWait"] = state ? state.groupWait : undefined;
resourceInputs["orgId"] = state ? state.orgId : 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["disableProvenance"] = args ? args.disableProvenance : undefined;
resourceInputs["groupBies"] = args ? args.groupBies : undefined;
resourceInputs["groupInterval"] = args ? args.groupInterval : undefined;
resourceInputs["groupWait"] = args ? args.groupWait : undefined;
resourceInputs["orgId"] = args ? args.orgId : undefined;
resourceInputs["policies"] = args ? args.policies : undefined;
resourceInputs["repeatInterval"] = args ? args.repeatInterval : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const aliasOpts = { aliases: [{ type: "grafana:index/notificationPolicy:NotificationPolicy" }] };
opts = pulumi.mergeOptions(opts, aliasOpts);
super(NotificationPolicy.__pulumiType, name, resourceInputs, opts);
}
}
exports.NotificationPolicy = NotificationPolicy;
/** @internal */
NotificationPolicy.__pulumiType = 'grafana:index/notificationPolicy:NotificationPolicy';
//# sourceMappingURL=notificationPolicy.js.map