/// <summary> /// Gets a monitoring alarm example by ID. /// </summary> /// <param name="service">The monitoring service instance.</param> /// <param name="alarmExampleId">The alarm example ID. This is obtained from <see cref="AlarmExample.Id">AlarmExample.Id</see>.</param> /// <returns>An <see cref="AlarmExample"/> object describing the alarm example.</returns> /// <exception cref="ArgumentNullException">If <paramref name="service"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentNullException">If <paramref name="alarmExampleId"/> 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-alarm-examples.html#service-alarm-examples-get">Get Alarm Example (Rackspace Cloud Monitoring Developer Guide - API v1.0)</seealso> public static AlarmExample GetAlarmExample(this IMonitoringService service, AlarmExampleId alarmExampleId) { if (service == null) throw new ArgumentNullException("service"); try { return service.GetAlarmExampleAsync(alarmExampleId, CancellationToken.None).Result; } catch (AggregateException ex) { ReadOnlyCollection<Exception> innerExceptions = ex.Flatten().InnerExceptions; if (innerExceptions.Count == 1) throw innerExceptions[0]; throw; } }
/// <summary> /// Evaluate the template of a single alarm example. /// </summary> /// <param name="service">The monitoring service instance.</param> /// <param name="alarmExampleId">The alarm example ID. This is obtained from <see cref="AlarmExample.Id">AlarmExample.Id</see>.</param> /// <param name="exampleParameters">A dictionary containing the values to insert in the alarm example. The dictionary should contain a key/value pair for each field described in <see cref="AlarmExample.Fields"/> for the alarm example.</param> /// <returns>A <see cref="BoundAlarmExample"/> object containing the evaluated alarm example.</returns> /// <exception cref="ArgumentNullException">If <paramref name="service"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentNullException"> /// If <paramref name="alarmExampleId"/> is <see langword="null"/>. /// <para>-or-</para> /// <para>If <paramref name="exampleParameters"/> is <see langword="null"/>.</para> /// </exception> /// <exception cref="ArgumentException">If <paramref name="exampleParameters"/> contains any empty keys.</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-alarm-examples.html#service-alarm-examples-post">Evaluate Alarm Example (Rackspace Cloud Monitoring Developer Guide - API v1.0)</seealso> public static BoundAlarmExample EvaluateAlarmExample(this IMonitoringService service, AlarmExampleId alarmExampleId, IDictionary<string, object> exampleParameters) { if (service == null) throw new ArgumentNullException("service"); try { return service.EvaluateAlarmExampleAsync(alarmExampleId, exampleParameters, 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 alarm examples. /// </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-alarm-examples.html#service-alarm-examples-list">List Alarm Examples (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<AlarmExample, AlarmExampleId> ListAlarmExamples(this IMonitoringService service, AlarmExampleId marker, int? limit) { if (service == null) throw new ArgumentNullException("service"); try { return service.ListAlarmExamplesAsync(marker, limit, CancellationToken.None).Result; } catch (AggregateException ex) { ReadOnlyCollection<Exception> innerExceptions = ex.Flatten().InnerExceptions; if (innerExceptions.Count == 1) throw innerExceptions[0]; throw; } }