Skip to content

Commit ebadaa6

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 0d1729a of spec repo
1 parent 37d739b commit ebadaa6

18 files changed

+2637
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 418 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Get detailed information about an agent returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_fleet_automation::FleetAutomationAPI;
4+
5+
#[tokio::main]
6+
async fn main() {
7+
let mut configuration = datadog::Configuration::new();
8+
configuration.set_unstable_operation_enabled("v2.GetFleetAgentInfo", true);
9+
let api = FleetAutomationAPI::with_config(configuration);
10+
let resp = api.get_fleet_agent_info("agent_key".to_string()).await;
11+
if let Ok(value) = resp {
12+
println!("{:#?}", value);
13+
} else {
14+
println!("{:#?}", resp.unwrap_err());
15+
}
16+
}

src/datadog/configuration.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ impl Default for Configuration {
127127
("v2.create_fleet_deployment_upgrade".to_owned(), false),
128128
("v2.create_fleet_schedule".to_owned(), false),
129129
("v2.delete_fleet_schedule".to_owned(), false),
130+
("v2.get_fleet_agent_info".to_owned(), false),
130131
("v2.get_fleet_deployment".to_owned(), false),
131132
("v2.get_fleet_schedule".to_owned(), false),
132133
("v2.list_fleet_agent_versions".to_owned(), false),

src/datadogV2/api/api_fleet_automation.rs

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ pub enum DeleteFleetScheduleError {
9797
UnknownValue(serde_json::Value),
9898
}
9999

100+
/// GetFleetAgentInfoError is a struct for typed errors of method [`FleetAutomationAPI::get_fleet_agent_info`]
101+
#[derive(Debug, Clone, Serialize, Deserialize)]
102+
#[serde(untagged)]
103+
pub enum GetFleetAgentInfoError {
104+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
105+
UnknownValue(serde_json::Value),
106+
}
107+
100108
/// GetFleetDeploymentError is a struct for typed errors of method [`FleetAutomationAPI::get_fleet_deployment`]
101109
#[derive(Debug, Clone, Serialize, Deserialize)]
102110
#[serde(untagged)]
@@ -1002,6 +1010,133 @@ impl FleetAutomationAPI {
10021010
}
10031011
}
10041012

