Skip to content

Commit

Permalink
[MetricsAdvisor] Fixed UpdateAlertConfiguration methods (#21514)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinelski authored Jun 4, 2021
1 parent 4200cee commit 7f9ea76
Show file tree
Hide file tree
Showing 42 changed files with 1,792 additions and 1,839 deletions.
1 change: 1 addition & 0 deletions sdk/metricsadvisor/Azure.AI.MetricsAdvisor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Added setters to models that use the Update APIs to make updating easier.

### Breaking Changes
- Update methods will now return the updated entity instead of an empty response. For example, `UpdateDataFeed` now returns a `Response<DataFeed>`.
- `NotificationHook.ExternalLink` and `WebNotificationHook.Endpoint` are now of type `Uri`.
- Removed setter from `GetIncidentsForDetectionConfigurationOptions.DimensionsToFilter`. Elements can be added directly to it without user instantiation.
- Renamed all `SkipCount` listing options to `Skip`. Affected classes include `GetAlertsOptions`, `GetDataFeedsOptions`, `GetHooksOptions`, and others.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ public MetricsAdvisorAdministrationClient(System.Uri endpoint, Azure.Core.TokenC
public virtual Azure.AsyncPageable<Azure.AI.MetricsAdvisor.Models.NotificationHook> GetHooksAsync(Azure.AI.MetricsAdvisor.Administration.GetHooksOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response RefreshDataFeedIngestion(string dataFeedId, System.DateTimeOffset startTime, System.DateTimeOffset endTime, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> RefreshDataFeedIngestionAsync(string dataFeedId, System.DateTimeOffset startTime, System.DateTimeOffset endTime, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response UpdateAlertConfiguration(string alertConfigurationId, Azure.AI.MetricsAdvisor.Models.AnomalyAlertConfiguration alertConfiguration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> UpdateAlertConfigurationAsync(string alertConfigurationId, Azure.AI.MetricsAdvisor.Models.AnomalyAlertConfiguration alertConfiguration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.AI.MetricsAdvisor.Models.AnomalyAlertConfiguration> UpdateAlertConfiguration(string alertConfigurationId, Azure.AI.MetricsAdvisor.Models.AnomalyAlertConfiguration alertConfiguration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.MetricsAdvisor.Models.AnomalyAlertConfiguration>> UpdateAlertConfigurationAsync(string alertConfigurationId, Azure.AI.MetricsAdvisor.Models.AnomalyAlertConfiguration alertConfiguration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response UpdateDataFeed(string dataFeedId, Azure.AI.MetricsAdvisor.Models.DataFeed dataFeed, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> UpdateDataFeedAsync(string dataFeedId, Azure.AI.MetricsAdvisor.Models.DataFeed dataFeed, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.AI.MetricsAdvisor.Models.DatasourceCredential> UpdateDatasourceCredential(Azure.AI.MetricsAdvisor.Models.DatasourceCredential datasourceCredential, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
Expand Down Expand Up @@ -915,9 +915,9 @@ public partial class MetricAnomalyAlertConfiguration
{
public MetricAnomalyAlertConfiguration(string detectionConfigurationId, Azure.AI.MetricsAdvisor.Models.MetricAnomalyAlertScope alertScope) { }
public Azure.AI.MetricsAdvisor.Models.MetricAnomalyAlertConditions AlertConditions { get { throw null; } set { } }
public Azure.AI.MetricsAdvisor.Models.MetricAnomalyAlertScope AlertScope { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.MetricAnomalyAlertScope AlertScope { get { throw null; } set { } }
public Azure.AI.MetricsAdvisor.Models.MetricAnomalyAlertSnoozeCondition AlertSnoozeCondition { get { throw null; } set { } }
public string DetectionConfigurationId { get { throw null; } }
public string DetectionConfigurationId { get { throw null; } set { } }
public bool? UseDetectionResultToFilterAnomalies { get { throw null; } set { } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
Expand Down Expand Up @@ -1161,9 +1161,9 @@ public SuppressCondition(int minimumNumber, double minimumRatio) { }
public partial class TopNGroupScope
{
public TopNGroupScope(int top, int period, int minimumTopCount) { }
public int MinimumTopCount { get { throw null; } }
public int Period { get { throw null; } }
public int Top { get { throw null; } }
public int MinimumTopCount { get { throw null; } set { } }
public int Period { get { throw null; } set { } }
public int Top { get { throw null; } set { } }
}
public partial class WebNotificationHook : Azure.AI.MetricsAdvisor.Models.NotificationHook
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1201,13 +1201,13 @@ public virtual Response<AnomalyAlertConfiguration> CreateAlertConfiguration(Anom
/// <param name="alertConfiguration">The <see cref="AnomalyAlertConfiguration"/> containing the updates.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>
/// A <see cref="Response"/> containing the result of the operation.
/// A <see cref="Response{T}"/> containing the result of the operation. The result is an <see cref="AnomalyAlertConfiguration"/>
/// instance containing information about the updated configuration.
/// </returns>
/// <exception cref="ArgumentNullException"><paramref name="alertConfigurationId"/> or <paramref name="alertConfiguration"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="alertConfigurationId"/> is empty or not a valid GUID.</exception>
public virtual async Task<Response> UpdateAlertConfigurationAsync(string alertConfigurationId, AnomalyAlertConfiguration alertConfiguration, CancellationToken cancellationToken = default)
public virtual async Task<Response<AnomalyAlertConfiguration>> UpdateAlertConfigurationAsync(string alertConfigurationId, AnomalyAlertConfiguration alertConfiguration, CancellationToken cancellationToken = default)
{
/*
Guid alertConfigurationGuid = ClientCommon.ValidateGuid(alertConfigurationId, nameof(alertConfigurationId));
Argument.AssertNotNull(alertConfiguration, nameof(alertConfiguration));
if (!string.IsNullOrEmpty(alertConfiguration.Id) && !alertConfigurationId.Equals(alertConfiguration.Id, StringComparison.OrdinalIgnoreCase))
Expand All @@ -1228,10 +1228,6 @@ public virtual async Task<Response> UpdateAlertConfigurationAsync(string alertCo
scope.Failed(e);
throw;
}
*/

await Task.CompletedTask.ConfigureAwait(false);
return default;
}

/// <summary>
Expand All @@ -1241,13 +1237,13 @@ public virtual async Task<Response> UpdateAlertConfigurationAsync(string alertCo
/// <param name="alertConfiguration">The <see cref="AnomalyAlertConfiguration"/> containing the updates.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>
/// A <see cref="Response"/> containing the result of the operation.
/// A <see cref="Response{T}"/> containing the result of the operation. The result is an <see cref="AnomalyAlertConfiguration"/>
/// instance containing information about the updated configuration.
/// </returns>
/// <exception cref="ArgumentNullException"><paramref name="alertConfigurationId"/> or <paramref name="alertConfiguration"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="alertConfigurationId"/> is empty or not a valid GUID.</exception>
public virtual Response UpdateAlertConfiguration(string alertConfigurationId, AnomalyAlertConfiguration alertConfiguration, CancellationToken cancellationToken = default)
public virtual Response<AnomalyAlertConfiguration> UpdateAlertConfiguration(string alertConfigurationId, AnomalyAlertConfiguration alertConfiguration, CancellationToken cancellationToken = default)
{
/*
Guid alertConfigurationGuid = ClientCommon.ValidateGuid(alertConfigurationId, nameof(alertConfigurationId));
Argument.AssertNotNull(alertConfiguration, nameof(alertConfiguration));
if (!string.IsNullOrEmpty(alertConfiguration.Id) && !alertConfigurationId.Equals(alertConfiguration.Id, StringComparison.OrdinalIgnoreCase))
Expand All @@ -1268,9 +1264,6 @@ public virtual Response UpdateAlertConfiguration(string alertConfigurationId, An
scope.Failed(e);
throw;
}
*/

return default;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ internal MetricAnomalyAlertConfiguration(string detectionConfigurationId, Metric
/// The identifier of the anomaly detection configuration to which this configuration applies.
/// </summary>
[CodeGenMember("AnomalyDetectionConfigurationId")]
public string DetectionConfigurationId { get; }
public string DetectionConfigurationId { get; set; }

/// <summary>
/// Selects which set of time series should trigger alerts.
/// </summary>
public MetricAnomalyAlertScope AlertScope { get; }
public MetricAnomalyAlertScope AlertScope { get; set; }

/// <summary>
/// If defined, this <see cref="MetricAnomalyAlertConfiguration"/> won't trigger alerts by itself. It
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ public TopNGroupScope(int top, int period, int minimumTopCount)
/// <summary>
/// The number of timestamps to take into account.
/// </summary>
public int Top { get; }
public int Top { get; set; }

/// <summary>
/// The number of items a period contains.
/// </summary>
public int Period { get; }
public int Period { get; set; }

/// <summary>
/// The number of anomalies that must be in the specified <see cref="Top"/> number of timestamps to send an alert.
/// </summary>
[CodeGenMember("MinTopCount")]
public int MinimumTopCount { get; }
public int MinimumTopCount { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,15 @@ public async Task CreateAndGetAlertConfigurationWithMultipleMetricConfigurations
[RecordedTest]
[TestCase(true)]
[TestCase(false)]
[Ignore("https://github.com/Azure/azure-sdk-for-net/issues/21177")]
public async Task UpdateAlertConfigurationWithMinimumSetupAndGetInstance(bool useTokenCrendential)
{
MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient(useTokenCrendential);

// Configure the Metric Anomaly Alert Configurations to be used.

string hookName = Recording.GenerateAlphaNumericId("hook");
var hookToCreate = new WebNotificationHook() { Name = hookName, Endpoint = new Uri("http://contoso.com/") };
var hookToCreate = new EmailNotificationHook() { Name = hookName, EmailsToAlert = { "fake@email.com" } };

await using var disposableHook = await DisposableNotificationHook.CreateHookAsync(adminClient, hookToCreate);

var scope = MetricAnomalyAlertScope.GetScopeForWholeSeries();
Expand Down Expand Up @@ -387,7 +387,6 @@ public async Task UpdateAlertConfigurationWithMinimumSetupAndGetInstance(bool us

string configName = Recording.GenerateAlphaNumericId("config");
var hookIds = new List<string>() { disposableHook.Id };
var metricAlertConfigs = new List<MetricAnomalyAlertConfiguration>() { metricAlertConfig0, metricAlertConfig1 };

var configToCreate = new AnomalyAlertConfiguration()
{
Expand Down Expand Up @@ -582,15 +581,15 @@ public async Task UpdateAlertConfigurationWithMinimumSetupAndNewInstance()
}

[RecordedTest]
[Ignore("https://github.com/Azure/azure-sdk-for-net/issues/21177")]
public async Task UpdateAlertConfigurationWithEveryMemberAndGetInstance()
{
MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient();

// Configure the Metric Anomaly Alert Configurations to be used.

string hookName = Recording.GenerateAlphaNumericId("hook");
var hookToCreate = new WebNotificationHook() { Name = hookName, Endpoint = new Uri("http://contoso.com/") };
var hookToCreate = new EmailNotificationHook() { Name = hookName, EmailsToAlert = { "fake@email.com" } };

await using var disposableHook = await DisposableNotificationHook.CreateHookAsync(adminClient, hookToCreate);

var scope = MetricAnomalyAlertScope.GetScopeForWholeSeries();
Expand Down
Loading

0 comments on commit 7f9ea76

Please sign in to comment.