Skip to content

Commit

Permalink
update javadoc and sample
Browse files Browse the repository at this point in the history
  • Loading branch information
samvaity committed Jun 25, 2021
1 parent 2ffbe49 commit 3f9429a
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.ai.metricsadvisor;

import com.azure.ai.metricsadvisor.models.ChangePointValue;
import com.azure.ai.metricsadvisor.models.DimensionKey;
import com.azure.ai.metricsadvisor.models.MetricAnomalyFeedback;
import com.azure.ai.metricsadvisor.models.MetricChangePointFeedback;
import com.azure.ai.metricsadvisor.models.MetricCommentFeedback;
Expand All @@ -14,6 +15,7 @@

import java.time.OffsetDateTime;

import static com.azure.ai.metricsadvisor.FeedbackTestBase.DIMENSION_FILTER;
import static com.azure.ai.metricsadvisor.models.FeedbackType.ANOMALY;
import static com.azure.ai.metricsadvisor.models.FeedbackType.CHANGE_POINT;
import static com.azure.ai.metricsadvisor.models.FeedbackType.COMMENT;
Expand All @@ -35,7 +37,8 @@ public static void main(String[] args) {
final OffsetDateTime startTime = OffsetDateTime.parse("2020-01-01T00:00:00Z");
final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
final MetricChangePointFeedback metricChangePointFeedback
= new MetricChangePointFeedback(startTime, endTime, ChangePointValue.AUTO_DETECT);
= new MetricChangePointFeedback(startTime, endTime, ChangePointValue.AUTO_DETECT)
.setDimensionFilter(new DimensionKey(DIMENSION_FILTER));

System.out.printf("Creating Metric Feedback%n");
final Mono<MetricFeedback> createdFeedbackMono
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.ai.metricsadvisor;

import com.azure.ai.metricsadvisor.models.ChangePointValue;
import com.azure.ai.metricsadvisor.models.DimensionKey;
import com.azure.ai.metricsadvisor.models.MetricAnomalyFeedback;
import com.azure.ai.metricsadvisor.models.MetricChangePointFeedback;
import com.azure.ai.metricsadvisor.models.MetricCommentFeedback;
Expand All @@ -13,6 +14,7 @@

import java.time.OffsetDateTime;

import static com.azure.ai.metricsadvisor.FeedbackTestBase.DIMENSION_FILTER;
import static com.azure.ai.metricsadvisor.models.FeedbackType.ANOMALY;
import static com.azure.ai.metricsadvisor.models.FeedbackType.CHANGE_POINT;
import static com.azure.ai.metricsadvisor.models.FeedbackType.COMMENT;
Expand All @@ -34,7 +36,8 @@ public static void main(String[] args) {
final OffsetDateTime startTime = OffsetDateTime.parse("2020-01-01T00:00:00Z");
final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
final MetricChangePointFeedback metricChangePointFeedback
= new MetricChangePointFeedback(startTime, endTime, ChangePointValue.AUTO_DETECT);
= new MetricChangePointFeedback(startTime, endTime, ChangePointValue.AUTO_DETECT)
.setDimensionFilter(new DimensionKey(DIMENSION_FILTER));

System.out.printf("Creating Metric Feedback%n");
final MetricFeedback createdFeedback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,8 @@ public void listIncidentsForDetectionConfigWithOptions() {
.setMaxPageSize(1000);

PagedFlux<AnomalyIncident> incidentsFlux
= metricsAdvisorAsyncClient.listIncidentsForDetectionConfiguration(detectionConfigurationId, startTime, endTime, options);
= metricsAdvisorAsyncClient.listIncidentsForDetectionConfiguration(detectionConfigurationId, startTime,
endTime, options);

incidentsFlux.subscribe(incident -> {
System.out.printf("Data Feed Metric Id: %s%n", incident.getMetricId());
Expand Down Expand Up @@ -666,7 +667,8 @@ public void listIncidentRootCausesWithIncident() {
= new ListIncidentsDetectedOptions()
.setMaxPageSize(10);

metricsAdvisorAsyncClient.listIncidentsForDetectionConfiguration(detectionConfigurationId, startTime, endTime, options)
metricsAdvisorAsyncClient.listIncidentsForDetectionConfiguration(detectionConfigurationId, startTime, endTime,
options)
.flatMap(incident -> {
return metricsAdvisorAsyncClient.listIncidentRootCauses(incident);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ public static void main(String[] args) {
.setOptions(new DataFeedOptions().setAdminEmails(Collections.singletonList("admin1@admin.com"))))
.doOnSubscribe(__ ->
System.out.printf("Updating data feed: %s%n", dataFeed.getId()))
.doOnSuccess(config -> {

.doOnSuccess(updatedDataFeed -> {

System.out.printf("Updated data feed%n");
System.out.printf("Updated data feed admin list: %s%n", dataFeed.getOptions().getAdminEmails());
System.out.printf("Updated data feed admin list: %s%n",
String.join(",", updatedDataFeed.getOptions().getAdminEmails()));
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ public static void main(String[] args) {

// Update the data feed.
System.out.printf("Updating data feed: %s%n", dataFeed.getId());
dataFeed = advisorAdministrationClient.updateDataFeed(dataFeed
.setOptions(new DataFeedOptions().setAdminEmails(Collections.singletonList("admin1@admin.com"))));
System.out.printf("Updated data feed admin list: %s%n", dataFeed.getOptions().getAdminEmails());
dataFeed = advisorAdministrationClient.updateDataFeed(dataFeed.setOptions(new DataFeedOptions()
.setAdminEmails(Collections.singletonList("admin1@admin.com"))
));
System.out.printf("Updated data feed admin list: %s%n",
String.join(",", dataFeed.getOptions().getAdminEmails()));

// Delete the data feed.
System.out.printf("Deleting data feed: %s%n", dataFeed.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ public static void main(String[] args) {
return advisorAdministrationAsyncClient.updateHook(emailHookToUpdate)
.doOnSubscribe(__ ->
System.out.printf("Updating Notification Hook: %s%n", hook.getId()))
.doOnSuccess(config ->
System.out.printf("Updated Notification Hook%n"));
.doOnSuccess(notificationHook ->
System.out.printf("Updated Notification Hook emails: %s%n",
String.join(",", ((EmailNotificationHook) notificationHook).getEmailsToAlert())));
});

// Delete the hook.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void main(String[] args) {

// Create email notificationHook.
System.out.printf("Creating NotificationHook%n");
NotificationHook emailNotificationHookToCreate = new EmailNotificationHook("email notification Hook")
NotificationHook emailNotificationHookToCreate = new EmailNotificationHook("email notification Hook1")
.setDescription("my email notification Hook")
.setEmailsToAlert(emails)
.setExternalLink("https://adwiki.azurewebsites.net/articles/howto/alerts/create-hooks.html");
Expand Down Expand Up @@ -56,8 +56,10 @@ public static void main(String[] args) {

emailHookToUpdate
.setEmailsToAlert(emailsToUpdate);
advisorAdministrationClient.updateHook(emailHookToUpdate);
notificationHook = advisorAdministrationClient.updateHook(emailHookToUpdate);
System.out.printf("Updated notification Hook: %s%n", notificationHook.getId());
System.out.printf("Updated Email Hook Emails: %s%n",
String.join(",", ((EmailNotificationHook) notificationHook).getEmailsToAlert()));

// Delete the notificationHook.
System.out.printf("Deleting Notification Hook: %s%n", notificationHook.getId());
Expand All @@ -74,26 +76,26 @@ public static void main(String[] args) {
System.out.printf("Created web notification Hook: %s%n", notificationHook.getId());

// List hooks.
System.out.printf("Listing hooks%n");
PagedIterable<NotificationHook> hooksIterable
= advisorAdministrationClient.listHooks();
for (NotificationHook notificationHookItem : hooksIterable) {
if (notificationHookItem instanceof EmailNotificationHook) {
EmailNotificationHook emailHook = (EmailNotificationHook) notificationHookItem;
System.out.printf("Email Hook Id: %s%n", emailHook.getId());
System.out.printf("Email Hook Name: %s%n", emailHook.getName());
System.out.printf("Email Hook Description: %s%n", emailHook.getDescription());
System.out.printf("Email Hook External Link: %s%n", emailHook.getExternalLink());
System.out.printf("Email Hook Emails: %s%n", String.join(",", emailHook.getEmailsToAlert()));
} else if (notificationHookItem instanceof WebNotificationHook) {
WebNotificationHook webHook = (WebNotificationHook) notificationHookItem;
System.out.printf("Web Hook Id: %s%n", webHook.getId());
System.out.printf("Web Hook Name: %s%n", webHook.getName());
System.out.printf("Web Hook Description: %s%n", webHook.getDescription());
System.out.printf("Web Hook External Link: %s%n", webHook.getExternalLink());
System.out.printf("Web Hook Endpoint: %s%n", webHook.getEndpoint());
System.out.printf("Web Hook Headers: %s%n", webHook.getHttpHeaders());
}
}
// System.out.printf("Listing hooks%n");
// PagedIterable<NotificationHook> hooksIterable
// = advisorAdministrationClient.listHooks();
// for (NotificationHook notificationHookItem : hooksIterable) {
// if (notificationHookItem instanceof EmailNotificationHook) {
// EmailNotificationHook emailHook = (EmailNotificationHook) notificationHookItem;
// System.out.printf("Email Hook Id: %s%n", emailHook.getId());
// System.out.printf("Email Hook Name: %s%n", emailHook.getName());
// System.out.printf("Email Hook Description: %s%n", emailHook.getDescription());
// System.out.printf("Email Hook External Link: %s%n", emailHook.getExternalLink());
// System.out.printf("Email Hook Emails: %s%n", String.join(",", emailHook.getEmailsToAlert()));
// } else if (notificationHookItem instanceof WebNotificationHook) {
// WebNotificationHook webHook = (WebNotificationHook) notificationHookItem;
// System.out.printf("Web Hook Id: %s%n", webHook.getId());
// System.out.printf("Web Hook Name: %s%n", webHook.getName());
// System.out.printf("Web Hook Description: %s%n", webHook.getDescription());
// System.out.printf("Web Hook External Link: %s%n", webHook.getExternalLink());
// System.out.printf("Web Hook Endpoint: %s%n", webHook.getEndpoint());
// System.out.printf("Web Hook Headers: %s%n", webHook.getHttpHeaders());
// }
// }
}
}

0 comments on commit 3f9429a

Please sign in to comment.