From eb7c0ed1d6e8a6a46f76df726b523cf7bbe8b734 Mon Sep 17 00:00:00 2001 From: kinelski Date: Thu, 29 Oct 2020 15:35:58 -0700 Subject: [PATCH] [MetricsAdvisor] Remove unnecessary ClientOptions type (#16436) --- .../Azure.AI.MetricsAdvisor/CHANGELOG.md | 6 ++- .../Azure.AI.MetricsAdvisor.netstandard2.0.cs | 19 ++----- .../src/Azure.AI.MetricsAdvisor.csproj | 4 ++ .../src/MetricsAdvisorAdministrationClient.cs | 8 +-- ...tricsAdvisorAdministrationClientOptions.cs | 50 ------------------- .../src/MetricsAdvisorClient.cs | 8 +-- ...ons.cs => MetricsAdvisorClientsOptions.cs} | 6 +-- .../tests/MetricsAdvisorLiveTestBase.cs | 6 +-- 8 files changed, 28 insertions(+), 79 deletions(-) delete mode 100644 sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorAdministrationClientOptions.cs rename sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/{MetricsAdvisorClientOptions.cs => MetricsAdvisorClientsOptions.cs} (89%) diff --git a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/CHANGELOG.md b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/CHANGELOG.md index c8eb46c451232..49fc651d231ca 100644 --- a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/CHANGELOG.md +++ b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/CHANGELOG.md @@ -8,17 +8,21 @@ - Added a public setter to `DataFeed.Options`. ### Breaking Changes -- In `MetricsAdvisorClient`, updated `CreateDataFeed` and `CreateDataFeedAsync` to take a whole `DataFeed` object as a parameter. - In `MetricsAdvisorClient`, changed return types of sync and async methods `GetIncidentRootCauses`, `GetMetricEnrichedSeriesData`, and `GetMetricSeriesData` to pageables. +- In `MetricsAdvisorAdministrationClient`, updated `CreateDataFeed` and `CreateDataFeedAsync` to take a whole `DataFeed` object as a parameter. - In `MetricsAdvisorAdministrationClient`, changed return types of sync and async methods `GetAnomalyAlertConfigurations` and `GetMetricAnomalyDetectionConfigurations` to pageables. - In `MetricsAdvisorAdministrationClient`, renamed parameter `alertConfigurationId` to `detectionConfigurationId` in sync and async `GetAnomalyAlertConfigurations` methods. - In `MetricEnrichedSeriesData`, made elements of `ExpectedValues`, `Periods`, `IsAnomaly`, `LowerBoundaries` and `UpperBoundaries` nullables. +- Removed `MetricsAdvisorClientOptions` and `MetricsAdvisorAdministrationOptions` and replaced both with `MetricsAdvisorClientsOptions`. - Renamed `MetricDimension` to `DataFeedDimension`. - Renamed `DataAnomaly` to `DataPointAnomaly`. - Renamed `IncidentStatus` to `AnomalyIncidentStatus`. - Renamed `AlertingHook`, `EmailHook`, and `WebHook` to `NotificationHook`, `EmailNotificationHook`, and `WebNotificationHook`, respectively. - Renamed `TimeMode` to `AlertQueryTimeMode`. +### Key Bug Fixes +- Fixed a bug in `GetMetricEnrichedSeriesData` sync and async methods where a `NullReferenceException` was thrown if a returned data point had missing data. + ## 1.0.0-beta.1 (2020-10-08) This is the first beta of the `Azure.AI.MetricsAdvisor` client library. diff --git a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/api/Azure.AI.MetricsAdvisor.netstandard2.0.cs b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/api/Azure.AI.MetricsAdvisor.netstandard2.0.cs index 99fa872d81ecc..5cbd3e0f37f42 100644 --- a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/api/Azure.AI.MetricsAdvisor.netstandard2.0.cs +++ b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/api/Azure.AI.MetricsAdvisor.netstandard2.0.cs @@ -4,7 +4,7 @@ public partial class MetricsAdvisorClient { protected MetricsAdvisorClient() { } public MetricsAdvisorClient(System.Uri endpoint, Azure.AI.MetricsAdvisor.MetricsAdvisorKeyCredential credential) { } - public MetricsAdvisorClient(System.Uri endpoint, Azure.AI.MetricsAdvisor.MetricsAdvisorKeyCredential credential, Azure.AI.MetricsAdvisor.MetricsAdvisorClientOptions options) { } + public MetricsAdvisorClient(System.Uri endpoint, Azure.AI.MetricsAdvisor.MetricsAdvisorKeyCredential credential, Azure.AI.MetricsAdvisor.MetricsAdvisorClientsOptions options) { } public virtual Azure.Response CreateMetricFeedback(Azure.AI.MetricsAdvisor.Models.MetricFeedback feedback, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CreateMetricFeedbackAsync(Azure.AI.MetricsAdvisor.Models.MetricFeedback feedback, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetAlerts(string alertConfigurationId, Azure.AI.MetricsAdvisor.Models.GetAlertsOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -36,10 +36,10 @@ public MetricsAdvisorClient(System.Uri endpoint, Azure.AI.MetricsAdvisor.Metrics public virtual Azure.Pageable GetValuesOfDimensionWithAnomalies(string detectionConfigurationId, string dimensionName, Azure.AI.MetricsAdvisor.Models.GetValuesOfDimensionWithAnomaliesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetValuesOfDimensionWithAnomaliesAsync(string detectionConfigurationId, string dimensionName, Azure.AI.MetricsAdvisor.Models.GetValuesOfDimensionWithAnomaliesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } - public partial class MetricsAdvisorClientOptions : Azure.Core.ClientOptions + public partial class MetricsAdvisorClientsOptions : Azure.Core.ClientOptions { - public MetricsAdvisorClientOptions(Azure.AI.MetricsAdvisor.MetricsAdvisorClientOptions.ServiceVersion version = Azure.AI.MetricsAdvisor.MetricsAdvisorClientOptions.ServiceVersion.V1_0) { } - public Azure.AI.MetricsAdvisor.MetricsAdvisorClientOptions.ServiceVersion Version { get { throw null; } } + public MetricsAdvisorClientsOptions(Azure.AI.MetricsAdvisor.MetricsAdvisorClientsOptions.ServiceVersion version = Azure.AI.MetricsAdvisor.MetricsAdvisorClientsOptions.ServiceVersion.V1_0) { } + public Azure.AI.MetricsAdvisor.MetricsAdvisorClientsOptions.ServiceVersion Version { get { throw null; } } public enum ServiceVersion { V1_0 = 1, @@ -58,7 +58,7 @@ public partial class MetricsAdvisorAdministrationClient { protected MetricsAdvisorAdministrationClient() { } public MetricsAdvisorAdministrationClient(System.Uri endpoint, Azure.AI.MetricsAdvisor.MetricsAdvisorKeyCredential credential) { } - public MetricsAdvisorAdministrationClient(System.Uri endpoint, Azure.AI.MetricsAdvisor.MetricsAdvisorKeyCredential credential, Azure.AI.MetricsAdvisor.MetricsAdvisorClientOptions options) { } + public MetricsAdvisorAdministrationClient(System.Uri endpoint, Azure.AI.MetricsAdvisor.MetricsAdvisorKeyCredential credential, Azure.AI.MetricsAdvisor.MetricsAdvisorClientsOptions options) { } public virtual Azure.Response CreateAnomalyAlertConfiguration(Azure.AI.MetricsAdvisor.Models.AnomalyAlertConfiguration alertConfiguration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CreateAnomalyAlertConfigurationAsync(Azure.AI.MetricsAdvisor.Models.AnomalyAlertConfiguration alertConfiguration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response CreateDataFeed(Azure.AI.MetricsAdvisor.Models.DataFeed dataFeed, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -106,15 +106,6 @@ public MetricsAdvisorAdministrationClient(System.Uri endpoint, Azure.AI.MetricsA public virtual Azure.Response UpdateMetricAnomalyDetectionConfiguration(string detectionConfigurationId, Azure.AI.MetricsAdvisor.Models.AnomalyDetectionConfiguration detectionConfiguration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task UpdateMetricAnomalyDetectionConfigurationAsync(string detectionConfigurationId, Azure.AI.MetricsAdvisor.Models.AnomalyDetectionConfiguration detectionConfiguration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } - public partial class MetricsAdvisorAdministrationClientOptions : Azure.Core.ClientOptions - { - public MetricsAdvisorAdministrationClientOptions(Azure.AI.MetricsAdvisor.Administration.MetricsAdvisorAdministrationClientOptions.ServiceVersion version = Azure.AI.MetricsAdvisor.Administration.MetricsAdvisorAdministrationClientOptions.ServiceVersion.V1_0) { } - public Azure.AI.MetricsAdvisor.Administration.MetricsAdvisorAdministrationClientOptions.ServiceVersion Version { get { throw null; } } - public enum ServiceVersion - { - V1_0 = 1, - } - } } namespace Azure.AI.MetricsAdvisor.Models { diff --git a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/Azure.AI.MetricsAdvisor.csproj b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/Azure.AI.MetricsAdvisor.csproj index 85ca391643690..872f7d0a84663 100644 --- a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/Azure.AI.MetricsAdvisor.csproj +++ b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/Azure.AI.MetricsAdvisor.csproj @@ -3,6 +3,10 @@ Microsoft Azure.AI.MetricsAdvisor client library 1.0.0-beta.2 $(RequiredTargetFrameworks) + + $(NoWarn); + AZC0007; + diff --git a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorAdministrationClient.cs b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorAdministrationClient.cs index 76a4d1a456800..d76d98b6a2170 100644 --- a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorAdministrationClient.cs +++ b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorAdministrationClient.cs @@ -40,12 +40,12 @@ public MetricsAdvisorAdministrationClient(Uri endpoint, MetricsAdvisorKeyCredent /// A credential used to authenticate to the service. /// A set of options to apply when configuring the client. /// or is null. - public MetricsAdvisorAdministrationClient(Uri endpoint, MetricsAdvisorKeyCredential credential, MetricsAdvisorClientOptions options) + public MetricsAdvisorAdministrationClient(Uri endpoint, MetricsAdvisorKeyCredential credential, MetricsAdvisorClientsOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); - options ??= new MetricsAdvisorClientOptions(); + options ??= new MetricsAdvisorClientsOptions(); _clientDiagnostics = new ClientDiagnostics(options); HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new MetricsAdvisorKeyCredentialPolicy(credential)); @@ -71,12 +71,12 @@ internal MetricsAdvisorAdministrationClient(Uri endpoint, TokenCredential creden /// A credential used to authenticate to the service. /// A set of options to apply when configuring the client. /// or is null. - internal MetricsAdvisorAdministrationClient(Uri endpoint, TokenCredential credential, MetricsAdvisorClientOptions options) + internal MetricsAdvisorAdministrationClient(Uri endpoint, TokenCredential credential, MetricsAdvisorClientsOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); - options ??= new MetricsAdvisorClientOptions(); + options ??= new MetricsAdvisorClientsOptions(); _clientDiagnostics = new ClientDiagnostics(options); HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, Constants.DefaultCognitiveScope)); diff --git a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorAdministrationClientOptions.cs b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorAdministrationClientOptions.cs deleted file mode 100644 index 68b2a06de6cba..0000000000000 --- a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorAdministrationClientOptions.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using Azure.Core; - -namespace Azure.AI.MetricsAdvisor.Administration -{ - /// - /// The set of options that can be specified when creating a - /// to configure its behavior. - /// - public class MetricsAdvisorAdministrationClientOptions : ClientOptions - { - private const ServiceVersion LatestVersion = ServiceVersion.V1_0; - - /// - /// Initializes a new instance of the class. - /// - /// The version of the service to send requests to. - /// is default. - public MetricsAdvisorAdministrationClientOptions(ServiceVersion version = LatestVersion) - { - if (version == default) - { - throw new ArgumentException($"The service version {version} is not supported by this library."); - } - - Version = version; - } - - /// - /// The service version. - /// - public enum ServiceVersion - { - /// - /// The V1.0 of the service. - /// -#pragma warning disable CA1707 // Identifiers should not contain underscores - V1_0 = 1 -#pragma warning restore CA1707 // Identifiers should not contain underscores - } - - /// - /// The service version. - /// - public ServiceVersion Version { get; } - } -} diff --git a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorClient.cs b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorClient.cs index e0919efb7fac0..457c6edaa50bc 100644 --- a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorClient.cs +++ b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorClient.cs @@ -42,12 +42,12 @@ public MetricsAdvisorClient(Uri endpoint, MetricsAdvisorKeyCredential credential /// A credential used to authenticate to the service. /// A set of options to apply when configuring the client. /// or is null. - public MetricsAdvisorClient(Uri endpoint, MetricsAdvisorKeyCredential credential, MetricsAdvisorClientOptions options) + public MetricsAdvisorClient(Uri endpoint, MetricsAdvisorKeyCredential credential, MetricsAdvisorClientsOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); - options ??= new MetricsAdvisorClientOptions(); + options ??= new MetricsAdvisorClientsOptions(); _clientDiagnostics = new ClientDiagnostics(options); HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new MetricsAdvisorKeyCredentialPolicy(credential)); @@ -73,12 +73,12 @@ internal MetricsAdvisorClient(Uri endpoint, TokenCredential credential) /// A credential used to authenticate to the service. /// A set of options to apply when configuring the client. /// or is null. - internal MetricsAdvisorClient(Uri endpoint, TokenCredential credential, MetricsAdvisorClientOptions options) + internal MetricsAdvisorClient(Uri endpoint, TokenCredential credential, MetricsAdvisorClientsOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); - options ??= new MetricsAdvisorClientOptions(); + options ??= new MetricsAdvisorClientsOptions(); _clientDiagnostics = new ClientDiagnostics(options); HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, Constants.DefaultCognitiveScope)); diff --git a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorClientOptions.cs b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorClientsOptions.cs similarity index 89% rename from sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorClientOptions.cs rename to sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorClientsOptions.cs index 960678e050c01..e9a5f4c5129b9 100644 --- a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorClientOptions.cs +++ b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/MetricsAdvisorClientsOptions.cs @@ -10,16 +10,16 @@ namespace Azure.AI.MetricsAdvisor /// The set of options that can be specified when creating a /// to configure its behavior. /// - public class MetricsAdvisorClientOptions : ClientOptions + public class MetricsAdvisorClientsOptions : ClientOptions { private const ServiceVersion LatestVersion = ServiceVersion.V1_0; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The version of the service to send requests to. /// is default. - public MetricsAdvisorClientOptions(ServiceVersion version = LatestVersion) + public MetricsAdvisorClientsOptions(ServiceVersion version = LatestVersion) { if (version == default) { diff --git a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/tests/MetricsAdvisorLiveTestBase.cs b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/tests/MetricsAdvisorLiveTestBase.cs index e3c1ab2828665..bf33c0f66f791 100644 --- a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/tests/MetricsAdvisorLiveTestBase.cs +++ b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/tests/MetricsAdvisorLiveTestBase.cs @@ -45,7 +45,7 @@ public MetricsAdvisorAdministrationClient GetMetricsAdvisorAdministrationClientA return InstrumentClient(new MetricsAdvisorAdministrationClient( new Uri(TestEnvironment.MetricsAdvisorUri), TestEnvironment.Credential, - InstrumentClientOptions(new MetricsAdvisorClientOptions()))); + InstrumentClientOptions(new MetricsAdvisorClientsOptions()))); } public MetricsAdvisorAdministrationClient GetMetricsAdvisorAdministrationClient() @@ -53,7 +53,7 @@ public MetricsAdvisorAdministrationClient GetMetricsAdvisorAdministrationClient( return InstrumentClient(new MetricsAdvisorAdministrationClient( new Uri(TestEnvironment.MetricsAdvisorUri), new MetricsAdvisorKeyCredential(TestEnvironment.MetricsAdvisorSubscriptionKey, TestEnvironment.MetricsAdvisorApiKey), - InstrumentClientOptions(new MetricsAdvisorClientOptions()))); + InstrumentClientOptions(new MetricsAdvisorClientsOptions()))); } public MetricsAdvisorClient GetMetricsAdvisorClient() @@ -61,7 +61,7 @@ public MetricsAdvisorClient GetMetricsAdvisorClient() return InstrumentClient(new MetricsAdvisorClient( new Uri(TestEnvironment.MetricsAdvisorUri), new MetricsAdvisorKeyCredential(TestEnvironment.MetricsAdvisorSubscriptionKey, TestEnvironment.MetricsAdvisorApiKey), - InstrumentClientOptions(new MetricsAdvisorClientOptions()))); + InstrumentClientOptions(new MetricsAdvisorClientsOptions()))); } internal static async Task GetFirstDataFeed(MetricsAdvisorAdministrationClient adminClient)