datadog_api/apis/
infrastructure.rs1use crate::{
2 client::DatadogClient,
3 models::{HostsResponse, TagsResponse},
4 Result,
5};
6use serde::Serialize;
7
8pub struct InfrastructureApi {
10 client: DatadogClient,
11}
12
13impl InfrastructureApi {
14 #[must_use]
16 pub const fn new(client: DatadogClient) -> Self {
17 Self { client }
18 }
19
20 pub async fn list_hosts(&self) -> Result<HostsResponse> {
21 self.client.get("/api/v1/hosts").await
22 }
23
24 pub async fn get_tags(&self, source: Option<&str>) -> Result<TagsResponse> {
25 if let Some(source) = source {
26 #[derive(Serialize)]
27 struct QueryParams<'a> {
28 source: &'a str,
29 }
30
31 let params = QueryParams { source };
32
33 self.client
34 .get_with_query("/api/v1/tags/hosts", ¶ms)
35 .await
36 } else {
37 self.client.get("/api/v1/tags/hosts").await
38 }
39 }
40}