Update a control
https://api.datadoghq.com/api/v2/governance/control/{detection_type}https://api.us3.datadoghq.com/api/v2/governance/control/{detection_type}https://api.us5.datadoghq.com/api/v2/governance/control/{detection_type}https://api.datadoghq.eu/api/v2/governance/control/{detection_type}https://api.ap1.datadoghq.com/api/v2/governance/control/{detection_type}https://api.ap2.datadoghq.com/api/v2/governance/control/{detection_type}https://api.uk1.datadoghq.com/api/v2/governance/control/{detection_type}https://api.ddog-gov.com/api/v2/governance/control/{detection_type}https://api.us2.ddog-gov.com/api/v2/governance/control/{detection_type}Présentation
Update the detection, notification, and mitigation configuration of a governance control. Only the attributes present in the request are modified. Changing the mitigation type or its parameters may require additional permissions.
Arguments
Paramètres du chemin
detection_type [required]The detection type that identifies the control, for example unused_api_keys.
Requête
Body Data (required)
data [required]The data of a governance control update request.
attributesThe attributes of a governance control that can be updated. Only the attributes present in the request are modified.
detection_parametersA free-form map of parameter names to their configured values.
mitigation_parametersA free-form map of parameter names to their configured values.
mitigation_typeThe mitigation type to configure for the control.
type [required]JSON:API resource type for a governance control.
governance_control{
"data": {
"attributes": {
"detection_parameters": {},
"mitigation_parameters": {},
"mitigation_type": "revoke_api_key"
},
"type": "governance_control"
}
}Réponse
OK
A single governance control.
data [required]A governance control resource.
attributes [required]The attributes of a governance control.
active_detections_count [required]The number of active detections for the control.
category [required]The value driver the control is grouped under, such as security or cost.
created_at [required]The time the control configuration was created.
created_by [required]The UUID of the user who created the control configuration.
description [required]A human-readable description of what the control detects.
detection_parameters [required]A free-form map of parameter names to their configured values.
insights [required]The insight slugs associated with the control.
last_detection_at [required]The time of the most recent detection for the control. null when there are no detections.
mitigated_detections_count [required]The number of mitigated detections for the control.
mitigation_parameters [required]A free-form map of parameter names to their configured values.
mitigation_type [required]The configured mitigation type for the control. Empty when not configured.
mitigations [required]The mitigations available for a control.
description [required]A human-readable description of the mitigation.
execution_modes [required]The execution modes the mitigation supports, such as manual or automatic.
id [required]The unique identifier of the mitigation.
permissions [required]The permissions required to apply the mitigation.
supported_parameters [required]An array of parameter definitions.
default_value [required]The default value of the parameter. The JSON type depends on the parameter's type. null when the parameter has no default.
description [required]A human-readable description of the parameter.
display_name [required]The human-readable name of the parameter.
name [required]The machine-readable name of the parameter.
required [required]Whether the parameter must be provided.
supported_values [required]The supported values for an enumerated parameter. null when the parameter is not an enumerated type.
label [required]The human-readable label for the value.
value [required]The machine-readable value.
type [required]The type of the parameter, such as integer, string, boolean, enum, or pattern_list.
title [required]A short, human-readable name for the mitigation.
name [required]Human-readable name of the control.
priority [required]The priority of the control, such as High.
product [required]The product the control belongs to.
resource_type [required]The type of resource the control evaluates.
resource_type_display_name [required]The human-readable name of the resource type.
supported_detection_parameters [required]An array of parameter definitions.
default_value [required]The default value of the parameter. The JSON type depends on the parameter's type. null when the parameter has no default.
description [required]A human-readable description of the parameter.
display_name [required]The human-readable name of the parameter.
name [required]The machine-readable name of the parameter.
required [required]Whether the parameter must be provided.
supported_values [required]The supported values for an enumerated parameter. null when the parameter is not an enumerated type.
label [required]The human-readable label for the value.
value [required]The machine-readable value.
type [required]The type of the parameter, such as integer, string, boolean, enum, or pattern_list.
type [required]The control type, such as Proactive or Detection.
id [required]The detection type that uniquely identifies the control.
type [required]JSON:API resource type for a governance control.
governance_control{
"data": {
"attributes": {
"active_detections_count": 12,
"category": "security",
"created_at": "2024-01-15T09:30:00Z",
"created_by": "11111111-2222-3333-4444-555555555555",
"description": "Identifies API keys that have not been used within your specified time threshold, helping reduce security risks from dormant credentials.",
"detection_parameters": {},
"insights": [
[]
],
"last_detection_at": "2024-03-01T12:00:00Z",
"mitigated_detections_count": 3,
"mitigation_parameters": {},
"mitigation_type": "revoke_api_key",
"mitigations": [
{
"description": "Automatically identifies and revokes inactive API keys to improve security and reduce potential attack surface.",
"execution_modes": [
"manual",
"automatic"
],
"id": "revoke_api_key",
"permissions": [
"api_keys_write",
"api_keys_delete"
],
"supported_parameters": [
{
"default_value": 30,
"description": "Number of days of inactivity before an API key is considered unused.",
"display_name": "Unused API Key Threshold",
"name": "api_key_threshold",
"required": false,
"supported_values": [
{
"label": "30 days",
"value": "thirty"
}
],
"type": "integer"
}
],
"title": "Revoke Unused API Keys"
}
],
"name": "Unused API Keys",
"priority": "High",
"product": "api_keys",
"resource_type": "api_key",
"resource_type_display_name": "API Key",
"supported_detection_parameters": [
{
"default_value": 30,
"description": "Number of days of inactivity before an API key is considered unused.",
"display_name": "Unused API Key Threshold",
"name": "api_key_threshold",
"required": false,
"supported_values": [
{
"label": "30 days",
"value": "thirty"
}
],
"type": "integer"
}
],
"type": "Proactive"
},
"id": "unused_api_keys",
"type": "governance_control"
}
}Bad Request
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Unauthorized
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Forbidden
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Not Found
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Exemple de code
# Path parameters
export detection_type="unused_api_keys"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/governance/control/${detection_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"detection_parameters": {
"api_key_threshold": 60
},
"mitigation_type": "revoke_api_key"
},
"type": "governance_control"
}
}
EOF# Path parameters
export detection_type="unused_api_keys"
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/governance/control/${detection_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"detection_parameters": {
"api_key_threshold": 60
},
"mitigation_type": "revoke_api_key"
},
"type": "governance_control"
}
}
EOF# Path parameters
export detection_type="unused_api_keys"
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/governance/control/${detection_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"detection_parameters": {
"api_key_threshold": 60
},
"mitigation_type": "revoke_api_key"
},
"type": "governance_control"
}
}
EOF# Path parameters
export detection_type="unused_api_keys"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/governance/control/${detection_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"detection_parameters": {
"api_key_threshold": 60
},
"mitigation_type": "revoke_api_key"
},
"type": "governance_control"
}
}
EOF# Path parameters
export detection_type="unused_api_keys"
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/governance/control/${detection_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"detection_parameters": {
"api_key_threshold": 60
},
"mitigation_type": "revoke_api_key"
},
"type": "governance_control"
}
}
EOF# Path parameters
export detection_type="unused_api_keys"
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/governance/control/${detection_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"detection_parameters": {
"api_key_threshold": 60
},
"mitigation_type": "revoke_api_key"
},
"type": "governance_control"
}
}
EOF# Path parameters
export detection_type="unused_api_keys"
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/governance/control/${detection_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"detection_parameters": {
"api_key_threshold": 60
},
"mitigation_type": "revoke_api_key"
},
"type": "governance_control"
}
}
EOF# Path parameters
export detection_type="unused_api_keys"
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/governance/control/${detection_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"detection_parameters": {
"api_key_threshold": 60
},
"mitigation_type": "revoke_api_key"
},
"type": "governance_control"
}
}
EOF# Path parameters
export detection_type="unused_api_keys"
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/governance/control/${detection_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"detection_parameters": {
"api_key_threshold": 60
},
"mitigation_type": "revoke_api_key"
},
"type": "governance_control"
}
}
EOF// Update a control returns "OK" response
package main
import (
"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"
)
func main() {
body := datadogV2.GovernanceControlUpdateRequest{
Data: datadogV2.GovernanceControlUpdateData{
Attributes: &datadogV2.GovernanceControlUpdateAttributes{
MitigationType: datadog.PtrString("revoke_api_key"),
},
Type: datadogV2.GOVERNANCECONTROLRESOURCETYPE_GOVERNANCE_CONTROL,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.UpdateGovernanceControl", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewGovernanceConsoleApi(apiClient)
resp, r, err := api.UpdateGovernanceControl(ctx, "detection_type", body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `GovernanceConsoleApi.UpdateGovernanceControl`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `GovernanceConsoleApi.UpdateGovernanceControl`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Update a control returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.GovernanceConsoleApi;
import com.datadog.api.client.v2.model.GovernanceControlResourceType;
import com.datadog.api.client.v2.model.GovernanceControlResponse;
import com.datadog.api.client.v2.model.GovernanceControlUpdateAttributes;
import com.datadog.api.client.v2.model.GovernanceControlUpdateData;
import com.datadog.api.client.v2.model.GovernanceControlUpdateRequest;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.updateGovernanceControl", true);
GovernanceConsoleApi apiInstance = new GovernanceConsoleApi(defaultClient);
GovernanceControlUpdateRequest body =
new GovernanceControlUpdateRequest()
.data(
new GovernanceControlUpdateData()
.attributes(
new GovernanceControlUpdateAttributes().mitigationType("revoke_api_key"))
.type(GovernanceControlResourceType.GOVERNANCE_CONTROL));
try {
GovernanceControlResponse result =
apiInstance.updateGovernanceControl("unused_api_keys", body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling GovernanceConsoleApi#updateGovernanceControl");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Update a control returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.governance_console_api import GovernanceConsoleApi
from datadog_api_client.v2.model.governance_control_resource_type import GovernanceControlResourceType
from datadog_api_client.v2.model.governance_control_update_attributes import GovernanceControlUpdateAttributes
from datadog_api_client.v2.model.governance_control_update_data import GovernanceControlUpdateData
from datadog_api_client.v2.model.governance_control_update_request import GovernanceControlUpdateRequest
body = GovernanceControlUpdateRequest(
data=GovernanceControlUpdateData(
attributes=GovernanceControlUpdateAttributes(
mitigation_type="revoke_api_key",
),
type=GovernanceControlResourceType.GOVERNANCE_CONTROL,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["update_governance_control"] = True
with ApiClient(configuration) as api_client:
api_instance = GovernanceConsoleApi(api_client)
response = api_instance.update_governance_control(detection_type="detection_type", body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Update a control returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.update_governance_control".to_sym] = true
end
api_instance = DatadogAPIClient::V2::GovernanceConsoleAPI.new
body = DatadogAPIClient::V2::GovernanceControlUpdateRequest.new({
data: DatadogAPIClient::V2::GovernanceControlUpdateData.new({
attributes: DatadogAPIClient::V2::GovernanceControlUpdateAttributes.new({
mitigation_type: "revoke_api_key",
}),
type: DatadogAPIClient::V2::GovernanceControlResourceType::GOVERNANCE_CONTROL,
}),
})
p api_instance.update_governance_control("detection_type", body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Update a control returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_governance_console::GovernanceConsoleAPI;
use datadog_api_client::datadogV2::model::GovernanceControlResourceType;
use datadog_api_client::datadogV2::model::GovernanceControlUpdateAttributes;
use datadog_api_client::datadogV2::model::GovernanceControlUpdateData;
use datadog_api_client::datadogV2::model::GovernanceControlUpdateRequest;
#[tokio::main]
async fn main() {
let body = GovernanceControlUpdateRequest::new(
GovernanceControlUpdateData::new(GovernanceControlResourceType::GOVERNANCE_CONTROL)
.attributes(
GovernanceControlUpdateAttributes::new()
.mitigation_type("revoke_api_key".to_string()),
),
);
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.update_governance_control", true);
let api = GovernanceConsoleAPI::with_config(configuration);
let resp = api
.update_governance_control("detection_type".to_string(), body)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Update a control returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
configuration.unstableOperations["v2.updateGovernanceControl"] = true;
const apiInstance = new v2.GovernanceConsoleApi(configuration);
const params: v2.GovernanceConsoleApiUpdateGovernanceControlRequest = {
body: {
data: {
attributes: {
mitigationType: "revoke_api_key",
},
type: "governance_control",
},
},
detectionType: "detection_type",
};
apiInstance
.updateGovernanceControl(params)
.then((data: v2.GovernanceControlResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"