#[cfg(any(test, feature = "test-support"))]
use crate::mock_client::{ExpectationBuilder, MockClient};
#[cfg(any(test, feature = "test-support"))]
pub trait LoganalyticsMockHelpers {
fn expect_list_workspaces(&mut self, subscription_id: &str) -> ExpectationBuilder<'_>;
fn expect_get_workspace(
&mut self,
subscription_id: &str,
resource_group_name: &str,
workspace_name: &str,
) -> ExpectationBuilder<'_>;
fn expect_create_workspace(
&mut self,
subscription_id: &str,
resource_group_name: &str,
workspace_name: &str,
) -> ExpectationBuilder<'_>;
fn expect_delete_workspace(
&mut self,
subscription_id: &str,
resource_group_name: &str,
workspace_name: &str,
) -> ExpectationBuilder<'_>;
fn expect_query_logs(
&mut self,
subscription_id: &str,
resource_group_name: &str,
workspace_name: &str,
) -> ExpectationBuilder<'_>;
fn expect_list_saved_searches(
&mut self,
subscription_id: &str,
resource_group_name: &str,
workspace_name: &str,
) -> ExpectationBuilder<'_>;
}
#[cfg(any(test, feature = "test-support"))]
impl LoganalyticsMockHelpers for MockClient {
fn expect_list_workspaces(
&mut self,
subscription_id: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/providers/Microsoft.OperationalInsights/workspaces"
);
self.expect_get(&path)
}
fn expect_get_workspace(
&mut self,
subscription_id: &str,
resource_group_name: &str,
workspace_name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/resourcegroups/{resource_group_name}/providers/Microsoft.OperationalInsights/workspaces/{workspace_name}"
);
self.expect_get(&path)
}
fn expect_create_workspace(
&mut self,
subscription_id: &str,
resource_group_name: &str,
workspace_name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/resourcegroups/{resource_group_name}/providers/Microsoft.OperationalInsights/workspaces/{workspace_name}"
);
self.expect_put(&path)
}
fn expect_delete_workspace(
&mut self,
subscription_id: &str,
resource_group_name: &str,
workspace_name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/resourcegroups/{resource_group_name}/providers/Microsoft.OperationalInsights/workspaces/{workspace_name}"
);
self.expect_delete(&path)
}
fn expect_query_logs(
&mut self,
subscription_id: &str,
resource_group_name: &str,
workspace_name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.OperationalInsights/workspaces/{workspace_name}/query"
);
self.expect_post(&path)
}
fn expect_list_saved_searches(
&mut self,
subscription_id: &str,
resource_group_name: &str,
workspace_name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.OperationalInsights/workspaces/{workspace_name}/savedSearches"
);
self.expect_get(&path)
}
}