Пример #1
0
        /// <summary>
        /// Creates a <see cref="TriggerNode"/> for a notification trigger with a specified OnNotificationAction name.<para/>
        /// If the trigger does not exist, an ambiguous match is found, or the resulting notification trigger is inherited, an <see cref="InvalidOperationException"/> is thrown.
        /// </summary>
        /// <param name="objectOrId">The object to retrieve notification triggers from.</param>
        /// <param name="name">The OnNotificationAction name to retrieve.</param>
        /// <exception cref="InvalidOperationException">The specified notification trigger does not exist or multiple triggers were resolved with the specified name.</exception>
        /// <returns>A <see cref="TriggerNode"/> encapsulating the specified object.</returns>
        public TriggerNode Trigger(Either <IPrtgObject, int> objectOrId, string name)
        {
            var triggers = client.GetNotificationTriggers(objectOrId).Where(t => !t.Inherited);

            var trigger = triggers.Where(t => t.OnNotificationAction.Name == name).ToList().SingleObject(name, "name");

            return(PrtgNode.Trigger(trigger));
        }
Пример #2
0
 /// <summary>
 /// Creates <see cref="TriggerNode"/> objects for all non-inherited notification triggers under a specified object.<para/>
 /// If no non-inherited notification triggers are found, an <see cref="InvalidOperationException"/> is thrown.
 /// </summary>
 /// <param name="objectOrId">The object to retrieve notification triggers from.</param>
 /// <exception cref="InvalidOperationException">No notification triggers were found.</exception>
 /// <returns>A list of <see cref="TriggerNode"/> objects encapsulating the returned triggers.</returns>
 public List <TriggerNode> Triggers(Either <IPrtgObject, int> objectOrId)
 {
     return(GetNodes(
                PrtgAPI.Property.Id,
                objectOrId,
                (p, o) => client.GetNotificationTriggers((Either <IPrtgObject, int>)o).Where(t => !t.Inherited).ToList(),
                (v, c) => PrtgNode.Trigger(v)
                ));
 }