datadog_api/apis/
dashboards.rs1use crate::{
2 client::DatadogClient,
3 models::{Dashboard, DashboardListResponse},
4 Result,
5};
6
7pub struct DashboardsApi {
9 client: DatadogClient,
10}
11
12impl DashboardsApi {
13 #[must_use]
15 pub const fn new(client: DatadogClient) -> Self {
16 Self { client }
17 }
18
19 pub async fn list_dashboards(&self) -> Result<DashboardListResponse> {
20 self.client.get("/api/v1/dashboard").await
21 }
22
23 pub async fn get_dashboard(&self, dashboard_id: &str) -> Result<Dashboard> {
24 let endpoint = format!("/api/v1/dashboard/{}", dashboard_id);
25 self.client.get(&endpoint).await
26 }
27
28 pub async fn create_dashboard(&self, dashboard: &Dashboard) -> Result<Dashboard> {
29 self.client.post("/api/v1/dashboard", dashboard).await
30 }
31
32 pub async fn update_dashboard(
33 &self,
34 dashboard_id: &str,
35 dashboard: &Dashboard,
36 ) -> Result<Dashboard> {
37 let endpoint = format!("/api/v1/dashboard/{}", dashboard_id);
38 self.client.put(&endpoint, dashboard).await
39 }
40
41 pub async fn delete_dashboard(&self, dashboard_id: &str) -> Result<()> {
42 let endpoint = format!("/api/v1/dashboard/{}", dashboard_id);
43 self.client.delete(&endpoint).await
44 }
45}