コード例 #1
0
        private async Task <NotificationRule> CreateRuleAsync(string name, string every, RuleStatusLevel status,
                                                              List <TagRule> tagRules, NotificationEndpoint notificationEndpoint, string orgId, NotificationRule rule)
        {
            Arguments.CheckNotNull(rule, "rule");

            rule.Name        = name;
            rule.Every       = every;
            rule.OrgID       = orgId;
            rule.TagRules    = tagRules;
            rule.StatusRules = new List <StatusRule> {
                new StatusRule(status)
            };
            rule.EndpointID = notificationEndpoint.Id;
            rule.Status     = TaskStatusType.Active;

            return(await CreateRuleAsync(rule));
        }
コード例 #2
0
        /**
         * Add a PagerDuty notification rule.
         *
         * @param name            Human-readable name describing the notification rule.
         * @param every           The notification repetition interval.
         * @param messageTemplate The template used to generate notification.
         * @param status          Status rule the notification rule attempts to match.
         * @param tagRules        List of tag rules the notification rule attempts to match.
         * @param endpoint        The endpoint to use for notification.
         * @param orgID           The ID of the organization that owns this notification rule.
         * @return Notification rule created
         */

        /// <summary>
        /// Add a PagerDuty notification rule.
        /// </summary>
        /// <param name="name">Human-readable name describing the notification rule.</param>
        /// <param name="every">The notification repetition interval.</param>
        /// <param name="messageTemplate">The template used to generate notification.</param>
        /// <param name="status">Status rule the notification rule attempts to match.</param>
        /// <param name="tagRules">List of tag rules the notification rule attempts to match.</param>
        /// <param name="endpoint">The endpoint to use for notification.</param>
        /// <param name="orgId">The ID of the organization that owns this notification rule</param>
        /// <returns>Notification rule created</returns>
        public async Task <PagerDutyNotificationRule> CreatePagerDutyRuleAsync(string name, string every,
                                                                               string messageTemplate, RuleStatusLevel status, List <TagRule> tagRules,
                                                                               PagerDutyNotificationEndpoint endpoint, string orgId)
        {
            Arguments.CheckNonEmptyString(name, nameof(name));
            Arguments.CheckNonEmptyString(every, nameof(every));
            Arguments.CheckNonEmptyString(messageTemplate, nameof(messageTemplate));
            Arguments.CheckNotNull(status, nameof(status));
            Arguments.CheckNotNull(endpoint, nameof(endpoint));
            Arguments.CheckNotNull(tagRules, nameof(tagRules));
            Arguments.CheckNonEmptyString(orgId, nameof(orgId));

            var rule = new PagerDutyNotificationRule(PagerDutyNotificationRuleBase.TypeEnum.Pagerduty,
                                                     messageTemplate);

            return((PagerDutyNotificationRule) await CreateRuleAsync(name, every, status, tagRules, endpoint, orgId,
                                                                     rule).ConfigureAwait(false));
        }
コード例 #3
0
        /// <summary>
        /// Add a HTTP notification rule.
        /// </summary>
        /// <param name="name">Human-readable name describing the notification rule.</param>
        /// <param name="every">The notification repetition interval.</param>
        /// <param name="status">Status rule the notification rule attempts to match.</param>
        /// <param name="tagRules">List of tag rules the notification rule attempts to match.</param>
        /// <param name="endpoint">The endpoint to use for notification.</param>
        /// <param name="orgId">The ID of the organization that owns this notification rule.</param>
        /// <returns>Notification rule created</returns>
        public async Task <HTTPNotificationRule> CreateHttpRuleAsync(string name, string every, RuleStatusLevel status,
                                                                     List <TagRule> tagRules,
                                                                     HTTPNotificationEndpoint endpoint, string orgId)
        {
            var rule = new HTTPNotificationRule(HTTPNotificationRuleBase.TypeEnum.Http);

            return((HTTPNotificationRule) await CreateRuleAsync(name, every, status, tagRules, endpoint, orgId,
                                                                rule));
        }