/// <summary>
        /// Clone a PagerDuty Notification endpoint.
        /// </summary>
        /// <param name="name">name of cloned endpoint</param>
        /// <param name="routingKey">Routing Key</param>
        /// <param name="endpoint">endpoint to clone</param>
        /// <returns>Notification endpoint cloned</returns>
        public async Task <PagerDutyNotificationEndpoint> ClonePagerDutyEndpointAsync(string name, string routingKey,
                                                                                      PagerDutyNotificationEndpoint endpoint)
        {
            Arguments.CheckNonEmptyString(name, nameof(name));
            Arguments.CheckNonEmptyString(routingKey, nameof(routingKey));
            Arguments.CheckNotNull(endpoint, nameof(endpoint));

            var cloned = new PagerDutyNotificationEndpoint(endpoint.ClientURL, routingKey, name: name);

            return((PagerDutyNotificationEndpoint) await CloneEndpointAsync(name, endpoint, cloned));
        }
        /// <summary>
        /// Add new PagerDuty notification endpoint.
        /// </summary>
        /// <param name="name">Endpoint name</param>
        /// <param name="clientUrl">Client URL</param>
        /// <param name="routingKey">Routing Key</param>
        /// <param name="orgId">Owner of an endpoint</param>
        /// <returns>created PagerDuty notification endpoint</returns>
        public async Task <PagerDutyNotificationEndpoint> CreatePagerDutyEndpointAsync(string name, string clientUrl,
                                                                                       string routingKey, string orgId)
        {
            Arguments.CheckNonEmptyString(name, nameof(name));
            Arguments.CheckNonEmptyString(clientUrl, nameof(clientUrl));
            Arguments.CheckNonEmptyString(routingKey, nameof(clientUrl));
            Arguments.CheckNonEmptyString(orgId, nameof(orgId));

            var endpoint = new PagerDutyNotificationEndpoint(type: NotificationEndpointType.Pagerduty,
                                                             clientURL: clientUrl, routingKey: routingKey, orgID: orgId, name: name,
                                                             status: NotificationEndpointBase.StatusEnum.Active);

            return((PagerDutyNotificationEndpoint) await CreateEndpointAsync(endpoint));
        }
Example #3
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));
        }