Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metrics Advisor SDK APIs aligning with most recent swagger updates #21936

Merged
merged 55 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
802f299
Adding more doc to FeedType types and correcting typo in addFeedback …
anuchandy May 26, 2021
6de8c86
Using the name Sql, MongoDb, InfluxDb
anuchandy May 27, 2021
67ffad4
Initial impl of credential entities and its integration with data feed
anuchandy May 27, 2021
1c63140
Apply Fluent, Immutable as appropriate
anuchandy May 27, 2021
e7f8b73
Updating listMetricEnrichedSeriesData signature to take detectionId a…
anuchandy May 27, 2021
3075377
Renaming listAnomaliesForAlert and listAnomaliesForDetectionConfig to…
anuchandy May 27, 2021
af1938e
Adding ClientOptions
anuchandy May 27, 2021
e00dd5f
Renaming listIncidentsForAlert and listIncidentsForDetectionConfig to…
anuchandy May 27, 2021
f841c01
Adding DimensionKey::get(..) and renaming TOPN enum-value to TOP_N
anuchandy May 27, 2021
77209ef
Sync with upstream master
anuchandy May 27, 2021
0e765ed
Add options overload API's
samvaity May 27, 2021
677ff98
revert DataFeedIngestionOption changes
samvaity May 27, 2021
1d1b8fa
Updating BoundaryDirection, DataFeedRollupType, DataFeedSourceType an…
anuchandy May 27, 2021
1969314
Adding doc for DataFeedSource abstract type, renaming AzureCosmosData…
anuchandy May 28, 2021
ba561a2
Removing setSubscriptionKey() and setApiKey(), instead adding an upda…
anuchandy May 28, 2021
5b0eea0
MA Credentials: Removing Entity suffix and adding DataSource prefix
anuchandy May 28, 2021
83ad566
Rename ErrorCode to MetricsAdvisorErrorCode
anuchandy May 28, 2021
57e7b23
update listDataFeedIngestionStatus
samvaity May 28, 2021
a3f4c7f
Merge pull request #3 from samvaity/add-list-alert-overload
anuchandy May 28, 2021
5f1d9e7
Addressing feedback for the last commit (Fixingspotbug and checkstyle)
anuchandy May 28, 2021
0af9b97
consider datasource prefix for credential as one word (archfeedback)
anuchandy May 28, 2021
ac70796
Renaming DataSourceCredentialType to DatasourceCredentialType
anuchandy May 28, 2021
08b9d80
Adding tests for Data Source Credentials. Rename userfacing type Data…
anuchandy May 28, 2021
81d4cd8
Adding junit tests for data source cred async apis
anuchandy May 28, 2021
cddf0aa
Adding sync tests for Data Source Credentials and recordings
anuchandy May 30, 2021
94deff8
Adding samples and code snippets for Credential Entity API
samvaity Jun 1, 2021
673df3c
Adding test skeleton for associating cred to datafeed
anuchandy Jun 1, 2021
98b52fe
Merge branch 'ma-new-apis' of github.com:anuchandy/azure-sdk-for-java…
anuchandy Jun 1, 2021
838c57f
Use single word datasource for DataSourceDataLakeGen2SharedKey
anuchandy Jun 2, 2021
79c7836
Removing unsupported value 'Secondly' from Granularity
anuchandy Jun 2, 2021
9d4ee6b
Hiding clientSecret getter from AzureLogAnalyticsDataFeedSource
anuchandy Jun 2, 2021
6585e52
Finishing Cred association with DataFeedSources
anuchandy Jun 2, 2021
dd90209
Completing tests for Cred association with DataFeedSources
anuchandy Jun 2, 2021
bf8dbcc
Adding test recordings for Cred to DataFeedSource association
anuchandy Jun 2, 2021
fffaddf
Adding cred association to AzureLogAnalytics DataFeed
anuchandy Jun 2, 2021
17eacfd
Add valid cred for log analytics
samvaity Jun 2, 2021
500824d
rename to updateKey
samvaity Jun 2, 2021
84c5a70
rename env vars
samvaity Jun 2, 2021
8060803
Merge pull request #5 from samvaity/ma-work
anuchandy Jun 2, 2021
725c01c
Moving admin models to admininstration.models package
anuchandy Jun 2, 2021
e4d1fda
sync with upstream changes
anuchandy Jun 2, 2021
52ae44e
Removing equality assert on LogAna ids
anuchandy Jun 2, 2021
8f8c822
Merge pull request #6 from anuchandy/ma-new-api-admin
anuchandy Jun 2, 2021
2d62afc
Update Changelog (#7)
samvaity Jun 2, 2021
ed7e7d9
Fix pipeline error - export admin models (#8)
samvaity Jun 2, 2021
ae4e843
Moving MetricsAdvisorServiceVersion to root package
anuchandy Jun 3, 2021
ff3c5a3
Override setDimensionFilter in Feedback types to ensure fluent chain
anuchandy Jun 3, 2021
5d36ae8
Adding addFeedbackWithResponse in sync client
anuchandy Jun 3, 2021
1793423
Use the param name credentialId consistently, removing unsupported co…
anuchandy Jun 3, 2021
e2d3ab7
Rename DATA_LAKE_GEN2SHARED_KEY enum-val to DATA_LAKE_GEN2_SHARED_KEY…
anuchandy Jun 3, 2021
ce0d0ee
Use from prefix (instead of using prefix) for all factory methods to …
anuchandy Jun 3, 2021
d90e28c
Introduced MetricsAdvisorKeys that composes subscription and api key
anuchandy Jun 3, 2021
6738f01
Renaming error types to MetricsAdvisorError and MetricsAdvisorRespons…
anuchandy Jun 3, 2021
1cc0446
update module info and add final
samvaity Jun 3, 2021
89eb519
Merge pull request #9 from samvaity/ma-module-info
anuchandy Jun 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public AnomaliesListTest(PerfStressOptions options) {
@Override
public void run() {
super.metricsAdvisorClient
.listAnomaliesForAlert(super.alertConfigId,
.listAnomalies(super.alertConfigId,
super.alertId,
new ListAnomaliesAlertedOptions(),
Context.NONE)
Expand All @@ -38,7 +38,7 @@ public void run() {
@Override
public Mono<Void> runAsync() {
return super.metricsAdvisorAsyncClient
.listAnomaliesForAlert(super.alertConfigId,
.listAnomalies(super.alertConfigId,
super.alertId,
new ListAnomaliesAlertedOptions())
.take(super.maxListElements)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package com.azure.ai.metricsadvisor.perf;

import com.azure.ai.metricsadvisor.models.ListIncidentsAlertedOptions;
import com.azure.ai.metricsadvisor.perf.core.ServiceTest;
import com.azure.perf.test.core.PerfStressOptions;
import reactor.core.publisher.Mono;
Expand All @@ -24,9 +23,8 @@ public IncidentsListTest(PerfStressOptions options) {
@Override
public void run() {
super.metricsAdvisorClient
.listIncidentsForAlert(super.alertConfigId,
super.alertId,
new ListIncidentsAlertedOptions())
.listIncidents(super.alertConfigId,
super.alertId)
.stream()
.limit(super.maxListElements)
.forEach(incident -> {
Expand All @@ -36,9 +34,8 @@ public void run() {
@Override
public Mono<Void> runAsync() {
return super.metricsAdvisorAsyncClient
.listIncidentsForAlert(super.alertConfigId,
super.alertId,
new ListIncidentsAlertedOptions())
.listIncidents(super.alertConfigId,
super.alertId)
.take(super.maxListElements)
.then();
}
Expand Down
15 changes: 12 additions & 3 deletions sdk/metricsadvisor/azure-ai-metricsadvisor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
## 1.0.0-beta.4 (Unreleased)

### Features added
- Added support for Azure Log Analytics DataFeed source.
- Added support for Azure Log Analytics DataFeed source
- Added data source credential API support to client
- Added authentication type support for data feed
- Added property `splitAlertByDimensions` to AnomalyAlertConfiguration model

### Breaking changes
- Replaced updateSubscriptionKey and updateApiKey into one method updateKey
- Deprecated support for HttpRequestDataFeed and ElasticsearchDataFeed source type
- Renamed `value` and `expectedValue` to `valueOfRootNode` and `expectedValueOfRootNode`
- Renamed `top` parameter to `maxPageSize`

- Removed granularity type DataFeedGranularityType.PerSecond as it's not supported by the service anymore.

## 1.0.0-beta.3 (2021-02-09)
- Support Azure Active Directory (AAD) authentication for Metrics Advisor clients.
- Renamed method `listDimensionValuesWithAnomalies` and `ListDimensionValuesWithAnomaliesOptions`.
Expand All @@ -32,7 +39,9 @@
- Renamed Data feed ingestion granularity type to `"PerMinute"` and `"PerSecond"` instead of `"Minutely"` and `"Secondly"`.
- Renamed Feedback api's from `createMetricFeedback`, `getMetricFeedback` and `listMetricFeedbacks`
to `addFeedback`, `getFeedback` and `listFeedback` respectively.

- Removed `getSubscriptionKey` and `getApiKey` from `MetricsAdvisorKeyCredential` and introduced `MetricsAdvisorKeys`.
- Renamed model `ErrorCode` to `MetricsAdvisorError` and `ErrorCodeException`
to `MetricsAdvisorResponseException`
## 1.0.0-beta.1 (2020-10-07)
Version 1.0.0-beta.1 is a preview of our efforts in creating a Azure Metrics Advisor client library that is developer-friendly
and idiomatic to the Java ecosystem. The principles that guide
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.azure.ai.metricsadvisor.implementation.AzureCognitiveServiceMetricsAdvisorRestAPIOpenAPIV2Impl;
import com.azure.ai.metricsadvisor.implementation.AzureCognitiveServiceMetricsAdvisorRestAPIOpenAPIV2ImplBuilder;
import com.azure.ai.metricsadvisor.models.MetricsAdvisorKeyCredential;
import com.azure.ai.metricsadvisor.models.MetricsAdvisorServiceVersion;
import com.azure.core.annotation.ServiceClientBuilder;
import com.azure.core.credential.TokenCredential;
import com.azure.core.http.ContentType;
Expand All @@ -19,11 +18,13 @@
import com.azure.core.http.policy.BearerTokenAuthenticationPolicy;
import com.azure.core.http.policy.HttpLogDetailLevel;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.policy.HttpLoggingPolicy;
import com.azure.core.http.policy.HttpPipelinePolicy;
import com.azure.core.http.policy.HttpPolicyProviders;
import com.azure.core.http.policy.RequestIdPolicy;
import com.azure.core.http.policy.RetryPolicy;
import com.azure.core.http.policy.UserAgentPolicy;
import com.azure.core.util.ClientOptions;
import com.azure.core.util.Configuration;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
Expand Down Expand Up @@ -79,6 +80,8 @@ public final class MetricsAdvisorClientBuilder {
private static final RetryPolicy DEFAULT_RETRY_POLICY = new RetryPolicy("retry-after-ms",
ChronoUnit.MILLIS);
private static final String DEFAULT_SCOPE = "https://cognitiveservices.azure.com/.default";
private static final HttpLogOptions DEFAULT_LOG_OPTIONS = new HttpLogOptions();
private static final ClientOptions DEFAULT_CLIENT_OPTIONS = new ClientOptions();

private final ClientLogger logger = new ClientLogger(MetricsAdvisorClientBuilder.class);
private final List<HttpPipelinePolicy> policies;
Expand All @@ -91,6 +94,7 @@ public final class MetricsAdvisorClientBuilder {
private TokenCredential tokenCredential;
private HttpClient httpClient;
private HttpLogOptions httpLogOptions;
private ClientOptions clientOptions;
private HttpPipeline httpPipeline;
private Configuration configuration;
private RetryPolicy retryPolicy;
Expand All @@ -111,8 +115,8 @@ public MetricsAdvisorClientBuilder() {
clientVersion = properties.getOrDefault(VERSION, "UnknownVersion");

headers = new HttpHeaders()
.put(ECHO_REQUEST_ID_HEADER, "true")
.put(ACCEPT_HEADER, CONTENT_TYPE_HEADER_VALUE);
.set(ECHO_REQUEST_ID_HEADER, "true")
.set(ACCEPT_HEADER, CONTENT_TYPE_HEADER_VALUE);
}

/**
Expand Down Expand Up @@ -183,24 +187,29 @@ private HttpPipeline getDefaultHttpPipeline(Configuration buildConfiguration) {
// Authentications
if (tokenCredential != null) {
policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPE));
} else if (!CoreUtils.isNullOrEmpty(metricsAdvisorKeyCredential.getSubscriptionKey())
|| !CoreUtils.isNullOrEmpty(metricsAdvisorKeyCredential.getApiKey())) {
headers.put(OCP_APIM_SUBSCRIPTION_KEY, metricsAdvisorKeyCredential.getSubscriptionKey());
headers.put(API_KEY, metricsAdvisorKeyCredential.getApiKey());
} else if (!CoreUtils.isNullOrEmpty(metricsAdvisorKeyCredential.getKeys().getSubscriptionKey())
|| !CoreUtils.isNullOrEmpty(metricsAdvisorKeyCredential.getKeys().getApiKey())) {
headers.set(OCP_APIM_SUBSCRIPTION_KEY, metricsAdvisorKeyCredential.getKeys().getSubscriptionKey());
headers.set(API_KEY, metricsAdvisorKeyCredential.getKeys().getApiKey());
} else {
// Throw exception that credential cannot be null
throw logger.logExceptionAsError(
new IllegalArgumentException("Missing credential information while building a client."));
}

policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), clientName, clientVersion,
ClientOptions buildClientOptions = this.clientOptions == null ? DEFAULT_CLIENT_OPTIONS : this.clientOptions;
HttpLogOptions buildLogOptions = this.httpLogOptions == null ? DEFAULT_LOG_OPTIONS : this.httpLogOptions;
final String applicationId = CoreUtils.getApplicationId(buildClientOptions, buildLogOptions);

policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion,
buildConfiguration));
policies.add(new RequestIdPolicy());
policies.add(new AddHeadersPolicy(headers));

HttpPolicyProviders.addBeforeRetryPolicies(policies);
policies.add(retryPolicy == null ? DEFAULT_RETRY_POLICY : retryPolicy);
policies.add(new AddDatePolicy());
policies.add(new HttpLoggingPolicy(httpLogOptions));

policies.addAll(this.policies);
HttpPolicyProviders.addAfterRetryPolicies(policies);
Expand Down Expand Up @@ -280,6 +289,17 @@ public MetricsAdvisorClientBuilder httpLogOptions(HttpLogOptions logOptions) {
return this;
}

/**
* Sets the client options such as application ID and custom headers to set on a request.
*
* @param clientOptions The client options.
* @return The updated MetricsAdvisorClientBuilder object.
*/
public MetricsAdvisorClientBuilder clientOptions(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
return this;
}

/**
* Adds a policy to the set of existing policies that are executed after required policies.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.ai.metricsadvisor.models;
package com.azure.ai.metricsadvisor;

import com.azure.core.util.ServiceVersion;

Expand Down
Loading