#[cfg(any(test, feature = "test-support"))]
use crate::mock_client::{ExpectationBuilder, MockClient};
#[cfg(any(test, feature = "test-support"))]
pub trait MonitorMockHelpers {
fn expect_list_metric_definitions(&mut self, resource_uri: &str) -> ExpectationBuilder<'_>;
fn expect_get_metrics(&mut self, resource_uri: &str) -> ExpectationBuilder<'_>;
fn expect_list_alert_rules(
&mut self,
subscription_id: &str,
resource_group_name: &str,
) -> ExpectationBuilder<'_>;
fn expect_get_alert_rule(
&mut self,
subscription_id: &str,
resource_group_name: &str,
rule_name: &str,
) -> ExpectationBuilder<'_>;
fn expect_create_alert_rule(
&mut self,
subscription_id: &str,
resource_group_name: &str,
rule_name: &str,
) -> ExpectationBuilder<'_>;
fn expect_delete_alert_rule(
&mut self,
subscription_id: &str,
resource_group_name: &str,
rule_name: &str,
) -> ExpectationBuilder<'_>;
fn expect_list_activity_logs(&mut self, subscription_id: &str) -> ExpectationBuilder<'_>;
}
#[cfg(any(test, feature = "test-support"))]
impl MonitorMockHelpers for MockClient {
fn expect_list_metric_definitions(
&mut self,
resource_uri: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/{resource_uri}/providers/microsoft.insights/metricDefinitions");
self.expect_get(&path)
}
fn expect_get_metrics(
&mut self,
resource_uri: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/{resource_uri}/providers/microsoft.insights/metrics");
self.expect_get(&path)
}
fn expect_list_alert_rules(
&mut self,
subscription_id: &str,
resource_group_name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Insights/metricAlerts"
);
self.expect_get(&path)
}
fn expect_get_alert_rule(
&mut self,
subscription_id: &str,
resource_group_name: &str,
rule_name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Insights/metricAlerts/{rule_name}"
);
self.expect_get(&path)
}
fn expect_create_alert_rule(
&mut self,
subscription_id: &str,
resource_group_name: &str,
rule_name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Insights/metricAlerts/{rule_name}"
);
self.expect_put(&path)
}
fn expect_delete_alert_rule(
&mut self,
subscription_id: &str,
resource_group_name: &str,
rule_name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Insights/metricAlerts/{rule_name}"
);
self.expect_delete(&path)
}
fn expect_list_activity_logs(
&mut self,
subscription_id: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/providers/microsoft.insights/eventtypes/management/values"
);
self.expect_get(&path)
}
}