Update an existing execution policy.
Returns the execution policy object when the request is successful.
This endpoint requires the execution_groups_write permission.
Attributes used to create or update an execution policy.
action_pattern [required]
object
The set of actions this policy applies to.
action_fqns [required]
[string]
The fully qualified action names this policy matches. Use * to match all actions
of the integration, or a fully qualified name prefixed with the integration's action
namespace (for example com.datadoghq.script.* for the Script integration).
integration [required]
enum
The integration the action pattern applies to.
Allowed enum values: INTEGRATION_KUBERNETES,INTEGRATION_SCRIPT,INTEGRATION_REMOTE_ACTION
effect [required]
enum
Whether the policy allows or denies matching actions.
Allowed enum values: allow,deny
name [required]
string
The name of the execution policy.
scope
object
Restricts where the policy applies. At most one of kubernetes, scripts,
or remote_action_rshell can be set. An empty object means the policy has
no scope restriction.
kubernetes
object
Restricts the policy to specific Kubernetes namespaces.
rules [required]
[object]
The Kubernetes scope rules.
target_namespaces [required]
[string]
The Kubernetes namespaces this rule applies to.
remote_action_rshell
object
Restricts the policy to specific remote shell paths.
rules [required]
[object]
The remote shell scope rules.
access [required]
enum
The level of remote shell access granted for the target paths.
Allowed enum values: read_only,read_write
target_paths [required]
[string]
The file system paths this rule applies to.
scripts
object
Restricts the policy to specific scripts.
rules [required]
[object]
The script scope rules.
target_script_names [required]
[string]
The script names this rule applies to.
targets
[object]
The targets this policy applies to.
agent_tags [required]
[string]
The Agent tags identifying the target.
name
string
A human-readable name for the target.
id [required]
string
The ID of the execution policy.
type [required]
enum
The type of the resource. The value should always be execution_policy.
Allowed enum values: execution_policy
Response object that includes a single execution policy.
Expand All
Campo
Type
Descripción
data [required]
object
Object for a single execution policy.
attributes [required]
object
An execution policy.
action_pattern [required]
object
The set of actions this policy applies to.
action_fqns [required]
[string]
The fully qualified action names this policy matches. Use * to match all actions
of the integration, or a fully qualified name prefixed with the integration's action
namespace (for example com.datadoghq.script.* for the Script integration).
integration [required]
enum
The integration the action pattern applies to.
Allowed enum values: INTEGRATION_KUBERNETES,INTEGRATION_SCRIPT,INTEGRATION_REMOTE_ACTION
created_at [required]
date-time
The date and time the execution policy was created.
created_by [required]
string
The ID of the user who created the execution policy.
effect [required]
enum
Whether the policy allows or denies matching actions.
Allowed enum values: allow,deny
name [required]
string
The name of the execution policy.
scope
object
Restricts where the policy applies. At most one of kubernetes, scripts,
or remote_action_rshell can be set. An empty object means the policy has
no scope restriction.
kubernetes
object
Restricts the policy to specific Kubernetes namespaces.
rules [required]
[object]
The Kubernetes scope rules.
target_namespaces [required]
[string]
The Kubernetes namespaces this rule applies to.
remote_action_rshell
object
Restricts the policy to specific remote shell paths.
rules [required]
[object]
The remote shell scope rules.
access [required]
enum
The level of remote shell access granted for the target paths.
Allowed enum values: read_only,read_write
target_paths [required]
[string]
The file system paths this rule applies to.
scripts
object
Restricts the policy to specific scripts.
rules [required]
[object]
The script scope rules.
target_script_names [required]
[string]
The script names this rule applies to.
targets [required]
[object]
The targets this policy applies to.
agent_tags [required]
[string]
The Agent tags identifying the target.
name
string
A human-readable name for the target.
updated_at [required]
date-time
The date and time the execution policy was last updated.
updated_by [required]
string
The ID of the user who last updated the execution policy.
version [required]
int32
The version of the execution policy. Incremented on every update.
id [required]
string
The ID of the execution policy.
type [required]
enum
The type of the resource. The value should always be execution_policy.
Allowed enum values: execution_policy
// Update an execution policy returns "OK" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "execution_policy" in the systemExecutionPolicyDataID:=os.Getenv("EXECUTION_POLICY_DATA_ID")body:=datadogV2.ExecutionPolicyUpdateRequest{Data:datadogV2.ExecutionPolicyUpdateRequestData{Id:ExecutionPolicyDataID,Type:datadogV2.EXECUTIONPOLICYTYPE_EXECUTION_POLICY,Attributes:datadogV2.ExecutionPolicyWriteAttributes{Name:"Cassette Execution Policy Updated",Effect:datadogV2.EXECUTIONPOLICYEFFECT_ALLOW,ActionPattern:datadogV2.ExecutionPolicyActionPattern{Integration:datadogV2.EXECUTIONPOLICYINTEGRATION_INTEGRATION_SCRIPT,ActionFqns:[]string{"com.datadoghq.script.*",},},},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()configuration.SetUnstableOperationEnabled("v2.UpdateExecutionPolicy",true)apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewExecutionPolicyApi(apiClient)resp,r,err:=api.UpdateExecutionPolicy(ctx,ExecutionPolicyDataID,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `ExecutionPolicyApi.UpdateExecutionPolicy`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `ExecutionPolicyApi.UpdateExecutionPolicy`:\n%s\n",responseContent)}
// Update an execution policy returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.ExecutionPolicyApi;importcom.datadog.api.client.v2.model.ExecutionPolicyActionPattern;importcom.datadog.api.client.v2.model.ExecutionPolicyEffect;importcom.datadog.api.client.v2.model.ExecutionPolicyIntegration;importcom.datadog.api.client.v2.model.ExecutionPolicyResponse;importcom.datadog.api.client.v2.model.ExecutionPolicyType;importcom.datadog.api.client.v2.model.ExecutionPolicyUpdateRequest;importcom.datadog.api.client.v2.model.ExecutionPolicyUpdateRequestData;importcom.datadog.api.client.v2.model.ExecutionPolicyWriteAttributes;importjava.util.Collections;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();defaultClient.setUnstableOperationEnabled("v2.updateExecutionPolicy",true);ExecutionPolicyApiapiInstance=newExecutionPolicyApi(defaultClient);// there is a valid "execution_policy" in the systemStringEXECUTION_POLICY_DATA_ID=System.getenv("EXECUTION_POLICY_DATA_ID");ExecutionPolicyUpdateRequestbody=newExecutionPolicyUpdateRequest().data(newExecutionPolicyUpdateRequestData().id(EXECUTION_POLICY_DATA_ID).type(ExecutionPolicyType.EXECUTION_POLICY).attributes(newExecutionPolicyWriteAttributes().name("Cassette Execution Policy Updated").effect(ExecutionPolicyEffect.ALLOW).actionPattern(newExecutionPolicyActionPattern().integration(ExecutionPolicyIntegration.INTEGRATION_SCRIPT).actionFqns(Collections.singletonList("com.datadoghq.script.*")))));try{ExecutionPolicyResponseresult=apiInstance.updateExecutionPolicy(EXECUTION_POLICY_DATA_ID,body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling ExecutionPolicyApi#updateExecutionPolicy");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
"""
Update an execution policy returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.execution_policy_apiimportExecutionPolicyApifromdatadog_api_client.v2.model.execution_policy_action_patternimportExecutionPolicyActionPatternfromdatadog_api_client.v2.model.execution_policy_effectimportExecutionPolicyEffectfromdatadog_api_client.v2.model.execution_policy_integrationimportExecutionPolicyIntegrationfromdatadog_api_client.v2.model.execution_policy_typeimportExecutionPolicyTypefromdatadog_api_client.v2.model.execution_policy_update_requestimportExecutionPolicyUpdateRequestfromdatadog_api_client.v2.model.execution_policy_update_request_dataimportExecutionPolicyUpdateRequestDatafromdatadog_api_client.v2.model.execution_policy_write_attributesimportExecutionPolicyWriteAttributes# there is a valid "execution_policy" in the systemEXECUTION_POLICY_DATA_ID=environ["EXECUTION_POLICY_DATA_ID"]body=ExecutionPolicyUpdateRequest(data=ExecutionPolicyUpdateRequestData(id=EXECUTION_POLICY_DATA_ID,type=ExecutionPolicyType.EXECUTION_POLICY,attributes=ExecutionPolicyWriteAttributes(name="Cassette Execution Policy Updated",effect=ExecutionPolicyEffect.ALLOW,action_pattern=ExecutionPolicyActionPattern(integration=ExecutionPolicyIntegration.INTEGRATION_SCRIPT,action_fqns=["com.datadoghq.script.*",],),),),)configuration=Configuration()configuration.unstable_operations["update_execution_policy"]=TruewithApiClient(configuration)asapi_client:api_instance=ExecutionPolicyApi(api_client)response=api_instance.update_execution_policy(policy_id=EXECUTION_POLICY_DATA_ID,body=body)print(response)
# Update an execution policy returns "OK" responserequire"datadog_api_client"DatadogAPIClient.configuredo|config|config.unstable_operations["v2.update_execution_policy".to_sym]=trueendapi_instance=DatadogAPIClient::V2::ExecutionPolicyAPI.new# there is a valid "execution_policy" in the systemEXECUTION_POLICY_DATA_ID=ENV["EXECUTION_POLICY_DATA_ID"]body=DatadogAPIClient::V2::ExecutionPolicyUpdateRequest.new({data:DatadogAPIClient::V2::ExecutionPolicyUpdateRequestData.new({id:EXECUTION_POLICY_DATA_ID,type:DatadogAPIClient::V2::ExecutionPolicyType::EXECUTION_POLICY,attributes:DatadogAPIClient::V2::ExecutionPolicyWriteAttributes.new({name:"Cassette Execution Policy Updated",effect:DatadogAPIClient::V2::ExecutionPolicyEffect::ALLOW,action_pattern:DatadogAPIClient::V2::ExecutionPolicyActionPattern.new({integration:DatadogAPIClient::V2::ExecutionPolicyIntegration::INTEGRATION_SCRIPT,action_fqns:["com.datadoghq.script.*",],}),}),}),})papi_instance.update_execution_policy(EXECUTION_POLICY_DATA_ID,body)
// Update an execution policy returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_execution_policy::ExecutionPolicyAPI;usedatadog_api_client::datadogV2::model::ExecutionPolicyActionPattern;usedatadog_api_client::datadogV2::model::ExecutionPolicyEffect;usedatadog_api_client::datadogV2::model::ExecutionPolicyIntegration;usedatadog_api_client::datadogV2::model::ExecutionPolicyType;usedatadog_api_client::datadogV2::model::ExecutionPolicyUpdateRequest;usedatadog_api_client::datadogV2::model::ExecutionPolicyUpdateRequestData;usedatadog_api_client::datadogV2::model::ExecutionPolicyWriteAttributes;#[tokio::main]asyncfnmain(){// there is a valid "execution_policy" in the system
letexecution_policy_data_id=std::env::var("EXECUTION_POLICY_DATA_ID").unwrap();letbody=ExecutionPolicyUpdateRequest::new(ExecutionPolicyUpdateRequestData::new(ExecutionPolicyWriteAttributes::new(ExecutionPolicyActionPattern::new(vec!["com.datadoghq.script.*".to_string()],ExecutionPolicyIntegration::INTEGRATION_SCRIPT,),ExecutionPolicyEffect::ALLOW,"Cassette Execution Policy Updated".to_string(),),execution_policy_data_id.clone(),ExecutionPolicyType::EXECUTION_POLICY,));letmutconfiguration=datadog::Configuration::new();configuration.set_unstable_operation_enabled("v2.UpdateExecutionPolicy",true);letapi=ExecutionPolicyAPI::with_config(configuration);letresp=api.update_execution_policy(execution_policy_data_id.clone(),body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Update an execution policy returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();configuration.unstableOperations["v2.updateExecutionPolicy"]=true;constapiInstance=newv2.ExecutionPolicyApi(configuration);// there is a valid "execution_policy" in the system
constEXECUTION_POLICY_DATA_ID=process.env.EXECUTION_POLICY_DATA_IDasstring;constparams: v2.ExecutionPolicyApiUpdateExecutionPolicyRequest={body:{data:{id: EXECUTION_POLICY_DATA_ID,type:"execution_policy",attributes:{name:"Cassette Execution Policy Updated",effect:"allow",actionPattern:{integration:"INTEGRATION_SCRIPT",actionFqns:["com.datadoghq.script.*"],},},},},policyId: EXECUTION_POLICY_DATA_ID,};apiInstance.updateExecutionPolicy(params).then((data: v2.ExecutionPolicyResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));