-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for new CRUD agent rules endpoints (#1892)
Co-authored-by: ci.datadog-api-spec <[email protected]>
- Loading branch information
1 parent
86fc754
commit b75f41c
Showing
64 changed files
with
5,024 additions
and
1,650 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
examples/v2/cloud-workload-security/CreateCSMThreatsAgentRule.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
Create a CSM Threats Agent rule returns "OK" response | ||
""" | ||
|
||
from datadog_api_client import ApiClient, Configuration | ||
from datadog_api_client.v2.api.cloud_workload_security_api import CloudWorkloadSecurityApi | ||
from datadog_api_client.v2.model.cloud_workload_security_agent_rule_create_attributes import ( | ||
CloudWorkloadSecurityAgentRuleCreateAttributes, | ||
) | ||
from datadog_api_client.v2.model.cloud_workload_security_agent_rule_create_data import ( | ||
CloudWorkloadSecurityAgentRuleCreateData, | ||
) | ||
from datadog_api_client.v2.model.cloud_workload_security_agent_rule_create_request import ( | ||
CloudWorkloadSecurityAgentRuleCreateRequest, | ||
) | ||
from datadog_api_client.v2.model.cloud_workload_security_agent_rule_type import CloudWorkloadSecurityAgentRuleType | ||
|
||
body = CloudWorkloadSecurityAgentRuleCreateRequest( | ||
data=CloudWorkloadSecurityAgentRuleCreateData( | ||
attributes=CloudWorkloadSecurityAgentRuleCreateAttributes( | ||
description="My Agent rule", | ||
enabled=True, | ||
expression='exec.file.name == "sh"', | ||
name="my_agent_rule", | ||
), | ||
type=CloudWorkloadSecurityAgentRuleType.AGENT_RULE, | ||
), | ||
) | ||
|
||
configuration = Configuration() | ||
with ApiClient(configuration) as api_client: | ||
api_instance = CloudWorkloadSecurityApi(api_client) | ||
response = api_instance.create_csm_threats_agent_rule(body=body) | ||
|
||
print(response) |
17 changes: 17 additions & 0 deletions
17
examples/v2/cloud-workload-security/DeleteCSMThreatsAgentRule.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
""" | ||
Delete a CSM Threats Agent rule returns "OK" response | ||
""" | ||
|
||
from os import environ | ||
from datadog_api_client import ApiClient, Configuration | ||
from datadog_api_client.v2.api.cloud_workload_security_api import CloudWorkloadSecurityApi | ||
|
||
# there is a valid "agent_rule_rc" in the system | ||
AGENT_RULE_DATA_ID = environ["AGENT_RULE_DATA_ID"] | ||
|
||
configuration = Configuration() | ||
with ApiClient(configuration) as api_client: | ||
api_instance = CloudWorkloadSecurityApi(api_client) | ||
api_instance.delete_csm_threats_agent_rule( | ||
agent_rule_id=AGENT_RULE_DATA_ID, | ||
) |
13 changes: 13 additions & 0 deletions
13
examples/v2/cloud-workload-security/DownloadCSMThreatsPolicy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
""" | ||
Get the latest CSM Threats policy returns "OK" response | ||
""" | ||
|
||
from datadog_api_client import ApiClient, Configuration | ||
from datadog_api_client.v2.api.cloud_workload_security_api import CloudWorkloadSecurityApi | ||
|
||
configuration = Configuration() | ||
with ApiClient(configuration) as api_client: | ||
api_instance = CloudWorkloadSecurityApi(api_client) | ||
response = api_instance.download_csm_threats_policy() | ||
|
||
print(response.read()) |
19 changes: 19 additions & 0 deletions
19
examples/v2/cloud-workload-security/GetCSMThreatsAgentRule.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
Get a CSM Threats Agent rule returns "OK" response | ||
""" | ||
|
||
from os import environ | ||
from datadog_api_client import ApiClient, Configuration | ||
from datadog_api_client.v2.api.cloud_workload_security_api import CloudWorkloadSecurityApi | ||
|
||
# there is a valid "agent_rule_rc" in the system | ||
AGENT_RULE_DATA_ID = environ["AGENT_RULE_DATA_ID"] | ||
|
||
configuration = Configuration() | ||
with ApiClient(configuration) as api_client: | ||
api_instance = CloudWorkloadSecurityApi(api_client) | ||
response = api_instance.get_csm_threats_agent_rule( | ||
agent_rule_id=AGENT_RULE_DATA_ID, | ||
) | ||
|
||
print(response) |
13 changes: 13 additions & 0 deletions
13
examples/v2/cloud-workload-security/ListCSMThreatsAgentRules.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
""" | ||
Get all CSM Threats Agent rules returns "OK" response | ||
""" | ||
|
||
from datadog_api_client import ApiClient, Configuration | ||
from datadog_api_client.v2.api.cloud_workload_security_api import CloudWorkloadSecurityApi | ||
|
||
configuration = Configuration() | ||
with ApiClient(configuration) as api_client: | ||
api_instance = CloudWorkloadSecurityApi(api_client) | ||
response = api_instance.list_csm_threats_agent_rules() | ||
|
||
print(response) |
Oops, something went wrong.