Créer une intégration GCP
https://api.datadoghq.com/api/v1/integration/gcphttps://api.us3.datadoghq.com/api/v1/integration/gcphttps://api.us5.datadoghq.com/api/v1/integration/gcphttps://api.datadoghq.eu/api/v1/integration/gcphttps://api.ap1.datadoghq.com/api/v1/integration/gcphttps://api.ap2.datadoghq.com/api/v1/integration/gcphttps://api.uk1.datadoghq.com/api/v1/integration/gcphttps://api.ddog-gov.com/api/v1/integration/gcphttps://api.us2.ddog-gov.com/api/v1/integration/gcpPrésentation
Cet endpoint est obsolète ; utilisez plutôt les endpoints v2. Créez une intégration Datadog/GCP.
Requête
Body Data (required)
Créez une intégration Datadog/GCP.
auth_provider_x509_cert_urlVotre compte Google Cloud Platform.
auth_uriShould be https://accounts.google.com/o/oauth2/auth.
automuteSilence monitors for expected GCE instance shutdowns.
client_emailYour email found in your JSON service account key.
client_idYour ID found in your JSON service account key.
client_x509_cert_urlShould be https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL
where $CLIENT_EMAIL is the email found in your JSON service account key.
cloud_run_revision_filtersDEPRECATED List of filters to limit the Cloud Run revisions that are pulled into Datadog by using tags.
Only Cloud Run revision resources that apply to specified filters are imported into Datadog.
Note: This field is deprecated. Instead, use monitored_resource_configs with type=cloud_run_revision
errorsAn array of errors.
host_filtersDEPRECATED A comma-separated list of filters to limit the VM instances that are pulled into Datadog by using tags.
Only VM instance resources that apply to specified filters are imported into Datadog.
Note: This field is deprecated. Instead, use monitored_resource_configs with type=gce_instance
is_cspm_enabledWhen enabled, Datadog will activate the Cloud Security Monitoring product for this service account. Note: This requires resource_collection_enabled to be set to true.
is_resource_change_collection_enabledWhen enabled, Datadog scans for all resource change data in your Google Cloud environment.
falseis_security_command_center_enabledWhen enabled, Datadog will attempt to collect Security Command Center Findings. Note: This requires additional permissions on the service account.
falsemonitored_resource_configsConfigurations for GCP monitored resources.
filtersList of filters to limit the monitored resources that are pulled into Datadog by using tags. Only monitored resources that apply to specified filters are imported into Datadog.
typeThe GCP monitored resource type. Only a subset of resource types are supported.
cloud_function, cloud_run_revision, gce_instanceprivate_keyYour private key name found in your JSON service account key.
private_key_idYour private key ID found in your JSON service account key.
project_idYour Google Cloud project ID found in your JSON service account key.
resource_collection_enabledWhen enabled, Datadog scans for all resources in your GCP environment.
token_uriShould be https://accounts.google.com/o/oauth2/token.
typeThe value for service_account found in your JSON service account key.
{
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"client_email": "252bf553ef04b351@example.com",
"client_id": "163662907116366290710",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL",
"host_filters": "key:value,filter:example",
"cloud_run_revision_filters": [
"dr:dre"
],
"is_cspm_enabled": true,
"is_security_command_center_enabled": true,
"is_resource_change_collection_enabled": true,
"private_key": "private_key",
"private_key_id": "123456789abcdefghi123456789abcdefghijklm",
"project_id": "datadog-apitest",
"resource_collection_enabled": true,
"token_uri": "https://accounts.google.com/o/oauth2/token",
"type": "service_account"
}Réponse
OK
No response body
{}Bad Request
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Authentication error
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Too many requests
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Exemple de code
# 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 POST "https://api.${DD_SITE}/api/v1/integration/gcp" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"client_email": "252bf553ef04b351@example.com",
"client_id": "163662907116366290710",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL",
"host_filters": "key:value,filter:example",
"cloud_run_revision_filters": [
"dr:dre"
],
"is_cspm_enabled": true,
"is_security_command_center_enabled": true,
"is_resource_change_collection_enabled": true,
"private_key": "private_key",
"private_key_id": "123456789abcdefghi123456789abcdefghijklm",
"project_id": "datadog-apitest",
"resource_collection_enabled": true,
"token_uri": "https://accounts.google.com/o/oauth2/token",
"type": "service_account"
}
EOF# 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 POST "https://api.${DD_SITE}/api/v1/integration/gcp" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"client_email": "252bf553ef04b351@example.com",
"client_id": "163662907116366290710",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL",
"host_filters": "key:value,filter:example",
"cloud_run_revision_filters": [
"dr:dre"
],
"is_cspm_enabled": true,
"is_security_command_center_enabled": true,
"is_resource_change_collection_enabled": true,
"private_key": "private_key",
"private_key_id": "123456789abcdefghi123456789abcdefghijklm",
"project_id": "datadog-apitest",
"resource_collection_enabled": true,
"token_uri": "https://accounts.google.com/o/oauth2/token",
"type": "service_account"
}
EOF# 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 POST "https://api.${DD_SITE}/api/v1/integration/gcp" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"client_email": "252bf553ef04b351@example.com",
"client_id": "163662907116366290710",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL",
"host_filters": "key:value,filter:example",
"cloud_run_revision_filters": [
"dr:dre"
],
"is_cspm_enabled": true,
"is_security_command_center_enabled": true,
"is_resource_change_collection_enabled": true,
"private_key": "private_key",
"private_key_id": "123456789abcdefghi123456789abcdefghijklm",
"project_id": "datadog-apitest",
"resource_collection_enabled": true,
"token_uri": "https://accounts.google.com/o/oauth2/token",
"type": "service_account"
}
EOF# 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 POST "https://api.${DD_SITE}/api/v1/integration/gcp" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"client_email": "252bf553ef04b351@example.com",
"client_id": "163662907116366290710",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL",
"host_filters": "key:value,filter:example",
"cloud_run_revision_filters": [
"dr:dre"
],
"is_cspm_enabled": true,
"is_security_command_center_enabled": true,
"is_resource_change_collection_enabled": true,
"private_key": "private_key",
"private_key_id": "123456789abcdefghi123456789abcdefghijklm",
"project_id": "datadog-apitest",
"resource_collection_enabled": true,
"token_uri": "https://accounts.google.com/o/oauth2/token",
"type": "service_account"
}
EOF# 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 POST "https://api.${DD_SITE}/api/v1/integration/gcp" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"client_email": "252bf553ef04b351@example.com",
"client_id": "163662907116366290710",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL",
"host_filters": "key:value,filter:example",
"cloud_run_revision_filters": [
"dr:dre"
],
"is_cspm_enabled": true,
"is_security_command_center_enabled": true,
"is_resource_change_collection_enabled": true,
"private_key": "private_key",
"private_key_id": "123456789abcdefghi123456789abcdefghijklm",
"project_id": "datadog-apitest",
"resource_collection_enabled": true,
"token_uri": "https://accounts.google.com/o/oauth2/token",
"type": "service_account"
}
EOF# 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 POST "https://api.${DD_SITE}/api/v1/integration/gcp" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"client_email": "252bf553ef04b351@example.com",
"client_id": "163662907116366290710",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL",
"host_filters": "key:value,filter:example",
"cloud_run_revision_filters": [
"dr:dre"
],
"is_cspm_enabled": true,
"is_security_command_center_enabled": true,
"is_resource_change_collection_enabled": true,
"private_key": "private_key",
"private_key_id": "123456789abcdefghi123456789abcdefghijklm",
"project_id": "datadog-apitest",
"resource_collection_enabled": true,
"token_uri": "https://accounts.google.com/o/oauth2/token",
"type": "service_account"
}
EOF# 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 POST "https://api.${DD_SITE}/api/v1/integration/gcp" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"client_email": "252bf553ef04b351@example.com",
"client_id": "163662907116366290710",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL",
"host_filters": "key:value,filter:example",
"cloud_run_revision_filters": [
"dr:dre"
],
"is_cspm_enabled": true,
"is_security_command_center_enabled": true,
"is_resource_change_collection_enabled": true,
"private_key": "private_key",
"private_key_id": "123456789abcdefghi123456789abcdefghijklm",
"project_id": "datadog-apitest",
"resource_collection_enabled": true,
"token_uri": "https://accounts.google.com/o/oauth2/token",
"type": "service_account"
}
EOF# 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 POST "https://api.${DD_SITE}/api/v1/integration/gcp" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"client_email": "252bf553ef04b351@example.com",
"client_id": "163662907116366290710",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL",
"host_filters": "key:value,filter:example",
"cloud_run_revision_filters": [
"dr:dre"
],
"is_cspm_enabled": true,
"is_security_command_center_enabled": true,
"is_resource_change_collection_enabled": true,
"private_key": "private_key",
"private_key_id": "123456789abcdefghi123456789abcdefghijklm",
"project_id": "datadog-apitest",
"resource_collection_enabled": true,
"token_uri": "https://accounts.google.com/o/oauth2/token",
"type": "service_account"
}
EOF# 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 POST "https://api.${DD_SITE}/api/v1/integration/gcp" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"client_email": "252bf553ef04b351@example.com",
"client_id": "163662907116366290710",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL",
"host_filters": "key:value,filter:example",
"cloud_run_revision_filters": [
"dr:dre"
],
"is_cspm_enabled": true,
"is_security_command_center_enabled": true,
"is_resource_change_collection_enabled": true,
"private_key": "private_key",
"private_key_id": "123456789abcdefghi123456789abcdefghijklm",
"project_id": "datadog-apitest",
"resource_collection_enabled": true,
"token_uri": "https://accounts.google.com/o/oauth2/token",
"type": "service_account"
}
EOF// Create a GCP integration 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/datadogV1"
)
func main() {
body := datadogV1.GCPAccount{
AuthProviderX509CertUrl: datadog.PtrString("https://www.googleapis.com/oauth2/v1/certs"),
AuthUri: datadog.PtrString("https://accounts.google.com/o/oauth2/auth"),
ClientEmail: datadog.PtrString("252bf553ef04b351@example.com"),
ClientId: datadog.PtrString("163662907116366290710"),
ClientX509CertUrl: datadog.PtrString("https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL"),
HostFilters: datadog.PtrString("key:value,filter:example"),
CloudRunRevisionFilters: []string{
"dr:dre",
},
IsCspmEnabled: datadog.PtrBool(true),
IsSecurityCommandCenterEnabled: datadog.PtrBool(true),
IsResourceChangeCollectionEnabled: datadog.PtrBool(true),
PrivateKey: datadog.PtrString("private_key"),
PrivateKeyId: datadog.PtrString("123456789abcdefghi123456789abcdefghijklm"),
ProjectId: datadog.PtrString("datadog-apitest"),
ResourceCollectionEnabled: datadog.PtrBool(true),
TokenUri: datadog.PtrString("https://accounts.google.com/o/oauth2/token"),
Type: datadog.PtrString("service_account"),
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewGCPIntegrationApi(apiClient)
resp, r, err := api.CreateGCPIntegration(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `GCPIntegrationApi.CreateGCPIntegration`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `GCPIntegrationApi.CreateGCPIntegration`:\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"// Create a GCP integration returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.GcpIntegrationApi;
import com.datadog.api.client.v1.model.GCPAccount;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
GcpIntegrationApi apiInstance = new GcpIntegrationApi(defaultClient);
GCPAccount body =
new GCPAccount()
.authProviderX509CertUrl("https://www.googleapis.com/oauth2/v1/certs")
.authUri("https://accounts.google.com/o/oauth2/auth")
.clientEmail("252bf553ef04b351@example.com")
.clientId("163662907116366290710")
.clientX509CertUrl("https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL")
.hostFilters("key:value,filter:example")
.cloudRunRevisionFilters(Collections.singletonList("dr:dre"))
.isCspmEnabled(true)
.isSecurityCommandCenterEnabled(true)
.isResourceChangeCollectionEnabled(true)
.privateKey("private_key")
.privateKeyId("123456789abcdefghi123456789abcdefghijklm")
.projectId("datadog-apitest")
.resourceCollectionEnabled(true)
.tokenUri("https://accounts.google.com/o/oauth2/token")
.type("service_account");
try {
apiInstance.createGCPIntegration(body);
} catch (ApiException e) {
System.err.println("Exception when calling GcpIntegrationApi#createGCPIntegration");
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""""
Create a GCP integration returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.gcp_integration_api import GCPIntegrationApi
from datadog_api_client.v1.model.gcp_account import GCPAccount
body = GCPAccount(
auth_provider_x509_cert_url="https://www.googleapis.com/oauth2/v1/certs",
auth_uri="https://accounts.google.com/o/oauth2/auth",
client_email="252bf553ef04b351@example.com",
client_id="163662907116366290710",
client_x509_cert_url="https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL",
host_filters="key:value,filter:example",
cloud_run_revision_filters=[
"dr:dre",
],
is_cspm_enabled=True,
is_security_command_center_enabled=True,
is_resource_change_collection_enabled=True,
private_key="private_key",
private_key_id="123456789abcdefghi123456789abcdefghijklm",
project_id="datadog-apitest",
resource_collection_enabled=True,
token_uri="https://accounts.google.com/o/oauth2/token",
type="service_account",
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = GCPIntegrationApi(api_client)
response = api_instance.create_gcp_integration(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"# Create a GCP integration returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V1::GCPIntegrationAPI.new
body = DatadogAPIClient::V1::GCPAccount.new({
auth_provider_x509_cert_url: "https://www.googleapis.com/oauth2/v1/certs",
auth_uri: "https://accounts.google.com/o/oauth2/auth",
client_email: "252bf553ef04b351@example.com",
client_id: "163662907116366290710",
client_x509_cert_url: "https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL",
host_filters: "key:value,filter:example",
cloud_run_revision_filters: [
"dr:dre",
],
is_cspm_enabled: true,
is_security_command_center_enabled: true,
is_resource_change_collection_enabled: true,
private_key: "private_key",
private_key_id: "123456789abcdefghi123456789abcdefghijklm",
project_id: "datadog-apitest",
resource_collection_enabled: true,
token_uri: "https://accounts.google.com/o/oauth2/token",
type: "service_account",
})
p api_instance.create_gcp_integration(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"// Create a GCP integration returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_gcp_integration::GCPIntegrationAPI;
use datadog_api_client::datadogV1::model::GCPAccount;
#[tokio::main]
async fn main() {
let body = GCPAccount::new()
.auth_provider_x509_cert_url("https://www.googleapis.com/oauth2/v1/certs".to_string())
.auth_uri("https://accounts.google.com/o/oauth2/auth".to_string())
.client_email("252bf553ef04b351@example.com".to_string())
.client_id("163662907116366290710".to_string())
.client_x509_cert_url(
"https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL".to_string(),
)
.cloud_run_revision_filters(vec!["dr:dre".to_string()])
.host_filters("key:value,filter:example".to_string())
.is_cspm_enabled(true)
.is_resource_change_collection_enabled(true)
.is_security_command_center_enabled(true)
.private_key("private_key".to_string())
.private_key_id("123456789abcdefghi123456789abcdefghijklm".to_string())
.project_id("datadog-apitest".to_string())
.resource_collection_enabled(true)
.token_uri("https://accounts.google.com/o/oauth2/token".to_string())
.type_("service_account".to_string());
let configuration = datadog::Configuration::new();
let api = GCPIntegrationAPI::with_config(configuration);
let resp = api.create_gcp_integration(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="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run/**
* Create a GCP integration returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v1.GCPIntegrationApi(configuration);
const params: v1.GCPIntegrationApiCreateGCPIntegrationRequest = {
body: {
authProviderX509CertUrl: "https://www.googleapis.com/oauth2/v1/certs",
authUri: "https://accounts.google.com/o/oauth2/auth",
clientEmail: "252bf553ef04b351@example.com",
clientId: "163662907116366290710",
clientX509CertUrl:
"https://www.googleapis.com/robot/v1/metadata/x509/$CLIENT_EMAIL",
hostFilters: "key:value,filter:example",
cloudRunRevisionFilters: ["dr:dre"],
isCspmEnabled: true,
isSecurityCommandCenterEnabled: true,
isResourceChangeCollectionEnabled: true,
privateKey: "private_key",
privateKeyId: "123456789abcdefghi123456789abcdefghijklm",
projectId: "datadog-apitest",
resourceCollectionEnabled: true,
tokenUri: "https://accounts.google.com/o/oauth2/token",
type: "service_account",
},
};
apiInstance
.createGCPIntegration(params)
.then((data: any) => {
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"from datadog import initialize, api
options = {
'api_key': '<DATADOG_API_KEY>',
'app_key': '<DATADOG_APPLICATION_KEY>'
}
initialize(**options)
api.GcpIntegration.create(
type="service_account",
project_id="<GCP_PROJECT_ID>",
private_key_id="<GCP_PRIVATE_KEY_ID>",
private_key="<GCP_PRIVATE_KEY>",
client_email="<GCP_CLIENT_EMAIL>",
client_id="<GCP_CLIENT_ID>",
auth_uri="<GCP_AUTH_URI>",
token_uri="<GCP_TOKEN_URI>",
auth_provider_x509_cert_url="<GCP_AUTH_PROVIDER_X509_CERT_URL>",
client_x509_cert_url="<GCP_CLIENT_X509_CERT_URL>",
host_filters="<KEY>:<VALUE>,<KEY>:<VALUE>"
)
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_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"DD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"DD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"DD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"DD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"require 'rubygems'
require 'dogapi'
api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
config= {
"type": "service_account",
"project_id": "<GCP_PROJECT_ID>",
"private_key_id": "<PRIVATE_KEY_ID>",
"private_key": "<PRIVATE_KEY>",
"client_email": "<CLIENT_EMAIL>",
"client_id": "<CLIENT_ID>",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/<CLIENT_EMAIL>",
"host_filters": "<KEY_1>:<VALUE_1>,<KEY_2>:<VALUE_2>"
}
dog = Dogapi::Client.new(api_key, app_key)
dog.gcp_integration_create(config)
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_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"DD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"DD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"