Welcome to Pulumi Registry, your window into the cloud. Read the announcement.

Opsgenie

v1.1.0 published on Thursday, Nov 11, 2021 by Pulumi

NotificationRule

Manages a Notification Rule within Opsgenie.

Example Usage

using Pulumi;
using Opsgenie = Pulumi.Opsgenie;

class MyStack : Stack
{
    public MyStack()
    {
        var testUser = new Opsgenie.User("testUser", new Opsgenie.UserArgs
        {
            Username = "Example user",
            FullName = "Name Lastname",
            Role = "User",
        });
        var testNotificationRule = new Opsgenie.NotificationRule("testNotificationRule", new Opsgenie.NotificationRuleArgs
        {
            Username = testUser.Username,
            ActionType = "schedule-end",
            NotificationTimes = 
            {
                "just-before",
                "15-minutes-ago",
            },
            Steps = 
            {
                new Opsgenie.Inputs.NotificationRuleStepArgs
                {
                    Contacts = 
                    {
                        new Opsgenie.Inputs.NotificationRuleStepContactArgs
                        {
                            Method = "email",
                            To = "example@user.com",
                        },
                    },
                },
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-opsgenie/sdk/go/opsgenie"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		testUser, err := opsgenie.NewUser(ctx, "testUser", &opsgenie.UserArgs{
			Username: pulumi.String("Example user"),
			FullName: pulumi.String("Name Lastname"),
			Role:     pulumi.String("User"),
		})
		if err != nil {
			return err
		}
		_, err = opsgenie.NewNotificationRule(ctx, "testNotificationRule", &opsgenie.NotificationRuleArgs{
			Username:   testUser.Username,
			ActionType: pulumi.String("schedule-end"),
			NotificationTimes: pulumi.StringArray{
				pulumi.String("just-before"),
				pulumi.String("15-minutes-ago"),
			},
			Steps: NotificationRuleStepArray{
				&NotificationRuleStepArgs{
					Contacts: NotificationRuleStepContactArray{
						&NotificationRuleStepContactArgs{
							Method: pulumi.String("email"),
							To:     pulumi.String("example@user.com"),
						},
					},
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_opsgenie as opsgenie

test_user = opsgenie.User("testUser",
    username="Example user",
    full_name="Name Lastname",
    role="User")
test_notification_rule = opsgenie.NotificationRule("testNotificationRule",
    username=test_user.username,
    action_type="schedule-end",
    notification_times=[
        "just-before",
        "15-minutes-ago",
    ],
    steps=[opsgenie.NotificationRuleStepArgs(
        contacts=[opsgenie.NotificationRuleStepContactArgs(
            method="email",
            to="example@user.com",
        )],
    )])
import * as pulumi from "@pulumi/pulumi";
import * as opsgenie from "@pulumi/opsgenie";

const testUser = new opsgenie.User("testUser", {
    username: "Example user",
    fullName: "Name Lastname",
    role: "User",
});
const testNotificationRule = new opsgenie.NotificationRule("testNotificationRule", {
    username: testUser.username,
    actionType: "schedule-end",
    notificationTimes: [
        "just-before",
        "15-minutes-ago",
    ],
    steps: [{
        contacts: [{
            method: "email",
            to: "example@user.com",
        }],
    }],
});

Create a NotificationRule Resource

new NotificationRule(name: string, args: NotificationRuleArgs, opts?: CustomResourceOptions);
@overload
def NotificationRule(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     action_type: Optional[str] = None,
                     criterias: Optional[Sequence[NotificationRuleCriteriaArgs]] = None,
                     enabled: Optional[bool] = None,
                     name: Optional[str] = None,
                     notification_times: Optional[Sequence[str]] = None,
                     order: Optional[int] = None,
                     repeats: Optional[Sequence[NotificationRuleRepeatArgs]] = None,
                     schedules: Optional[Sequence[NotificationRuleScheduleArgs]] = None,
                     steps: Optional[Sequence[NotificationRuleStepArgs]] = None,
                     time_restrictions: Optional[Sequence[NotificationRuleTimeRestrictionArgs]] = None,
                     username: Optional[str] = None)
@overload
def NotificationRule(resource_name: str,
                     args: NotificationRuleArgs,
                     opts: Optional[ResourceOptions] = None)
func NewNotificationRule(ctx *Context, name string, args NotificationRuleArgs, opts ...ResourceOption) (*NotificationRule, error)
public NotificationRule(string name, NotificationRuleArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args NotificationRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args NotificationRuleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args NotificationRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args NotificationRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

NotificationRule Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The NotificationRule resource accepts the following input properties:

ActionType string
Type of the action that notification rule will have. Allowed values: create-alert, acknowledged-alert, closed-alert, assigned-alert, add-note, schedule-start, schedule-end, incoming-call-routing
Username string
Username of user to which this notification rule belongs to.
Criterias List<NotificationRuleCriteriaArgs>
Enabled bool
Defined if this step is enabled. Default: true
Name string
Name of the notification policy
NotificationTimes List<string>
List of Time Periods that notification for schedule start/end will be sent. Allowed values: just-before, 15-minutes-ago, 1-hour-ago, 1-day-ago. If action_type is schedule-start or schedule-end then it is required.
Order int
Order of the condition in conditions list
Repeats List<NotificationRuleRepeatArgs>
Schedules List<NotificationRuleScheduleArgs>
Steps List<NotificationRuleStepArgs>
Notification rule steps to take (eg. SMS or email message). This is a block, structure is documented below.
TimeRestrictions List<NotificationRuleTimeRestrictionArgs>
ActionType string
Type of the action that notification rule will have. Allowed values: create-alert, acknowledged-alert, closed-alert, assigned-alert, add-note, schedule-start, schedule-end, incoming-call-routing
Username string
Username of user to which this notification rule belongs to.
Criterias []NotificationRuleCriteriaArgs
Enabled bool
Defined if this step is enabled. Default: true
Name string
Name of the notification policy
NotificationTimes []string
List of Time Periods that notification for schedule start/end will be sent. Allowed values: just-before, 15-minutes-ago, 1-hour-ago, 1-day-ago. If action_type is schedule-start or schedule-end then it is required.
Order int
Order of the condition in conditions list
Repeats []NotificationRuleRepeatArgs
Schedules []NotificationRuleScheduleArgs
Steps []NotificationRuleStepArgs
Notification rule steps to take (eg. SMS or email message). This is a block, structure is documented below.
TimeRestrictions []NotificationRuleTimeRestrictionArgs
actionType string
Type of the action that notification rule will have. Allowed values: create-alert, acknowledged-alert, closed-alert, assigned-alert, add-note, schedule-start, schedule-end, incoming-call-routing
username string
Username of user to which this notification rule belongs to.
criterias NotificationRuleCriteriaArgs[]
enabled boolean
Defined if this step is enabled. Default: true
name string
Name of the notification policy
notificationTimes string[]
List of Time Periods that notification for schedule start/end will be sent. Allowed values: just-before, 15-minutes-ago, 1-hour-ago, 1-day-ago. If action_type is schedule-start or schedule-end then it is required.
order number
Order of the condition in conditions list
repeats NotificationRuleRepeatArgs[]
schedules NotificationRuleScheduleArgs[]
steps NotificationRuleStepArgs[]
Notification rule steps to take (eg. SMS or email message). This is a block, structure is documented below.
timeRestrictions NotificationRuleTimeRestrictionArgs[]
action_type str
Type of the action that notification rule will have. Allowed values: create-alert, acknowledged-alert, closed-alert, assigned-alert, add-note, schedule-start, schedule-end, incoming-call-routing
username str
Username of user to which this notification rule belongs to.
criterias Sequence[NotificationRuleCriteriaArgs]
enabled bool
Defined if this step is enabled. Default: true
name str
Name of the notification policy
notification_times Sequence[str]
List of Time Periods that notification for schedule start/end will be sent. Allowed values: just-before, 15-minutes-ago, 1-hour-ago, 1-day-ago. If action_type is schedule-start or schedule-end then it is required.
order int
Order of the condition in conditions list
repeats Sequence[NotificationRuleRepeatArgs]
schedules Sequence[NotificationRuleScheduleArgs]
steps Sequence[NotificationRuleStepArgs]
Notification rule steps to take (eg. SMS or email message). This is a block, structure is documented below.
time_restrictions Sequence[NotificationRuleTimeRestrictionArgs]

Outputs

All input properties are implicitly available as output properties. Additionally, the NotificationRule resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.

Look up an Existing NotificationRule Resource

Get an existing NotificationRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: NotificationRuleState, opts?: CustomResourceOptions): NotificationRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        action_type: Optional[str] = None,
        criterias: Optional[Sequence[NotificationRuleCriteriaArgs]] = None,
        enabled: Optional[bool] = None,
        name: Optional[str] = None,
        notification_times: Optional[Sequence[str]] = None,
        order: Optional[int] = None,
        repeats: Optional[Sequence[NotificationRuleRepeatArgs]] = None,
        schedules: Optional[Sequence[NotificationRuleScheduleArgs]] = None,
        steps: Optional[Sequence[NotificationRuleStepArgs]] = None,
        time_restrictions: Optional[Sequence[NotificationRuleTimeRestrictionArgs]] = None,
        username: Optional[str] = None) -> NotificationRule
func GetNotificationRule(ctx *Context, name string, id IDInput, state *NotificationRuleState, opts ...ResourceOption) (*NotificationRule, error)
public static NotificationRule Get(string name, Input<string> id, NotificationRuleState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

ActionType string
Type of the action that notification rule will have. Allowed values: create-alert, acknowledged-alert, closed-alert, assigned-alert, add-note, schedule-start, schedule-end, incoming-call-routing
Criterias List<NotificationRuleCriteriaArgs>
Enabled bool
Defined if this step is enabled. Default: true
Name string
Name of the notification policy
NotificationTimes List<string>
List of Time Periods that notification for schedule start/end will be sent. Allowed values: just-before, 15-minutes-ago, 1-hour-ago, 1-day-ago. If action_type is schedule-start or schedule-end then it is required.
Order int
Order of the condition in conditions list
Repeats List<NotificationRuleRepeatArgs>
Schedules List<NotificationRuleScheduleArgs>
Steps List<NotificationRuleStepArgs>
Notification rule steps to take (eg. SMS or email message). This is a block, structure is documented below.
TimeRestrictions List<NotificationRuleTimeRestrictionArgs>
Username string
Username of user to which this notification rule belongs to.
ActionType string
Type of the action that notification rule will have. Allowed values: create-alert, acknowledged-alert, closed-alert, assigned-alert, add-note, schedule-start, schedule-end, incoming-call-routing
Criterias []NotificationRuleCriteriaArgs
Enabled bool
Defined if this step is enabled. Default: true
Name string
Name of the notification policy
NotificationTimes []string
List of Time Periods that notification for schedule start/end will be sent. Allowed values: just-before, 15-minutes-ago, 1-hour-ago, 1-day-ago. If action_type is schedule-start or schedule-end then it is required.
Order int
Order of the condition in conditions list
Repeats []NotificationRuleRepeatArgs
Schedules []NotificationRuleScheduleArgs
Steps []NotificationRuleStepArgs
Notification rule steps to take (eg. SMS or email message). This is a block, structure is documented below.
TimeRestrictions []NotificationRuleTimeRestrictionArgs
Username string
Username of user to which this notification rule belongs to.
actionType string
Type of the action that notification rule will have. Allowed values: create-alert, acknowledged-alert, closed-alert, assigned-alert, add-note, schedule-start, schedule-end, incoming-call-routing
criterias NotificationRuleCriteriaArgs[]
enabled boolean
Defined if this step is enabled. Default: true
name string
Name of the notification policy
notificationTimes string[]
List of Time Periods that notification for schedule start/end will be sent. Allowed values: just-before, 15-minutes-ago, 1-hour-ago, 1-day-ago. If action_type is schedule-start or schedule-end then it is required.
order number
Order of the condition in conditions list
repeats NotificationRuleRepeatArgs[]
schedules NotificationRuleScheduleArgs[]
steps NotificationRuleStepArgs[]
Notification rule steps to take (eg. SMS or email message). This is a block, structure is documented below.
timeRestrictions NotificationRuleTimeRestrictionArgs[]
username string
Username of user to which this notification rule belongs to.
action_type str
Type of the action that notification rule will have. Allowed values: create-alert, acknowledged-alert, closed-alert, assigned-alert, add-note, schedule-start, schedule-end, incoming-call-routing
criterias Sequence[NotificationRuleCriteriaArgs]
enabled bool
Defined if this step is enabled. Default: true
name str
Name of the notification policy
notification_times Sequence[str]
List of Time Periods that notification for schedule start/end will be sent. Allowed values: just-before, 15-minutes-ago, 1-hour-ago, 1-day-ago. If action_type is schedule-start or schedule-end then it is required.
order int
Order of the condition in conditions list
repeats Sequence[NotificationRuleRepeatArgs]
schedules Sequence[NotificationRuleScheduleArgs]
steps Sequence[NotificationRuleStepArgs]
Notification rule steps to take (eg. SMS or email message). This is a block, structure is documented below.
time_restrictions Sequence[NotificationRuleTimeRestrictionArgs]
username str
Username of user to which this notification rule belongs to.

Supporting Types

NotificationRuleCriteria

Type string
Kind of matching filter. Possible values: match-all, match-any-condition, match-all-conditions
Conditions List<NotificationRuleCriteriaCondition>
Defines the fields and values when the condition applies
Type string
Kind of matching filter. Possible values: match-all, match-any-condition, match-all-conditions
Conditions []NotificationRuleCriteriaCondition
Defines the fields and values when the condition applies
type string
Kind of matching filter. Possible values: match-all, match-any-condition, match-all-conditions
conditions NotificationRuleCriteriaCondition[]
Defines the fields and values when the condition applies
type str
Kind of matching filter. Possible values: match-all, match-any-condition, match-all-conditions
conditions Sequence[NotificationRuleCriteriaCondition]
Defines the fields and values when the condition applies

NotificationRuleCriteriaCondition

Field string
Possible values: message, alias, description, source, entity, tags, actions, details, extra-properties, recipients, teams, priority
Operation string
Possible values: matches, contains, starts-with, ends-with, equals, contains-key, contains-value, greater-than, less-than, is-empty, equals-ignore-whitespace
ExpectedValue string
User defined value that will be compared with alert field according to the operation. Default: empty string
Key string
If ‘field’ is set as ‘extra-properties’, key could be used for key-value pair
Not bool
Indicates behaviour of the given operation. Default: false
Order int
Order of the condition in conditions list
Field string
Possible values: message, alias, description, source, entity, tags, actions, details, extra-properties, recipients, teams, priority
Operation string
Possible values: matches, contains, starts-with, ends-with, equals, contains-key, contains-value, greater-than, less-than, is-empty, equals-ignore-whitespace
ExpectedValue string
User defined value that will be compared with alert field according to the operation. Default: empty string
Key string
If ‘field’ is set as ‘extra-properties’, key could be used for key-value pair
Not bool
Indicates behaviour of the given operation. Default: false
Order int
Order of the condition in conditions list
field string
Possible values: message, alias, description, source, entity, tags, actions, details, extra-properties, recipients, teams, priority
operation string
Possible values: matches, contains, starts-with, ends-with, equals, contains-key, contains-value, greater-than, less-than, is-empty, equals-ignore-whitespace
expectedValue string
User defined value that will be compared with alert field according to the operation. Default: empty string
key string
If ‘field’ is set as ‘extra-properties’, key could be used for key-value pair
not boolean
Indicates behaviour of the given operation. Default: false
order number
Order of the condition in conditions list
field str
Possible values: message, alias, description, source, entity, tags, actions, details, extra-properties, recipients, teams, priority
operation str
Possible values: matches, contains, starts-with, ends-with, equals, contains-key, contains-value, greater-than, less-than, is-empty, equals-ignore-whitespace
expected_value str
User defined value that will be compared with alert field according to the operation. Default: empty string
key str
If ‘field’ is set as ‘extra-properties’, key could be used for key-value pair
not_ bool
Indicates behaviour of the given operation. Default: false
order int
Order of the condition in conditions list

NotificationRuleRepeat

LoopAfter int
Enabled bool
Defined if this step is enabled. Default: true
LoopAfter int
Enabled bool
Defined if this step is enabled. Default: true
loopAfter number
enabled boolean
Defined if this step is enabled. Default: true
loop_after int
enabled bool
Defined if this step is enabled. Default: true

NotificationRuleSchedule

Name string
Name of the notification policy
Type string
Kind of matching filter. Possible values: match-all, match-any-condition, match-all-conditions
Name string
Name of the notification policy
Type string
Kind of matching filter. Possible values: match-all, match-any-condition, match-all-conditions
name string
Name of the notification policy
type string
Kind of matching filter. Possible values: match-all, match-any-condition, match-all-conditions
name str
Name of the notification policy
type str
Kind of matching filter. Possible values: match-all, match-any-condition, match-all-conditions

NotificationRuleStep

Contacts List<NotificationRuleStepContact>
Defines the contact that notification will be sent to. This is a block, structure is documented below.
Enabled bool
Defined if this step is enabled. Default: true
SendAfter int
Time period, in minutes, notification will be sent after.
Contacts []NotificationRuleStepContact
Defines the contact that notification will be sent to. This is a block, structure is documented below.
Enabled bool
Defined if this step is enabled. Default: true
SendAfter int
Time period, in minutes, notification will be sent after.
contacts NotificationRuleStepContact[]
Defines the contact that notification will be sent to. This is a block, structure is documented below.
enabled boolean
Defined if this step is enabled. Default: true
sendAfter number
Time period, in minutes, notification will be sent after.
contacts Sequence[NotificationRuleStepContact]
Defines the contact that notification will be sent to. This is a block, structure is documented below.
enabled bool
Defined if this step is enabled. Default: true
send_after int
Time period, in minutes, notification will be sent after.

NotificationRuleStepContact

Method string
Contact method. Possible values: email, sms, voice, mobile
To string
Address of a given method (eg. email address for email, phone number for sms/voice or mobile application name for mobile)
Method string
Contact method. Possible values: email, sms, voice, mobile
To string
Address of a given method (eg. email address for email, phone number for sms/voice or mobile application name for mobile)
method string
Contact method. Possible values: email, sms, voice, mobile
to string
Address of a given method (eg. email address for email, phone number for sms/voice or mobile application name for mobile)
method str
Contact method. Possible values: email, sms, voice, mobile
to str
Address of a given method (eg. email address for email, phone number for sms/voice or mobile application name for mobile)

NotificationRuleTimeRestriction

Type string
Kind of matching filter. Possible values: match-all, match-any-condition, match-all-conditions
Restrictions List<NotificationRuleTimeRestrictionRestriction>
Type string
Kind of matching filter. Possible values: match-all, match-any-condition, match-all-conditions
Restrictions []NotificationRuleTimeRestrictionRestriction
type string
Kind of matching filter. Possible values: match-all, match-any-condition, match-all-conditions
restrictions NotificationRuleTimeRestrictionRestriction[]
type str
Kind of matching filter. Possible values: match-all, match-any-condition, match-all-conditions
restrictions Sequence[NotificationRuleTimeRestrictionRestriction]

NotificationRuleTimeRestrictionRestriction

EndDay string
EndHour int
EndMin int
StartDay string
StartHour int
StartMin int
EndDay string
EndHour int
EndMin int
StartDay string
StartHour int
StartMin int
endDay string
endHour number
endMin number
startDay string
startHour number
startMin number

Import

Notification policies can be imported using the user_id/notification_rule_id, e.g.

 $ pulumi import opsgenie:index/notificationRule:NotificationRule test user_id/notification_rule_id`

Package Details

Repository
https://github.com/pulumi/pulumi-opsgenie
License
Apache-2.0
Notes
This Pulumi package is based on the opsgenie Terraform Provider.