diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackAsyncSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackAsyncSample.java index 3f11effc70012..8a469cf987a1e 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackAsyncSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackAsyncSample.java @@ -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; @@ -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; @@ -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 createdFeedbackMono diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackSample.java index 705f4a156e8e0..618e4b0bf9323 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackSample.java @@ -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; @@ -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; @@ -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 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricsAdvisorAsyncClientJavaDocCodeSnippets.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricsAdvisorAsyncClientJavaDocCodeSnippets.java index 623229f9fe361..8b2db9dc8bdaf 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricsAdvisorAsyncClientJavaDocCodeSnippets.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricsAdvisorAsyncClientJavaDocCodeSnippets.java @@ -386,7 +386,8 @@ public void listIncidentsForDetectionConfigWithOptions() { .setMaxPageSize(1000); PagedFlux 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()); @@ -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); }) diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/DatafeedAsyncSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/DatafeedAsyncSample.java index e33629591ac02..30f85b24973e4 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/DatafeedAsyncSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/DatafeedAsyncSample.java @@ -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())); }); }); diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/DatafeedSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/DatafeedSample.java index 94a165b4bfd55..400770a730e1c 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/DatafeedSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/DatafeedSample.java @@ -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()); diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/HookAsyncSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/HookAsyncSample.java index db08b203b05ff..0f7a5979f21f6 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/HookAsyncSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/HookAsyncSample.java @@ -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. diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/HookSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/HookSample.java index 729cf3c6e6c63..567b8f2c5beb1 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/HookSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/HookSample.java @@ -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"); @@ -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()); @@ -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 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 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()); + // } + // } } }