Skip to content

Commit

Permalink
Merge pull request #3 from samvaity/add-list-alert-overload
Browse files Browse the repository at this point in the history
Add options overload API's to Metrics Advisor Clients
  • Loading branch information
anuchandy authored May 28, 2021
2 parents 83ad566 + 57e7b23 commit a3f4c7f
Show file tree
Hide file tree
Showing 13 changed files with 338 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,28 @@ public class MetricsAdvisorAsyncClient {
this.service = service;
}

/**
* List series definition for a metric.
*
* <p><strong>Code sample</strong></p>
* {@codesnippet com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient.listMetricSeriesDefinitions#String-OffsetDateTime}
*
* @param metricId metric unique id.
* @param activeSince the start time for querying series ingested after this time.
*
* @return A {@link PagedFlux} of the {@link MetricSeriesDefinition metric series definitions}.
* @throws IllegalArgumentException thrown if {@code metricId} fail the UUID format validation.
* @throws ErrorCodeException thrown if the request is rejected by server.
* @throws NullPointerException thrown if the {@code metricId} or {@code activeSince}
* is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<MetricSeriesDefinition> listMetricSeriesDefinitions(
String metricId,
OffsetDateTime activeSince) {
return listMetricSeriesDefinitions(metricId, activeSince);
}

/**
* List series definition for a metric.
*
Expand Down Expand Up @@ -375,6 +397,29 @@ private Mono<PagedResponse<String>> listMetricDimensionValuesNextPageAsync(Strin
null));
}

/**
* List the enrichment status for a metric.
*
* <p><strong>Code sample</strong></p>
* {@codesnippet com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient.listMetricEnrichmentStatus#String-OffsetDateTime-OffsetDateTime}
*
* @param metricId metric unique id.
* @param startTime The start time for querying the time series data.
* @param endTime The end time for querying the time series data.
*
* @return the list of enrichment status's for the specified metric.
* @throws IllegalArgumentException thrown if {@code metricId} fail the UUID format validation.
* @throws ErrorCodeException thrown if the request is rejected by server.
* @throws NullPointerException thrown if {@code metricId}, {@code startTime} and {@code endTime}
* is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<EnrichmentStatus> listMetricEnrichmentStatus(
String metricId,
OffsetDateTime startTime, OffsetDateTime endTime) {
return listMetricEnrichmentStatus(metricId, startTime, endTime, null);
}

/**
* List the enrichment status for a metric.
*
Expand Down Expand Up @@ -562,6 +607,30 @@ PagedFlux<MetricEnrichedSeriesData> listMetricEnrichedSeriesData(String detectio
null));
}

/**
* Fetch the anomalies identified by an anomaly detection configuration.
*
* <p><strong>Code sample</strong></p>
* {@codesnippet com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient.listAnomalies#String-OffsetDateTime-OffsetDateTime}
*
* @param detectionConfigurationId The anomaly detection configuration id.
* @param startTime The start time of the time range within which the anomalies were detected.
* @param endTime The end time of the time range within which the anomalies were detected.
*
* @return The anomalies.
* @throws IllegalArgumentException thrown if {@code detectionConfigurationId} does not conform
* to the UUID format specification
* or {@code options.filter} is used to set severity but either min or max severity is missing.
* @throws NullPointerException thrown if the {@code detectionConfigurationId} or {@code options}
* or {@code startTime} or {@code endTime} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<DataPointAnomaly> listAnomalies(
String detectionConfigurationId,
OffsetDateTime startTime, OffsetDateTime endTime) {
return listAnomalies(detectionConfigurationId, startTime, endTime, null);
}

/**
* Fetch the anomalies identified by an anomaly detection configuration.
*
Expand Down Expand Up @@ -681,6 +750,28 @@ private Mono<PagedResponse<DataPointAnomaly>> listAnomaliesForDetectionConfigNex
.map(response -> AnomalyTransforms.fromInnerPagedResponse(response));
}

/**
* Fetch the incidents identified by an anomaly detection configuration.
*
* <p><strong>Code sample</strong></p>
* {@codesnippet com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient.listIncidents#String-OffsetDateTime-OffsetDateTime}
*
* @param detectionConfigurationId The anomaly detection configuration id.
* @param startTime The start time of the time range within which the incidents were detected.
* @param endTime The end time of the time range within which the incidents were detected.
* @return The incidents.
* @throws IllegalArgumentException thrown if {@code detectionConfigurationId} does not conform
* to the UUID format specification.
* @throws NullPointerException thrown if the {@code detectionConfigurationId} or {@code options}
* or {@code startTime} or {@code endTime} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<AnomalyIncident> listIncidents(
String detectionConfigurationId,
OffsetDateTime startTime, OffsetDateTime endTime) {
return listIncidents(detectionConfigurationId, startTime, endTime, null);
}

/**
* Fetch the incidents identified by an anomaly detection configuration.
*
Expand Down Expand Up @@ -871,6 +962,30 @@ private Mono<PagedResponse<IncidentRootCause>> listIncidentRootCausesInternal(An
.map(res -> IncidentRootCauseTransforms.fromInnerResponse(res));
}

/**
* Fetch dimension values that have anomalies.
*
* <p><strong>Code sample</strong></p>
* {@codesnippet com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient.listAnomalyDimensionValues#String-String-OffsetDateTime-OffsetDateTime}
*
* @param detectionConfigurationId Identifies the configuration used to detect the anomalies.
* @param dimensionName The dimension name to retrieve the values for.
* @param startTime The start time of the time range within which the anomalies were identified.
* @param endTime The end time of the time range within which the anomalies were identified.
* @return The dimension values with anomalies.
* @throws IllegalArgumentException thrown if {@code detectionConfigurationId} does not conform
* to the UUID format specification.
* @throws NullPointerException thrown if the {@code detectionConfigurationId} or {@code dimensionName}
* or {@code options} or {@code startTime} or {@code endTime} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<String> listAnomalyDimensionValues(
String detectionConfigurationId,
String dimensionName,
OffsetDateTime startTime, OffsetDateTime endTime) {
return listAnomalyDimensionValues(detectionConfigurationId, dimensionName, startTime, endTime);
}

/**
* Fetch dimension values that have anomalies.
*
Expand Down Expand Up @@ -997,6 +1112,27 @@ private Mono<PagedResponse<String>> listAnomalyDimensionValuesNextPageAsync(
error));
}

/**
* Fetch the alerts triggered by an anomaly alert configuration.
*
* <p><strong>Code sample</strong></p>
* {@codesnippet com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient.listAlerts#String-OffsetDateTime-OffsetDateTime}
*
* @param alertConfigurationId The anomaly alert configuration id.
* @param startTime The start time of the time range within which the alerts were triggered.
* @param endTime The end time of the time range within which the alerts were triggered.
* @return The alerts.
* @throws IllegalArgumentException thrown if {@code alertConfigurationId} does not conform
* to the UUID format specification.
* @throws NullPointerException thrown if the {@code alertConfigurationId}
* or {@code startTime} or {@code endTime} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<AnomalyAlert> listAlerts(
String alertConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime) {
return listAlerts(alertConfigurationId, startTime, endTime, null);
}

/**
* Fetch the alerts triggered by an anomaly alert configuration.
*
Expand Down Expand Up @@ -1194,6 +1330,27 @@ private Mono<PagedResponse<DataPointAnomaly>> listAnomaliesForAlertNextPageAsync
.map(response -> AnomalyTransforms.fromInnerPagedResponse(response));
}


/**
* Fetch the incidents in an alert.
*
* <p><strong>Code sample</strong></p>
* {@codesnippet com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient.listIncidents#String-String-ListIncidentsAlertedOptions}
*
* @param alertConfigurationId The anomaly alert configuration id.
* @param alertId The alert id.
* @return The incidents.
* @throws IllegalArgumentException thrown if {@code alertConfigurationId} or {@code alertId} does not
* conform to the UUID format specification.
* @throws NullPointerException thrown if the {@code alertConfigurationId} or {@code alertId} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<AnomalyIncident> listIncidents(
String alertConfigurationId,
String alertId) {
return listIncidents(alertConfigurationId, alertId, null);
}

/**
* Fetch the incidents in an alert.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,29 +574,6 @@ public PagedIterable<DataPointAnomaly> listAnomalies(
context == null ? Context.NONE : context));
}

/**
* Fetch the incidents in an alert.
*
* <p><strong>Code sample</strong></p>
* {@codesnippet com.azure.ai.metricsadvisor.MetricsAdvisorClient.listIncidents#String-String-ListIncidentsAlertedOptions}
*
* @param alertConfigurationId The anomaly alert configuration id.
* @param alertId The alert id.
* @param options The additional parameters.
*
* @return The incidents.
* @throws IllegalArgumentException thrown if {@code alertConfigurationId} or {@code alertId} does not
* conform to the UUID format specification.
* @throws NullPointerException thrown if the {@code alertConfigurationId} or {@code alertId} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<AnomalyIncident> listIncidents(
String alertConfigurationId,
String alertId,
ListIncidentsAlertedOptions options) {
return listIncidents(alertConfigurationId, alertId, options, Context.NONE);
}

/**
* Fetch the incidents in an alert.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,23 @@ Mono<Response<Void>> deleteMetricAnomalyDetectionConfigWithResponse(String detec
.doOnError(error -> logger.warning("Failed to delete MetricAnomalyDetectionConfiguration", error));
}

/**
* Given a metric id, retrieve all anomaly detection configurations applied to it.
*
* <p><strong>Code sample</strong></p>
* {@codesnippet com.azure.ai.metricsadvisor.administration.MetricsAdvisorAdministrationAsyncClient.listMetricAnomalyDetectionConfigs#String}
*
* @param metricId The metric id.
* @return The anomaly detection configurations.
* @throws NullPointerException thrown if the {@code metricId} is null.
* @throws IllegalArgumentException If {@code metricId} does not conform to the UUID format specification.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<AnomalyDetectionConfiguration> listMetricAnomalyDetectionConfigs(
String metricId) {
return listMetricAnomalyDetectionConfigs(metricId);
}

/**
* Given a metric id, retrieve all anomaly detection configurations applied to it.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ public PagedIterable<DataFeed> listDataFeeds(ListDataFeedOptions options, Contex
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<DataFeedIngestionStatus> listDataFeedIngestionStatus(
String dataFeedId,
ListDataFeedIngestionOptions options) {
String dataFeedId, ListDataFeedIngestionOptions options) {
return listDataFeedIngestionStatus(dataFeedId, options, Context.NONE);
}

Expand Down Expand Up @@ -519,19 +518,17 @@ public Response<Void> deleteMetricAnomalyDetectionConfigWithResponse(
* Given a metric id, retrieve all anomaly detection configurations applied to it.
*
* <p><strong>Code sample</strong></p>
* {@codesnippet com.azure.ai.metricsadvisor.administration.MetricsAdvisorAdministrationClient.listMetricAnomalyDetectionConfigs#String-ListMetricAnomalyDetectionConfigsOptions}
* {@codesnippet com.azure.ai.metricsadvisor.administration.MetricsAdvisorAdministrationClient.listMetricAnomalyDetectionConfigs#String}
*
* @param metricId The metric id.
* @param options th e additional configurable options to specify when querying the result.
* @return The anomaly detection configurations.
* @throws NullPointerException thrown if the {@code metricId} is null.
* @throws IllegalArgumentException If {@code metricId} does not conform to the UUID format specification.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<AnomalyDetectionConfiguration> listMetricAnomalyDetectionConfigs(
String metricId,
ListMetricAnomalyDetectionConfigsOptions options) {
return new PagedIterable<>(client.listMetricAnomalyDetectionConfigs(metricId, options,
String metricId) {
return new PagedIterable<>(client.listMetricAnomalyDetectionConfigs(metricId, null,
Context.NONE));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.azure.ai.metricsadvisor.models.ListIncidentsAlertedOptions;
import com.azure.ai.metricsadvisor.models.MetricsAdvisorKeyCredential;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.util.Context;

/**
* Sample demonstrates how to list incidents in an alert.
Expand All @@ -27,7 +28,8 @@ public static void main(String[] args) {
PagedIterable<AnomalyIncident> incidentsIterable = advisorClient.listIncidents(
alertConfigurationId,
alertId,
options);
options,
Context.NONE);

for (AnomalyIncident anomalyIncident : incidentsIterable) {
System.out.printf("DataFeedMetric Id: %s%n", anomalyIncident.getMetricId());
Expand Down
Loading

0 comments on commit a3f4c7f

Please sign in to comment.