Skip to content

Commit

Permalink
[MetricsAdvisor] Made constructor of DataFeed parameterless (#18319)
Browse files Browse the repository at this point in the history
* Fixed bug when setting Viewers and Administrators during Data Feed creation.

* Made DataFeed-related collections not settable.
  • Loading branch information
kinelski authored Feb 2, 2021
1 parent 38cabe2 commit cad9ae5
Show file tree
Hide file tree
Showing 115 changed files with 6,051 additions and 5,136 deletions.
11 changes: 11 additions & 0 deletions sdk/metricsadvisor/Azure.AI.MetricsAdvisor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,23 @@
- Added support for AAD authentication in `MetricsAdvisorClient` and `MetricsAdvisorAdministrationClient`.

### Breaking Changes
- The constructor of the `DataFeed` class is now parameterless. Required properties should be set via setters.
- The constructor of the `DataFeedSchema` class is now parameterless. Metrics can be added directly to `MetricColumns`.
- The constructor of the `DataFeedIngestionSettings` class is now parameterless. Required properties should be set via setters.
- In `DataFeed`, added property setters to `Name`, `DataSource`, `Granularity`, `IngestionSettings`, and `Schema`.
- In `DataFeedIngestionSettings`, added a property setter to `IngestionStartTime`.
- In `DataFeed`, removed the setters of the properties `Administrators` and `Viewers`.
- In `DataFeedSchema`, removed the setter of the property `DimensionColumns`.
- In `DataFeedRollupSettings`, removed the setter of the property `AutoRollupGroupByColumnNames`.
- `DataFeed.SourceType` is now nullable. It will be null whenever `DataFeed.DataSource` is null.
- `DataFeed.IngestionStartTime` is now nullable.
- In `MetricsAdvisorKeyCredential`, renamed the parameter `key` to `subscriptionKey` in the method `UpdateSubscriptionKey`.
- In `MetricsAdvisorKeyCredential`, renamed the parameter `key` to `apiKey` in the method `UpdateApiKey`.

### Key Bug Fixes
- Fixed a bug in which setting `WebNotificationHook.CertificatePassword` would actually set the property `Username` instead.
- Fixed a bug in which an `ArgumentNullException` was thrown when getting a `DataFeed` from the service as a Viewer.
- Fixed a bug in which a data feed's administrators and viewers could not be set during creation.

## 1.0.0-beta.2 (2020-11-10)

Expand Down
33 changes: 13 additions & 20 deletions sdk/metricsadvisor/Azure.AI.MetricsAdvisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,29 +186,22 @@ Metrics Advisor supports multiple types of data sources. In this sample we'll il
string sqlServerConnectionString = "<connectionString>";
string sqlServerQuery = "<query>";

var dataFeedName = "Sample data feed";
var dataFeedSource = new SqlServerDataFeedSource(sqlServerConnectionString, sqlServerQuery);
var dataFeedGranularity = new DataFeedGranularity(DataFeedGranularityType.Daily);
var dataFeed = new DataFeed();

var dataFeedMetrics = new List<DataFeedMetric>()
{
new DataFeedMetric("cost"),
new DataFeedMetric("revenue")
};
var dataFeedDimensions = new List<DataFeedDimension>()
{
new DataFeedDimension("category"),
new DataFeedDimension("city")
};
var dataFeedSchema = new DataFeedSchema(dataFeedMetrics)
{
DimensionColumns = dataFeedDimensions
};
dataFeed.Name = "Sample data feed";
dataFeed.DataSource = new SqlServerDataFeedSource(sqlServerConnectionString, sqlServerQuery);
dataFeed.Granularity = new DataFeedGranularity(DataFeedGranularityType.Daily);

var ingestionStartTime = DateTimeOffset.Parse("2020-01-01T00:00:00Z");
var dataFeedIngestionSettings = new DataFeedIngestionSettings(ingestionStartTime);
dataFeed.Schema = new DataFeedSchema();
dataFeed.Schema.MetricColumns.Add(new DataFeedMetric("cost"));
dataFeed.Schema.MetricColumns.Add(new DataFeedMetric("revenue"));
dataFeed.Schema.DimensionColumns.Add(new DataFeedDimension("category"));
dataFeed.Schema.DimensionColumns.Add(new DataFeedDimension("city"));

var dataFeed = new DataFeed(dataFeedName, dataFeedSource, dataFeedGranularity, dataFeedSchema, dataFeedIngestionSettings);
dataFeed.IngestionSettings = new DataFeedIngestionSettings()
{
IngestionStartTime = DateTimeOffset.Parse("2020-01-01T00:00:00Z")
};

Response<string> response = await adminClient.CreateDataFeedAsync(dataFeed);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,26 +507,26 @@ public ChangeThresholdCondition(double changePercentage, int shiftPoint, bool is
}
public partial class DataFeed
{
public DataFeed(string dataFeedName, Azure.AI.MetricsAdvisor.Models.DataFeedSource dataSource, Azure.AI.MetricsAdvisor.Models.DataFeedGranularity dataFeedGranularity, Azure.AI.MetricsAdvisor.Models.DataFeedSchema dataFeedSchema, Azure.AI.MetricsAdvisor.Models.DataFeedIngestionSettings dataFeedIngestionSettings) { }
public DataFeed() { }
public Azure.AI.MetricsAdvisor.Models.DataFeedAccessMode? AccessMode { get { throw null; } set { } }
public string ActionLinkTemplate { get { throw null; } set { } }
public System.Collections.Generic.IList<string> Administrators { get { throw null; } set { } }
public System.Collections.Generic.IList<string> Administrators { get { throw null; } }
public System.DateTimeOffset? CreatedTime { get { throw null; } }
public string Creator { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.DataFeedSource DataSource { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.DataFeedSource DataSource { get { throw null; } set { } }
public string Description { get { throw null; } set { } }
public Azure.AI.MetricsAdvisor.Models.DataFeedGranularity Granularity { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.DataFeedGranularity Granularity { get { throw null; } set { } }
public string Id { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.DataFeedIngestionSettings IngestionSettings { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.DataFeedIngestionSettings IngestionSettings { get { throw null; } set { } }
public bool? IsAdministrator { get { throw null; } }
public System.Collections.Generic.IReadOnlyDictionary<string, string> MetricIds { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.DataFeedMissingDataPointFillSettings MissingDataPointFillSettings { get { throw null; } set { } }
public string Name { get { throw null; } }
public string Name { get { throw null; } set { } }
public Azure.AI.MetricsAdvisor.Models.DataFeedRollupSettings RollupSettings { get { throw null; } set { } }
public Azure.AI.MetricsAdvisor.Models.DataFeedSchema Schema { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.DataFeedSourceType SourceType { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.DataFeedSchema Schema { get { throw null; } set { } }
public Azure.AI.MetricsAdvisor.Models.DataFeedSourceType? SourceType { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.DataFeedStatus? Status { get { throw null; } }
public System.Collections.Generic.IList<string> Viewers { get { throw null; } set { } }
public System.Collections.Generic.IList<string> Viewers { get { throw null; } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct DataFeedAccessMode : System.IEquatable<Azure.AI.MetricsAdvisor.Models.DataFeedAccessMode>
Expand Down Expand Up @@ -612,11 +612,11 @@ internal DataFeedIngestionProgress() { }
}
public partial class DataFeedIngestionSettings
{
public DataFeedIngestionSettings(System.DateTimeOffset ingestionStartTime) { }
public DataFeedIngestionSettings() { }
public int? DataSourceRequestConcurrency { get { throw null; } set { } }
public System.TimeSpan? IngestionRetryDelay { get { throw null; } set { } }
public System.TimeSpan? IngestionStartOffset { get { throw null; } set { } }
public System.DateTimeOffset IngestionStartTime { get { throw null; } }
public System.DateTimeOffset? IngestionStartTime { get { throw null; } set { } }
public System.TimeSpan? StopRetryAfter { get { throw null; } set { } }
}
public partial class DataFeedIngestionStatus
Expand Down Expand Up @@ -664,7 +664,7 @@ public partial class DataFeedRollupSettings
{
public DataFeedRollupSettings() { }
public string AlreadyRollupIdentificationValue { get { throw null; } set { } }
public System.Collections.Generic.IList<string> AutoRollupGroupByColumnNames { get { throw null; } set { } }
public System.Collections.Generic.IList<string> AutoRollupGroupByColumnNames { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.DataFeedAutoRollupMethod? RollupMethod { get { throw null; } set { } }
public Azure.AI.MetricsAdvisor.Models.DataFeedRollupType? RollupType { get { throw null; } set { } }
}
Expand All @@ -689,8 +689,8 @@ public DataFeedRollupSettings() { }
}
public partial class DataFeedSchema
{
public DataFeedSchema(System.Collections.Generic.IList<Azure.AI.MetricsAdvisor.Models.DataFeedMetric> metricColumns) { }
public System.Collections.Generic.IList<Azure.AI.MetricsAdvisor.Models.DataFeedDimension> DimensionColumns { get { throw null; } set { } }
public DataFeedSchema() { }
public System.Collections.Generic.IList<Azure.AI.MetricsAdvisor.Models.DataFeedDimension> DimensionColumns { get { throw null; } }
public System.Collections.Generic.IList<Azure.AI.MetricsAdvisor.Models.DataFeedMetric> MetricColumns { get { throw null; } }
public string TimestampColumn { get { throw null; } set { } }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,11 @@ Page<DataFeed> NextPageFunc(string nextLink, int? pageSizeHint)
/// A <see cref="Response{T}"/> containing the result of the operation. The result is a <c>string</c>
/// containing the ID of the newly created feed.
/// </returns>
/// <exception cref="ArgumentNullException"><paramref name="dataFeed"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="dataFeed"/>, <paramref name="dataFeed"/>.Name, <paramref name="dataFeed"/>.DataSource, <paramref name="dataFeed"/>.Granularity, <paramref name="dataFeed"/>.Schema, <paramref name="dataFeed"/>.IngestionSettings, or <paramref name="dataFeed"/>.IngestionSettings.IngestionStartTime is null.</exception>
/// <exception cref="ArgumentException"><paramref name="dataFeed"/>.Name is empty.</exception>
public virtual async Task<Response<string>> CreateDataFeedAsync(DataFeed dataFeed, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(dataFeed, nameof(dataFeed));
ValidateDataFeedToCreate(dataFeed);

using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(MetricsAdvisorAdministrationClient)}.{nameof(CreateDataFeed)}");
scope.Start();
Expand Down Expand Up @@ -306,10 +307,11 @@ public virtual async Task<Response<string>> CreateDataFeedAsync(DataFeed dataFee
/// A <see cref="Response{T}"/> containing the result of the operation. The result is a <c>string</c> instance
/// containing the ID of the newly created feed.
/// </returns>
/// <exception cref="ArgumentNullException"><paramref name="dataFeed"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="dataFeed"/>, <paramref name="dataFeed"/>.Name, <paramref name="dataFeed"/>.DataSource, <paramref name="dataFeed"/>.Granularity, <paramref name="dataFeed"/>.Schema, <paramref name="dataFeed"/>.IngestionSettings, or <paramref name="dataFeed"/>.IngestionSettings.IngestionStartTime is null.</exception>
/// <exception cref="ArgumentException"><paramref name="dataFeed"/>.Name is empty.</exception>
public virtual Response<string> CreateDataFeed(DataFeed dataFeed, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(dataFeed, nameof(dataFeed));
ValidateDataFeedToCreate(dataFeed);

using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(MetricsAdvisorAdministrationClient)}.{nameof(CreateDataFeed)}");
scope.Start();
Expand Down Expand Up @@ -678,6 +680,17 @@ private static IReadOnlyList<DataFeed> ConvertToDataFeeds(IReadOnlyList<DataFeed
return dataFeeds;
}

private static void ValidateDataFeedToCreate(DataFeed dataFeed)
{
Argument.AssertNotNull(dataFeed, nameof(dataFeed));
Argument.AssertNotNullOrEmpty(dataFeed.Name, $"{nameof(dataFeed)}.{nameof(dataFeed.Name)}");
Argument.AssertNotNull(dataFeed.DataSource, $"{nameof(dataFeed)}.{nameof(dataFeed.DataSource)}");
Argument.AssertNotNull(dataFeed.Granularity, $"{nameof(dataFeed)}.{nameof(dataFeed.Granularity)}");
Argument.AssertNotNull(dataFeed.Schema, $"{nameof(dataFeed)}.{nameof(dataFeed.Schema)}");
Argument.AssertNotNull(dataFeed.IngestionSettings, $"{nameof(dataFeed)}.{nameof(dataFeed.IngestionSettings)}");
Argument.AssertNotNull(dataFeed.IngestionSettings.IngestionStartTime, $"{nameof(dataFeed)}.{nameof(dataFeed.IngestionSettings)}.{nameof(dataFeed.IngestionSettings.IngestionStartTime)}");
}

#endregion DataFeed

#region AnomalyDetectionConfiguration
Expand Down
Loading

0 comments on commit cad9ae5

Please sign in to comment.