@@ -254,6 +254,44 @@ impl GetSignalEntitiesOptionalParams {
254254 }
255255}
256256
257+ /// GetSingleEntityContextOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_single_entity_context`]
258+ #[non_exhaustive]
259+ #[derive(Clone, Default, Debug)]
260+ pub struct GetSingleEntityContextOptionalParams {
261+ /// The start of the time range to query, as an RFC3339 timestamp or a relative time (for example, `now-7d`).
262+ /// Defaults to `now-7d`. Ignored when `as_of` is set.
263+ pub from: Option<String>,
264+ /// The end of the time range to query, as an RFC3339 timestamp or a relative time (for example, `now`).
265+ /// Defaults to `now`. Ignored when `as_of` is set.
266+ pub to: Option<String>,
267+ /// A point in time at which to query the entity revisions, as an RFC3339 timestamp, a Unix timestamp
268+ /// (in seconds), or a relative time (for example, `now-1d`). When set, `from` and `to` are ignored.
269+ /// Cannot be combined with custom `from` / `to` values.
270+ pub as_of: Option<String>,
271+ }
272+
273+ impl GetSingleEntityContextOptionalParams {
274+ /// The start of the time range to query, as an RFC3339 timestamp or a relative time (for example, `now-7d`).
275+ /// Defaults to `now-7d`. Ignored when `as_of` is set.
276+ pub fn from(mut self, value: String) -> Self {
277+ self.from = Some(value);
278+ self
279+ }
280+ /// The end of the time range to query, as an RFC3339 timestamp or a relative time (for example, `now`).
281+ /// Defaults to `now`. Ignored when `as_of` is set.
282+ pub fn to(mut self, value: String) -> Self {
283+ self.to = Some(value);
284+ self
285+ }
286+ /// A point in time at which to query the entity revisions, as an RFC3339 timestamp, a Unix timestamp
287+ /// (in seconds), or a relative time (for example, `now-1d`). When set, `from` and `to` are ignored.
288+ /// Cannot be combined with custom `from` / `to` values.
289+ pub fn as_of(mut self, value: String) -> Self {
290+ self.as_of = Some(value);
291+ self
292+ }
293+ }
294+
257295/// GetStaticAnalysisRulesetOptionalParams is a struct for passing parameters to the method [`SecurityMonitoringAPI::get_static_analysis_ruleset`]
258296#[non_exhaustive]
259297#[derive(Clone, Default, Debug)]
@@ -2048,6 +2086,14 @@ pub enum GetSignalNotificationRulesError {
20482086 UnknownValue(serde_json::Value),
20492087}
20502088
2089+ /// GetSingleEntityContextError is a struct for typed errors of method [`SecurityMonitoringAPI::get_single_entity_context`]
2090+ #[derive(Debug, Clone, Serialize, Deserialize)]
2091+ #[serde(untagged)]
2092+ pub enum GetSingleEntityContextError {
2093+ APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
2094+ UnknownValue(serde_json::Value),
2095+ }
2096+
20512097/// GetStaticAnalysisDefaultRulesetsError is a struct for typed errors of method [`SecurityMonitoringAPI::get_static_analysis_default_rulesets`]
20522098#[derive(Debug, Clone, Serialize, Deserialize)]
20532099#[serde(untagged)]
@@ -13076,6 +13122,151 @@ impl SecurityMonitoringAPI {
1307613122 }
1307713123 }
1307813124
13125+ /// Get a single entity from the Cloud SIEM entity context store by its identifier, returning the historical
13126+ /// revisions of the entity in the requested time range. The endpoint can either return revisions across an
13127+ /// interval (`from` / `to`) or the snapshot of the entity at a single point in time (`as_of`); the two modes
13128+ /// are mutually exclusive.
13129+ pub async fn get_single_entity_context(
13130+ &self,
13131+ id: String,
13132+ params: GetSingleEntityContextOptionalParams,
13133+ ) -> Result<
13134+ crate::datadogV2::model::SingleEntityContextResponse,
13135+ datadog::Error<GetSingleEntityContextError>,
13136+ > {
13137+ match self
13138+ .get_single_entity_context_with_http_info(id, params)
13139+ .await
13140+ {
13141+ Ok(response_content) => {
13142+ if let Some(e) = response_content.entity {
13143+ Ok(e)
13144+ } else {
13145+ Err(datadog::Error::Serde(serde::de::Error::custom(
13146+ "response content was None",
13147+ )))
13148+ }
13149+ }
13150+ Err(err) => Err(err),
13151+ }
13152+ }
13153+
13154+ /// Get a single entity from the Cloud SIEM entity context store by its identifier, returning the historical
13155+ /// revisions of the entity in the requested time range. The endpoint can either return revisions across an
13156+ /// interval (`from` / `to`) or the snapshot of the entity at a single point in time (`as_of`); the two modes
13157+ /// are mutually exclusive.
13158+ pub async fn get_single_entity_context_with_http_info(
13159+ &self,
13160+ id: String,
13161+ params: GetSingleEntityContextOptionalParams,
13162+ ) -> Result<
13163+ datadog::ResponseContent<crate::datadogV2::model::SingleEntityContextResponse>,
13164+ datadog::Error<GetSingleEntityContextError>,
13165+ > {
13166+ let local_configuration = &self.config;
13167+ let operation_id = "v2.get_single_entity_context";
13168+ if local_configuration.is_unstable_operation_enabled(operation_id) {
13169+ warn!("Using unstable operation {operation_id}");
13170+ } else {
13171+ let local_error = datadog::UnstableOperationDisabledError {
13172+ msg: "Operation 'v2.get_single_entity_context' is not enabled".to_string(),
13173+ };
13174+ return Err(datadog::Error::UnstableOperationDisabledError(local_error));
13175+ }
13176+
13177+ // unbox and build optional parameters
13178+ let from = params.from;
13179+ let to = params.to;
13180+ let as_of = params.as_of;
13181+
13182+ let local_client = &self.client;
13183+
13184+ let local_uri_str = format!(
13185+ "{}/api/v2/security_monitoring/entity_context/{id}",
13186+ local_configuration.get_operation_host(operation_id),
13187+ id = datadog::urlencode(id)
13188+ );
13189+ let mut local_req_builder =
13190+ local_client.request(reqwest::Method::GET, local_uri_str.as_str());
13191+
13192+ if let Some(ref local_query_param) = from {
13193+ local_req_builder =
13194+ local_req_builder.query(&[("from", &local_query_param.to_string())]);
13195+ };
13196+ if let Some(ref local_query_param) = to {
13197+ local_req_builder = local_req_builder.query(&[("to", &local_query_param.to_string())]);
13198+ };
13199+ if let Some(ref local_query_param) = as_of {
13200+ local_req_builder =
13201+ local_req_builder.query(&[("as_of", &local_query_param.to_string())]);
13202+ };
13203+
13204+ // build headers
13205+ let mut headers = HeaderMap::new();
13206+ headers.insert("Accept", HeaderValue::from_static("application/json"));
13207+
13208+ // build user agent
13209+ match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
13210+ Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
13211+ Err(e) => {
13212+ log::warn!("Failed to parse user agent header: {e}, falling back to default");
13213+ headers.insert(
13214+ reqwest::header::USER_AGENT,
13215+ HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
13216+ )
13217+ }
13218+ };
13219+
13220+ // build auth
13221+ if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
13222+ headers.insert(
13223+ "DD-API-KEY",
13224+ HeaderValue::from_str(local_key.key.as_str())
13225+ .expect("failed to parse DD-API-KEY header"),
13226+ );
13227+ };
13228+ if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
13229+ headers.insert(
13230+ "DD-APPLICATION-KEY",
13231+ HeaderValue::from_str(local_key.key.as_str())
13232+ .expect("failed to parse DD-APPLICATION-KEY header"),
13233+ );
13234+ };
13235+
13236+ local_req_builder = local_req_builder.headers(headers);
13237+ let local_req = local_req_builder.build()?;
13238+ log::debug!("request content: {:?}", local_req.body());
13239+ let local_resp = local_client.execute(local_req).await?;
13240+
13241+ let local_status = local_resp.status();
13242+ let local_content = local_resp.text().await?;
13243+ log::debug!("response content: {}", local_content);
13244+
13245+ if !local_status.is_client_error() && !local_status.is_server_error() {
13246+ match serde_json::from_str::<crate::datadogV2::model::SingleEntityContextResponse>(
13247+ &local_content,
13248+ ) {
13249+ Ok(e) => {
13250+ return Ok(datadog::ResponseContent {
13251+ status: local_status,
13252+ content: local_content,
13253+ entity: Some(e),
13254+ })
13255+ }
13256+ Err(e) => return Err(datadog::Error::Serde(e)),
13257+ };
13258+ } else {
13259+ let local_entity: Option<GetSingleEntityContextError> =
13260+ serde_json::from_str(&local_content).ok();
13261+ let local_error = datadog::ResponseContent {
13262+ status: local_status,
13263+ content: local_content,
13264+ entity: local_entity,
13265+ };
13266+ Err(datadog::Error::ResponseError(local_error))
13267+ }
13268+ }
13269+
1307913270 /// Get the default SAST ruleset names for a given programming language.
1308013271 pub async fn get_static_analysis_default_rulesets(
1308113272 &self,
0 commit comments