/// <summary>
 /// Initializes a new instance of the <see cref="NewNotificationConfiguration"/> class
 /// with the specified properties.
 /// </summary>
 /// <param name="label">The friendly name of the notification.</param>
 /// <param name="notificationTypeId">The notification type ID. This is obtained from <see cref="NotificationType.Id">NotificationType.Id</see>, or from the predefined values in <see cref="NotificationTypeId"/>.</param>
 /// <param name="details">A <see cref="NotificationDetails"/> object containing the detailed configuration properties for the specified notification type.</param>
 /// <param name="metadata">A collection of metadata to associate with the notification. If the value is <see langword="null"/>, no custom metadata is associated with the notification.</param>
 /// <exception cref="ArgumentNullException">
 /// If <paramref name="label"/> is <see langword="null"/>.
 /// <para>-or-</para>
 /// <para>If <paramref name="details"/> is <see langword="null"/>.</para>
 /// </exception>
 /// <exception cref="ArgumentException">
 /// If <paramref name="label"/> is empty.
 /// <para>-or-</para>
 /// <para>If <paramref name="details"/> is non-<see langword="null"/> and <paramref name="notificationTypeId"/> is <see langword="null"/>.</para>
 /// <para>-or-</para>
 /// <para>If <paramref name="details"/> does not support notifications of type <paramref name="notificationTypeId"/>.</para>
 /// <para>-or-</para>
 /// <para>If <paramref name="metadata"/> contains any empty keys.</para>
 /// </exception>
 public NewNotificationConfiguration(string label, NotificationTypeId notificationTypeId, NotificationDetails details, IDictionary<string, string> metadata = null)
     : base(label, notificationTypeId, details, metadata)
 {
     if (label == null)
         throw new ArgumentNullException("label");
     if (details == null)
         throw new ArgumentNullException("details");
 }
        public override int GetHashCode()
        {
            int hash = 1;

            if (Title.Length != 0)
            {
                hash ^= Title.GetHashCode();
            }
            if (Content.Length != 0)
            {
                hash ^= Content.GetHashCode();
            }
            if (Status != 0)
            {
                hash ^= Status.GetHashCode();
            }
            if (Level != 0)
            {
                hash ^= Level.GetHashCode();
            }
            if (Creator.Length != 0)
            {
                hash ^= Creator.GetHashCode();
            }
            if (ExtJson.Length != 0)
            {
                hash ^= ExtJson.GetHashCode();
            }
            if (IsStock != false)
            {
                hash ^= IsStock.GetHashCode();
            }
            if (IsNotify != false)
            {
                hash ^= IsNotify.GetHashCode();
            }
            if (Type.Length != 0)
            {
                hash ^= Type.GetHashCode();
            }
            if (NotificationTypeId != 0)
            {
                hash ^= NotificationTypeId.GetHashCode();
            }
            if (IsInnerBroadcast != false)
            {
                hash ^= IsInnerBroadcast.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        /// <summary>
        /// Deserializes a JSON object to a <see cref="NotificationDetails"/> instance of the proper type.
        /// </summary>
        /// <param name="notificationTypeId">The notification type ID.</param>
        /// <param name="obj">The JSON object representing the notification details.</param>
        /// <returns>A <see cref="NotificationDetails"/> object corresponding to the JSON object.</returns>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="notificationTypeId"/> is <see langword="null"/>.
        /// <para>-or-</para>
        /// <para>If <paramref name="obj"/> is <see langword="null"/>.</para>
        /// </exception>
        public static NotificationDetails FromJObject(NotificationTypeId notificationTypeId, JObject obj)
        {
            if (notificationTypeId == null)
                throw new ArgumentNullException("notificationTypeId");
            if (obj == null)
                throw new ArgumentNullException("obj");

            if (notificationTypeId == NotificationTypeId.Webhook)
                return obj.ToObject<WebhookNotificationDetails>();
            else if (notificationTypeId == NotificationTypeId.Email)
                return obj.ToObject<EmailNotificationDetails>();
            else if (notificationTypeId == NotificationTypeId.PagerDuty)
                return obj.ToObject<PagerDutyNotificationDetails>();
            else
                return obj.ToObject<GenericNotificationDetails>();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NotificationConfiguration"/> class
        /// with the specified properties.
        /// </summary>
        /// <param name="label">The friendly name of the notification. If this value is <see langword="null"/>, the underlying property will be omitted from the JSON representation of the object.</param>
        /// <param name="notificationTypeId">The notification type ID. This is obtained from <see cref="NotificationType.Id">NotificationType.Id</see>, or from the predefined values in <see cref="NotificationTypeId"/>. If this value is <see langword="null"/>, the underlying property will be omitted from the JSON representation of the object.</param>
        /// <param name="details">A <see cref="NotificationDetails"/> object containing the detailed configuration properties for the specified notification type. If this value is <see langword="null"/>, the underlying property will be omitted from the JSON representation of the object.</param>
        /// <param name="metadata">A collection of metadata to associate with the notification. If the value is <see langword="null"/>, no custom metadata is associated with the notification. If this value is <see langword="null"/>, the underlying property will be omitted from the JSON representation of the object.</param>
        /// <exception cref="ArgumentException">
        /// If <paramref name="label"/> is empty.
        /// <para>-or-</para>
        /// <para>If <paramref name="details"/> is non-<see langword="null"/> and <paramref name="notificationTypeId"/> is <see langword="null"/>.</para>
        /// <para>-or-</para>
        /// <para>If <paramref name="details"/> does not support notifications of type <paramref name="notificationTypeId"/>.</para>
        /// <para>-or-</para>
        /// <para>If <paramref name="metadata"/> contains any empty keys.</para>
        /// </exception>
        protected NotificationConfiguration(string label, NotificationTypeId notificationTypeId, NotificationDetails details, IDictionary<string, string> metadata)
        {
            if (label == string.Empty)
                throw new ArgumentException("label cannot be empty");
            if (details != null && notificationTypeId == null)
                throw new ArgumentException("notificationTypeId must be specified if details is specified", "notificationTypeId");
            if (details != null && !details.SupportsNotificationType(notificationTypeId))
                throw new ArgumentException(string.Format("The notification details object does not support '{0}' notifications.", notificationTypeId), "details");
            if (metadata != null && metadata.ContainsKey(string.Empty))
                throw new ArgumentException("metadata cannot contain any empty keys", "metadata");

            _label = label;
            _type = notificationTypeId;
            _details = details != null ? JObject.FromObject(details) : null;
            _metadata = metadata;
        }
 /// <inheritdoc/>
 /// <remarks>
 /// This class only supports <see cref="NotificationTypeId.Email"/> notifications.
 /// </remarks>
 protected internal override bool SupportsNotificationType(NotificationTypeId notificationTypeId)
 {
     return notificationTypeId == NotificationTypeId.Email;
 }
        /// <summary>
        /// Gets a monitoring notification type by ID.
        /// </summary>
        /// <param name="service">The monitoring service instance.</param>
        /// <param name="notificationTypeId">The notification type ID. This is obtained from <see cref="NotificationType.Id">NotificationType.Id</see>, or from the predefined values in <see cref="NotificationTypeId"/>.</param>
        /// <returns>A <see cref="NotificationType"/> object describing the notification type.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="service"/> is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentNullException">If <paramref name="notificationTypeId"/> is <see langword="null"/>.</exception>
        /// <exception cref="WebException">If the REST request does not return successfully.</exception>
        /// <seealso href="http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/service-notification-types-crud.html#Service-Notification-Types-get">Get Notification Type (Rackspace Cloud Monitoring Developer Guide - API v1.0)</seealso>
        public static NotificationType GetNotificationType(this IMonitoringService service, NotificationTypeId notificationTypeId)
        {
            if (service == null)
                throw new ArgumentNullException("service");

            try
            {
                return service.GetNotificationTypeAsync(notificationTypeId, CancellationToken.None).Result;
            }
            catch (AggregateException ex)
            {
                ReadOnlyCollection<Exception> innerExceptions = ex.Flatten().InnerExceptions;
                if (innerExceptions.Count == 1)
                    throw innerExceptions[0];

                throw;
            }
        }
        /// <summary>
        /// Gets a collection of monitoring notification types.
        /// </summary>
        /// <param name="service">The monitoring service instance.</param>
        /// <param name="marker">A marker identifying the next page of results. This parameter is used for <see href="http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/api-paginated-collections.html">pagination</see>, and is obtained from <see cref="ReadOnlyCollectionPage{T, TMarker}.NextMarker"/>. If the value is <see langword="null"/>, the list starts at the beginning.</param>
        /// <param name="limit">The maximum number of items to include in a single page of results. This parameter is used for <see href="http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/api-paginated-collections.html">pagination</see>. If the value is <see langword="null"/>, a provider-specific default value is used.</param>
        /// <returns>
        /// A <see cref="ReadOnlyCollectionPage{T, TMarker}"/> object containing the page
        /// of results and its associated pagination metadata.
        /// </returns>
        /// <exception cref="ArgumentNullException">If <paramref name="service"/> is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentOutOfRangeException">If <paramref name="limit"/> is less than or equal to 0.</exception>
        /// <exception cref="WebException">If the REST request does not return successfully.</exception>
        /// <seealso href="http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/service-notification-types-crud.html#Service-Notification-Types-List">List Notification Types (Rackspace Cloud Monitoring Developer Guide - API v1.0)</seealso>
        /// <seealso href="http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/api-paginated-collections.html">Paginated Collections (Rackspace Cloud Monitoring Developer Guide - API v1.0)</seealso>
        public static ReadOnlyCollectionPage<NotificationType, NotificationTypeId> ListNotificationTypes(this IMonitoringService service, NotificationTypeId marker, int? limit)
        {
            if (service == null)
                throw new ArgumentNullException("service");

            try
            {
                return service.ListNotificationTypesAsync(marker, limit, CancellationToken.None).Result;
            }
            catch (AggregateException ex)
            {
                ReadOnlyCollection<Exception> innerExceptions = ex.Flatten().InnerExceptions;
                if (innerExceptions.Count == 1)
                    throw innerExceptions[0];

                throw;
            }
        }
 /// <summary>
 /// Determines whether the current <see cref="NotificationDetails"/> object is compatible
 /// with notifications of a particular type.
 /// </summary>
 /// <param name="notificationTypeId">The notification type ID.</param>
 /// <returns><see langword="true"/> if the current <see cref="NotificationDetails"/> object is compatible with <paramref name="notificationTypeId"/>; otherwise, <see langword="false"/>.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="notificationTypeId"/> is <see langword="null"/>.</exception>
 protected internal abstract bool SupportsNotificationType(NotificationTypeId notificationTypeId);
		public bool IsOff(NotificationTypeId typeId) => default;
		public StaticNotificationData Off(NotificationTypeId typeId) => default;
 /// <inheritdoc/>
 /// <remarks>
 /// This class can be used for any notification type. Clients using this class are responsible
 /// for adding the necessary properties for their specific notification type.
 /// </remarks>
 protected internal override bool SupportsNotificationType(NotificationTypeId notificationTypeId)
 {
     return true;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateNotificationConfiguration"/> class
 /// with the specified properties.
 /// </summary>
 /// <param name="label">The friendly name of the notification. If this value is <see langword="null"/>, the existing value for the notification is not changed.</param>
 /// <param name="notificationTypeId">The notification type ID. This is obtained from <see cref="NotificationType.Id">NotificationType.Id</see>, or from the predefined values in <see cref="NotificationTypeId"/>. If this value is <see langword="null"/>, the existing value for the notification is not changed.</param>
 /// <param name="details">A <see cref="NotificationDetails"/> object containing the detailed configuration properties for the specified notification type. If this value is <see langword="null"/>, the existing value for the notification is not changed.</param>
 /// <param name="metadata">A collection of metadata to associate with the notification. If this value is <see langword="null"/>, the existing value for the notification is not changed.</param>
 /// <exception cref="ArgumentException">
 /// If <paramref name="label"/> is empty.
 /// <para>-or-</para>
 /// <para>If <paramref name="details"/> is non-<see langword="null"/> and <paramref name="notificationTypeId"/> is <see langword="null"/>.</para>
 /// <para>-or-</para>
 /// <para>If <paramref name="details"/> does not support notifications of type <paramref name="notificationTypeId"/>.</para>
 /// <para>-or-</para>
 /// <para>If <paramref name="metadata"/> contains any empty keys.</para>
 /// </exception>
 public UpdateNotificationConfiguration(string label = null, NotificationTypeId notificationTypeId = null, NotificationDetails details = null, IDictionary<string, string> metadata = null)
     : base(label, notificationTypeId, details, metadata)
 {
 }
Esempio n. 13
0
 public NotificationSettingsGroupData Add(NotificationTypeId notificationType) => default;
Esempio n. 14
0
 // Extension methods
 public static bool IsLocal(this NotificationTypeId typeId) => default;