1013+
/// Retrieve detailed information about a specific Datadog Agent.
1014+
/// This endpoint returns comprehensive information about an agent including:
1015+
/// - Agent details and metadata
1016+
/// - Configured integrations organized by status (working, warning, error, missing)
1017+
/// - Detected integrations
1018+
/// - Configuration files and layers
1019+
pub async fn get_fleet_agent_info(
1020+
&self,
1021+
agent_key: String,
1022+
) -> Result<
1023+
crate::datadogV2::model::FleetAgentInfoResponse,
1024+
datadog::Error<GetFleetAgentInfoError>,
1025+
> {
1026+
match self.get_fleet_agent_info_with_http_info(agent_key).await {
1027+
Ok(response_content) => {
1028+
if let Some(e) = response_content.entity {
1029+
Ok(e)
1030+
} else {
1031+
Err(datadog::Error::Serde(serde::de::Error::custom(
1032+
"response content was None",
1033+
)))
1034+
}
1035+
}
1036+
Err(err) => Err(err),
1037+
}
1038+
}
1039+
1040+
/// Retrieve detailed information about a specific Datadog Agent.
1041+
/// This endpoint returns comprehensive information about an agent including:
1042+
/// - Agent details and metadata
1043+
/// - Configured integrations organized by status (working, warning, error, missing)
1044+
/// - Detected integrations
1045+
/// - Configuration files and layers
1046+
pub async fn get_fleet_agent_info_with_http_info(
1047+
&self,
1048+
agent_key: String,
1049+
) -> Result<
1050+
datadog::ResponseContent<crate::datadogV2::model::FleetAgentInfoResponse>,
1051+
datadog::Error<GetFleetAgentInfoError>,
1052+
> {
1053+
let local_configuration = &self.config;
1054+
let operation_id = "v2.get_fleet_agent_info";
1055+
if local_configuration.is_unstable_operation_enabled(operation_id) {
1056+
warn!("Using unstable operation {operation_id}");
1057+
} else {
1058+
let local_error = datadog::UnstableOperationDisabledError {
1059+
msg: "Operation 'v2.get_fleet_agent_info' is not enabled".to_string(),
1060+
};
1061+
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
1062+
}
1063+
1064+
let local_client = &self.client;
1065+
1066+
let local_uri_str = format!(
1067+
"{}/api/unstable/fleet/agents/{agent_key}",
1068+
local_configuration.get_operation_host(operation_id),
1069+
agent_key = datadog::urlencode(agent_key)
1070+
);
1071+
let mut local_req_builder =
1072+
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1073+
1074+
// build headers
1075+
let mut headers = HeaderMap::new();
1076+
headers.insert("Accept", HeaderValue::from_static("application/json"));
1077+
1078+
// build user agent
1079+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1080+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1081+
Err(e) => {
1082+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
1083+
headers.insert(
1084+
reqwest::header::USER_AGENT,
1085+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1086+
)
1087+
}
1088+
};
1089+
1090+
// build auth
1091+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1092+
headers.insert(
1093+
"DD-API-KEY",
1094+
HeaderValue::from_str(local_key.key.as_str())
1095+
.expect("failed to parse DD-API-KEY header"),
1096+
);
1097+
};
1098+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1099+
headers.insert(
1100+
"DD-APPLICATION-KEY",
1101+
HeaderValue::from_str(local_key.key.as_str())
1102+
.expect("failed to parse DD-APPLICATION-KEY header"),
1103+
);
1104+
};
1105+
1106+
local_req_builder = local_req_builder.headers(headers);
1107+
let local_req = local_req_builder.build()?;
1108+
log::debug!("request content: {:?}", local_req.body());
1109+
let local_resp = local_client.execute(local_req).await?;
1110+
1111+
let local_status = local_resp.status();
1112+
let local_content = local_resp.text().await?;
1113+
log::debug!("response content: {}", local_content);
1114+
1115+
if !local_status.is_client_error() && !local_status.is_server_error() {
1116+
match serde_json::from_str::<crate::datadogV2::model::FleetAgentInfoResponse>(
1117+
&local_content,
1118+
) {
1119+
Ok(e) => {
1120+
return Ok(datadog::ResponseContent {
1121+
status: local_status,
1122+
content: local_content,
1123+
entity: Some(e),
1124+
})
1125+
}
1126+
Err(e) => return Err(datadog::Error::Serde(e)),
1127+
};
1128+
} else {
1129+
let local_entity: Option<GetFleetAgentInfoError> =
1130+
serde_json::from_str(&local_content).ok();
1131+
let local_error = datadog::ResponseContent {
1132+
status: local_status,
1133+
content: local_content,
1134+
entity: local_entity,
1135+
};
1136+
Err(datadog::Error::ResponseError(local_error))
1137+
}
1138+
}
1139+
10051140
/// Retrieve detailed information about a specific deployment using its unique identifier.
10061141
/// This endpoint returns comprehensive information about a deployment, including:
10071142
/// - Deployment metadata (ID, type, filter query)

