Skip to content

Commit 76e1c48

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Exposing set action on Terraform V2 (#662)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 165184c commit 76e1c48

File tree

76 files changed

+1070
-202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1070
-202
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2025-06-03 09:24:13.740178",
8-
"spec_repo_commit": "5906d277"
7+
"regenerated": "2025-06-04 09:10:39.421656",
8+
"spec_repo_commit": "6c99bb98"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-06-03 09:24:13.756322",
13-
"spec_repo_commit": "5906d277"
12+
"regenerated": "2025-06-04 09:10:39.437589",
13+
"spec_repo_commit": "6c99bb98"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7526,6 +7526,50 @@ components:
75267526
type: string
75277527
kill:
75287528
$ref: '#/components/schemas/CloudWorkloadSecurityAgentRuleKill'
7529+
metadata:
7530+
$ref: '#/components/schemas/CloudWorkloadSecurityAgentRuleActionMetadata'
7531+
set:
7532+
$ref: '#/components/schemas/CloudWorkloadSecurityAgentRuleActionSet'
7533+
type: object
7534+
CloudWorkloadSecurityAgentRuleActionMetadata:
7535+
description: The metadata action applied on the scope matching the rule
7536+
properties:
7537+
image_tag:
7538+
description: The image tag of the metadata action
7539+
type: string
7540+
service:
7541+
description: The service of the metadata action
7542+
type: string
7543+
short_image:
7544+
description: The short image of the metadata action
7545+
type: string
7546+
type: object
7547+
CloudWorkloadSecurityAgentRuleActionSet:
7548+
description: The set action applied on the scope matching the rule
7549+
properties:
7550+
append:
7551+
description: Whether the value should be appended to the field
7552+
type: boolean
7553+
field:
7554+
description: The field of the set action
7555+
type: string
7556+
name:
7557+
description: The name of the set action
7558+
type: string
7559+
scope:
7560+
description: The scope of the set action
7561+
type: string
7562+
size:
7563+
description: The size of the set action
7564+
format: int64
7565+
type: integer
7566+
ttl:
7567+
description: The time to live of the set action
7568+
format: int64
7569+
type: integer
7570+
value:
7571+
description: The value of the set action
7572+
type: string
75297573
type: object
75307574
CloudWorkloadSecurityAgentRuleActions:
75317575
description: The array of actions the rule can perform if triggered
@@ -7541,6 +7585,11 @@ components:
75417585
agentConstraint:
75427586
description: The version of the Agent
75437587
type: string
7588+
blocking:
7589+
description: The blocking policies that the rule belongs to
7590+
items:
7591+
type: string
7592+
type: array
75447593
category:
75457594
description: The category of the Agent rule
75467595
example: Process Activity
@@ -7564,6 +7613,11 @@ components:
75647613
description: The description of the Agent rule
75657614
example: My Agent rule
75667615
type: string
7616+
disabled:
7617+
description: The disabled policies that the rule belongs to
7618+
items:
7619+
type: string
7620+
type: array
75677621
enabled:
75687622
description: Whether the Agent rule is enabled
75697623
example: true
@@ -7577,6 +7631,11 @@ components:
75777631
items:
75787632
type: string
75797633
type: array
7634+
monitoring:
7635+
description: The monitoring policies that the rule belongs to
7636+
items:
7637+
type: string
7638+
type: array
75807639
name:
75817640
description: The name of the Agent rule
75827641
example: my_agent_rule
@@ -7611,10 +7670,22 @@ components:
76117670
CloudWorkloadSecurityAgentRuleCreateAttributes:
76127671
description: Create a new Cloud Workload Security Agent rule.
76137672
properties:
7673+
actions:
7674+
$ref: '#/components/schemas/CloudWorkloadSecurityAgentRuleActions'
7675+
blocking:
7676+
description: The blocking policies that the rule belongs to
7677+
items:
7678+
type: string
7679+
type: array
76147680
description:
76157681
description: The description of the Agent rule.
76167682
example: My Agent rule
76177683
type: string
7684+
disabled:
7685+
description: The disabled policies that the rule belongs to
7686+
items:
7687+
type: string
7688+
type: array
76187689
enabled:
76197690
description: Whether the Agent rule is enabled
76207691
example: true
@@ -7628,6 +7699,11 @@ components:
76287699
items:
76297700
type: string
76307701
type: array
7702+
monitoring:
7703+
description: The monitoring policies that the rule belongs to
7704+
items:
7705+
type: string
7706+
type: array
76317707
name:
76327708
description: The name of the Agent rule.
76337709
example: my_agent_rule
@@ -7718,10 +7794,22 @@ components:
77187794
CloudWorkloadSecurityAgentRuleUpdateAttributes:
77197795
description: Update an existing Cloud Workload Security Agent rule
77207796
properties:
7797+
actions:
7798+
$ref: '#/components/schemas/CloudWorkloadSecurityAgentRuleActions'
7799+
blocking:
7800+
description: The blocking policies that the rule belongs to
7801+
items:
7802+
type: string
7803+
type: array
77217804
description:
77227805
description: The description of the Agent rule
77237806
example: My Agent rule
77247807
type: string
7808+
disabled:
7809+
description: The disabled policies that the rule belongs to
7810+
items:
7811+
type: string
7812+
type: array
77257813
enabled:
77267814
description: Whether the Agent rule is enabled
77277815
example: true
@@ -7730,6 +7818,11 @@ components:
77307818
description: The SECL expression of the Agent rule
77317819
example: exec.file.name == "sh"
77327820
type: string
7821+
monitoring:
7822+
description: The monitoring policies that the rule belongs to
7823+
items:
7824+
type: string
7825+
type: array
77337826
policy_id:
77347827
description: The ID of the policy where the Agent rule is saved
77357828
example: a8c8e364-6556-434d-b798-a4c23de29c0b
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Create a Workload Protection agent rule with set action returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_csm_threats::CSMThreatsAPI;
4+
use datadog_api_client::datadogV2::model::CloudWorkloadSecurityAgentRuleAction;
5+
use datadog_api_client::datadogV2::model::CloudWorkloadSecurityAgentRuleActionSet;
6+
use datadog_api_client::datadogV2::model::CloudWorkloadSecurityAgentRuleCreateAttributes;
7+
use datadog_api_client::datadogV2::model::CloudWorkloadSecurityAgentRuleCreateData;
8+
use datadog_api_client::datadogV2::model::CloudWorkloadSecurityAgentRuleCreateRequest;
9+
use datadog_api_client::datadogV2::model::CloudWorkloadSecurityAgentRuleType;
10+
11+
#[tokio::main]
12+
async fn main() {
13+
// there is a valid "policy_rc" in the system
14+
let policy_data_id = std::env::var("POLICY_DATA_ID").unwrap();
15+
let body = CloudWorkloadSecurityAgentRuleCreateRequest::new(
16+
CloudWorkloadSecurityAgentRuleCreateData::new(
17+
CloudWorkloadSecurityAgentRuleCreateAttributes::new(
18+
r#"exec.file.name == "sh""#.to_string(),
19+
"examplecsmthreat".to_string(),
20+
)
21+
.actions(Some(vec![CloudWorkloadSecurityAgentRuleAction::new().set(
22+
CloudWorkloadSecurityAgentRuleActionSet::new()
23+
.name("test_set".to_string())
24+
.scope("process".to_string())
25+
.value("test_value".to_string()),
26+
)]))
27+
.description("My Agent rule with set action".to_string())
28+
.enabled(true)
29+
.filters(vec![])
30+
.policy_id(policy_data_id.clone())
31+
.product_tags(vec![]),
32+
CloudWorkloadSecurityAgentRuleType::AGENT_RULE,
33+
),
34+
);
35+
let configuration = datadog::Configuration::new();
36+
let api = CSMThreatsAPI::with_config(configuration);
37+
let resp = api.create_csm_threats_agent_rule(body).await;
38+
if let Ok(value) = resp {
39+
println!("{:#?}", value);
40+
} else {
41+
println!("{:#?}", resp.unwrap_err());
42+
}
43+
}

src/datadogV2/model/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3160,6 +3160,10 @@ pub mod model_cloud_workload_security_agent_rule_action;
31603160
pub use self::model_cloud_workload_security_agent_rule_action::CloudWorkloadSecurityAgentRuleAction;
31613161
pub mod model_cloud_workload_security_agent_rule_kill;
31623162
pub use self::model_cloud_workload_security_agent_rule_kill::CloudWorkloadSecurityAgentRuleKill;
3163+
pub mod model_cloud_workload_security_agent_rule_action_metadata;
3164+
pub use self::model_cloud_workload_security_agent_rule_action_metadata::CloudWorkloadSecurityAgentRuleActionMetadata;
3165+
pub mod model_cloud_workload_security_agent_rule_action_set;
3166+
pub use self::model_cloud_workload_security_agent_rule_action_set::CloudWorkloadSecurityAgentRuleActionSet;
31633167
pub mod model_cloud_workload_security_agent_rule_creator_attributes;
31643168
pub use self::model_cloud_workload_security_agent_rule_creator_attributes::CloudWorkloadSecurityAgentRuleCreatorAttributes;
31653169
pub mod model_cloud_workload_security_agent_rule_updater_attributes;

src/datadogV2/model/model_cloud_workload_security_agent_rule_action.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ pub struct CloudWorkloadSecurityAgentRuleAction {
1717
/// Kill system call applied on the container matching the rule
1818
#[serde(rename = "kill")]
1919
pub kill: Option<crate::datadogV2::model::CloudWorkloadSecurityAgentRuleKill>,
20+
/// The metadata action applied on the scope matching the rule
21+
#[serde(rename = "metadata")]
22+
pub metadata: Option<crate::datadogV2::model::CloudWorkloadSecurityAgentRuleActionMetadata>,
23+
/// The set action applied on the scope matching the rule
24+
#[serde(rename = "set")]
25+
pub set: Option<crate::datadogV2::model::CloudWorkloadSecurityAgentRuleActionSet>,
2026
#[serde(flatten)]
2127
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
2228
#[serde(skip)]
@@ -29,6 +35,8 @@ impl CloudWorkloadSecurityAgentRuleAction {
2935
CloudWorkloadSecurityAgentRuleAction {
3036
filter: None,
3137
kill: None,
38+
metadata: None,
39+
set: None,
3240
additional_properties: std::collections::BTreeMap::new(),
3341
_unparsed: false,
3442
}
@@ -47,6 +55,22 @@ impl CloudWorkloadSecurityAgentRuleAction {
4755
self
4856
}
4957

58+
pub fn metadata(
59+
mut self,
60+
value: crate::datadogV2::model::CloudWorkloadSecurityAgentRuleActionMetadata,
61+
) -> Self {
62+
self.metadata = Some(value);
63+
self
64+
}
65+
66+
pub fn set(
67+
mut self,
68+
value: crate::datadogV2::model::CloudWorkloadSecurityAgentRuleActionSet,
69+
) -> Self {
70+
self.set = Some(value);
71+
self
72+
}
73+
5074
pub fn additional_properties(
5175
mut self,
5276
value: std::collections::BTreeMap<String, serde_json::Value>,
@@ -82,6 +106,12 @@ impl<'de> Deserialize<'de> for CloudWorkloadSecurityAgentRuleAction {
82106
let mut filter: Option<String> = None;
83107
let mut kill: Option<crate::datadogV2::model::CloudWorkloadSecurityAgentRuleKill> =
84108
None;
109+
let mut metadata: Option<
110+
crate::datadogV2::model::CloudWorkloadSecurityAgentRuleActionMetadata,
111+
> = None;
112+
let mut set: Option<
113+
crate::datadogV2::model::CloudWorkloadSecurityAgentRuleActionSet,
114+
> = None;
85115
let mut additional_properties: std::collections::BTreeMap<
86116
String,
87117
serde_json::Value,
@@ -102,6 +132,18 @@ impl<'de> Deserialize<'de> for CloudWorkloadSecurityAgentRuleAction {
102132
}
103133
kill = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
104134
}
135+
"metadata" => {
136+
if v.is_null() {
137+
continue;
138+
}
139+
metadata = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
140+
}
141+
"set" => {
142+
if v.is_null() {
143+
continue;
144+
}
145+
set = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
146+
}
105147
&_ => {
106148
if let Ok(value) = serde_json::from_value(v.clone()) {
107149
additional_properties.insert(k, value);
@@ -113,6 +155,8 @@ impl<'de> Deserialize<'de> for CloudWorkloadSecurityAgentRuleAction {
113155
let content = CloudWorkloadSecurityAgentRuleAction {
114156
filter,
115157
kill,
158+
metadata,
159+
set,
116160
additional_properties,
117161
_unparsed,
118162
};

0 commit comments

Comments
 (0)