src/datadogV2/model/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@ pub mod model_fleet_agent_version_resource_type;
1212
pub use self::model_fleet_agent_version_resource_type::FleetAgentVersionResourceType;
1313
pub mod model_api_error_response;
1414
pub use self::model_api_error_response::APIErrorResponse;
15+
pub mod model_fleet_agent_info_response;
16+
pub use self::model_fleet_agent_info_response::FleetAgentInfoResponse;
17+
pub mod model_fleet_agent_info;
18+
pub use self::model_fleet_agent_info::FleetAgentInfo;
19+
pub mod model_fleet_agent_info_attributes;
20+
pub use self::model_fleet_agent_info_attributes::FleetAgentInfoAttributes;
21+
pub mod model_fleet_agent_info_details;
22+
pub use self::model_fleet_agent_info_details::FleetAgentInfoDetails;
23+
pub mod model_fleet_configuration_layer;
24+
pub use self::model_fleet_configuration_layer::FleetConfigurationLayer;
25+
pub mod model_fleet_detected_integration;
26+
pub use self::model_fleet_detected_integration::FleetDetectedIntegration;
27+
pub mod model_fleet_integrations_by_status;
28+
pub use self::model_fleet_integrations_by_status::FleetIntegrationsByStatus;
29+
pub mod model_fleet_configuration_file;
30+
pub use self::model_fleet_configuration_file::FleetConfigurationFile;
31+
pub mod model_fleet_integration_details;
32+
pub use self::model_fleet_integration_details::FleetIntegrationDetails;
33+
pub mod model_fleet_agent_info_resource_type;
34+
pub use self::model_fleet_agent_info_resource_type::FleetAgentInfoResourceType;
1535
pub mod model_fleet_deployments_response;
1636
pub use self::model_fleet_deployments_response::FleetDeploymentsResponse;
1737
pub mod model_fleet_deployment;
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
use serde::de::{Error, MapAccess, Visitor};
5+
use serde::{Deserialize, Deserializer, Serialize};
6+
use serde_with::skip_serializing_none;
7+
use std::fmt::{self, Formatter};
8+
9+
/// Represents detailed information about a specific Datadog Agent.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct FleetAgentInfo {
14+
/// Attributes for agent information.
15+
#[serde(rename = "attributes")]
16+
pub attributes: crate::datadogV2::model::FleetAgentInfoAttributes,
17+
/// The unique agent key identifier.
18+
#[serde(rename = "id")]
19+
pub id: String,
20+
/// The type of Agent info resource.
21+
#[serde(rename = "type")]
22+
pub type_: crate::datadogV2::model::FleetAgentInfoResourceType,
23+
#[serde(flatten)]
24+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
25+
#[serde(skip)]
26+
#[serde(default)]
27+
pub(crate) _unparsed: bool,
28+
}
29+
30+
impl FleetAgentInfo {
31+
pub fn new(
32+
attributes: crate::datadogV2::model::FleetAgentInfoAttributes,
33+
id: String,
34+
type_: crate::datadogV2::model::FleetAgentInfoResourceType,
35+
) -> FleetAgentInfo {
36+
FleetAgentInfo {
37+
attributes,
38+
id,
39+
type_,
40+
additional_properties: std::collections::BTreeMap::new(),
41+
_unparsed: false,
42+
}
43+
}
44+
45+
pub fn additional_properties(
46+
mut self,
47+
value: std::collections::BTreeMap<String, serde_json::Value>,
48+
) -> Self {
49+
self.additional_properties = value;
50+
self
51+
}
52+
}
53+
54+
impl<'de> Deserialize<'de> for FleetAgentInfo {
55+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
56+
where
57+
D: Deserializer<'de>,
58+
{
59+
struct FleetAgentInfoVisitor;
60+
impl<'a> Visitor<'a> for FleetAgentInfoVisitor {
61+
type Value = FleetAgentInfo;
62+
63+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
64+
f.write_str("a mapping")
65+
}
66+
67+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
68+
where
69+
M: MapAccess<'a>,
70+
{
71+
let mut attributes: Option<crate::datadogV2::model::FleetAgentInfoAttributes> =
72+
None;
73+
let mut id: Option<String> = None;
74+
let mut type_: Option<crate::datadogV2::model::FleetAgentInfoResourceType> = None;
75+
let mut additional_properties: std::collections::BTreeMap<
76+
String,
77+
serde_json::Value,
78+
> = std::collections::BTreeMap::new();
79+
let mut _unparsed = false;
80+
81+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
82+
match k.as_str() {
83+
"attributes" => {
84+
attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
85+
}
86+
"id" => {
87+
id = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
88+
}
89+
"type" => {
90+
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
91+
if let Some(ref _type_) = type_ {
92+
match _type_ {
93+
crate::datadogV2::model::FleetAgentInfoResourceType::UnparsedObject(_type_) => {
94+
_unparsed = true;
95+
},
96+
_ => {}
97+
}
98+
}
99+
}
100+
&_ => {
101+
if let Ok(value) = serde_json::from_value(v.clone()) {
102+
additional_properties.insert(k, value);
103+
}
104+
}
105+
}
106+
}
107+
let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?;
108+
let id = id.ok_or_else(|| M::Error::missing_field("id"))?;
109+
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;
110+
111+
let content = FleetAgentInfo {
112+
attributes,
113+
id,
114+
type_,
115+
additional_properties,
116+
_unparsed,
117+
};
118+
119+
Ok(content)
120+
}
121+
}
122+
123+
deserializer.deserialize_any(FleetAgentInfoVisitor)
124+
}
125+
}

0 commit comments

Comments
 (0)