Enable Storage Management for a bucket
https://api.datadoghq.com/api/v2/cloudinventoryservice/syncconfigshttps://api.us3.datadoghq.com/api/v2/cloudinventoryservice/syncconfigshttps://api.us5.datadoghq.com/api/v2/cloudinventoryservice/syncconfigshttps://api.datadoghq.eu/api/v2/cloudinventoryservice/syncconfigshttps://api.ap1.datadoghq.com/api/v2/cloudinventoryservice/syncconfigshttps://api.ap2.datadoghq.com/api/v2/cloudinventoryservice/syncconfigshttps://api.uk1.datadoghq.com/api/v2/cloudinventoryservice/syncconfigshttps://api.ddog-gov.com/api/v2/cloudinventoryservice/syncconfigshttps://api.us2.ddog-gov.com/api/v2/cloudinventoryservice/syncconfigs概要
Enable Storage Management for an S3 bucket, GCS bucket, or Azure container by registering the destination that holds its inventory reports. Set data.id to the cloud provider (aws, gcp, or azure) and provide the matching settings under data.attributes. Calling this endpoint with the same provider replaces the existing configuration.
リクエスト
Body Data (required)
data [required]Storage Management configuration data for the create or update request.
attributes [required]Settings for the cloud provider specified in data.id. Include only the matching provider object (aws, gcp, or azure).
awsAWS settings for the S3 bucket Storage Management reads inventory reports from.
aws_account_id [required]AWS account ID that owns the inventory bucket.
destination_bucket_name [required]Name of the S3 bucket containing inventory files.
destination_bucket_region [required]AWS Region of the inventory bucket.
destination_prefixObject key prefix where inventory reports are written. Omit or set to / when reports are written at the bucket root.
azureAzure settings for the storage account and container with inventory data.
client_id [required]Azure AD application (client) ID used for access.
container [required]Blob container name.
resource_group [required]Resource group containing the storage account.
storage_account [required]Storage account name.
subscription_id [required]Azure subscription ID.
tenant_id [required]Azure AD tenant ID.
gcpGCP settings for buckets involved in inventory reporting.
destination_bucket_name [required]GCS bucket name where Datadog reads inventory reports.
project_id [required]GCP project ID for the inventory destination bucket.
service_account_email [required]Service account email used to read the destination bucket.
source_bucket_name [required]GCS bucket name that inventory reports are generated for.
id [required]Cloud provider for this sync configuration (aws, gcp, or azure). For requests, must match the provider block supplied under attributes.
aws, gcp, azuretype [required]Always cloud_provider.
cloud_provider{
"data": {
"attributes": {
"aws": {
"aws_account_id": "123456789012",
"destination_bucket_name": "my-inventory-bucket",
"destination_bucket_region": "us-east-1",
"destination_prefix": "logs/"
},
"azure": {
"client_id": "11111111-1111-1111-1111-111111111111",
"container": "inventory-container",
"resource_group": "my-resource-group",
"storage_account": "mystorageaccount",
"subscription_id": "33333333-3333-3333-3333-333333333333",
"tenant_id": "22222222-2222-2222-2222-222222222222"
},
"gcp": {
"destination_bucket_name": "my-inventory-reports",
"project_id": "my-gcp-project",
"service_account_email": "reader@my-gcp-project.iam.gserviceaccount.com",
"source_bucket_name": "my-monitored-bucket"
}
},
"id": "aws",
"type": "cloud_provider"
}
}応答
OK
Storage Management configuration returned after a create or update. Additional read-only fields appear on list and get responses.
data [required]Storage Management configuration data.
attributes [required]Attributes for a Storage Management configuration. Fields other than id may be empty in the response immediately after a create or update; subsequent reads return the full configuration.
aws_account_id [required]AWS account ID for the inventory bucket.
aws_bucket_name [required]AWS S3 bucket name for inventory files.
aws_region [required]AWS Region for the inventory bucket.
azure_client_id [required]Azure AD application (client) ID.
azure_container_name [required]Azure blob container name.
azure_storage_account_name [required]Azure storage account name.
azure_tenant_id [required]Azure AD tenant ID.
cloud_provider [required]Cloud provider for this sync configuration (aws, gcp, or azure). For requests, must match the provider block supplied under attributes.
aws, gcp, azureerror [required]Human-readable error detail when sync is unhealthy.
error_code [required]Machine-readable error code when sync is unhealthy.
gcp_bucket_name [required]GCS bucket name for inventory files Datadog reads.
gcp_project_id [required]GCP project ID.
gcp_service_account_email [required]Service account email for bucket access.
prefix [required]Object key prefix where inventory reports are written. Returns / when reports are written at the bucket root.
id [required]Unique identifier for this Storage Management configuration.
type [required]Always sync_configs.
sync_configs{
"data": {
"attributes": {
"aws_account_id": "123456789012",
"aws_bucket_name": "my-inventory-bucket",
"aws_region": "us-east-1",
"azure_client_id": "11111111-1111-1111-1111-111111111111",
"azure_container_name": "inventory-container",
"azure_storage_account_name": "mystorageaccount",
"azure_tenant_id": "22222222-2222-2222-2222-222222222222",
"cloud_provider": "aws",
"error": "",
"error_code": "",
"gcp_bucket_name": "my-inventory-reports",
"gcp_project_id": "my-gcp-project",
"gcp_service_account_email": "reader@my-gcp-project.iam.gserviceaccount.com",
"prefix": "logs/"
},
"id": "abc123",
"type": "sync_configs"
}
}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"
}
]
}Forbidden
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}コード例
# 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 PUT "https://api.${DD_SITE}/api/v2/cloudinventoryservice/syncconfigs" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"aws": {
"aws_account_id": "123456789012",
"destination_bucket_name": "my-inventory-bucket",
"destination_bucket_region": "us-east-1",
"destination_prefix": "logs/"
}
},
"id": "aws",
"type": "cloud_provider"
}
}
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 PUT "https://api.${DD_SITE}/api/v2/cloudinventoryservice/syncconfigs" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"aws": {
"aws_account_id": "123456789012",
"destination_bucket_name": "my-inventory-bucket",
"destination_bucket_region": "us-east-1",
"destination_prefix": "logs/"
}
},
"id": "aws",
"type": "cloud_provider"
}
}
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 PUT "https://api.${DD_SITE}/api/v2/cloudinventoryservice/syncconfigs" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"aws": {
"aws_account_id": "123456789012",
"destination_bucket_name": "my-inventory-bucket",
"destination_bucket_region": "us-east-1",
"destination_prefix": "logs/"
}
},
"id": "aws",
"type": "cloud_provider"
}
}
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 PUT "https://api.${DD_SITE}/api/v2/cloudinventoryservice/syncconfigs" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"aws": {
"aws_account_id": "123456789012",
"destination_bucket_name": "my-inventory-bucket",
"destination_bucket_region": "us-east-1",
"destination_prefix": "logs/"
}
},
"id": "aws",
"type": "cloud_provider"
}
}
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 PUT "https://api.${DD_SITE}/api/v2/cloudinventoryservice/syncconfigs" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"aws": {
"aws_account_id": "123456789012",
"destination_bucket_name": "my-inventory-bucket",
"destination_bucket_region": "us-east-1",
"destination_prefix": "logs/"
}
},
"id": "aws",
"type": "cloud_provider"
}
}
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 PUT "https://api.${DD_SITE}/api/v2/cloudinventoryservice/syncconfigs" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"aws": {
"aws_account_id": "123456789012",
"destination_bucket_name": "my-inventory-bucket",
"destination_bucket_region": "us-east-1",
"destination_prefix": "logs/"
}
},
"id": "aws",
"type": "cloud_provider"
}
}
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 PUT "https://api.${DD_SITE}/api/v2/cloudinventoryservice/syncconfigs" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"aws": {
"aws_account_id": "123456789012",
"destination_bucket_name": "my-inventory-bucket",
"destination_bucket_region": "us-east-1",
"destination_prefix": "logs/"
}
},
"id": "aws",
"type": "cloud_provider"
}
}
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 PUT "https://api.${DD_SITE}/api/v2/cloudinventoryservice/syncconfigs" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"aws": {
"aws_account_id": "123456789012",
"destination_bucket_name": "my-inventory-bucket",
"destination_bucket_region": "us-east-1",
"destination_prefix": "logs/"
}
},
"id": "aws",
"type": "cloud_provider"
}
}
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 PUT "https://api.${DD_SITE}/api/v2/cloudinventoryservice/syncconfigs" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"aws": {
"aws_account_id": "123456789012",
"destination_bucket_name": "my-inventory-bucket",
"destination_bucket_region": "us-east-1",
"destination_prefix": "logs/"
}
},
"id": "aws",
"type": "cloud_provider"
}
}
EOF// Enable Storage Management for a bucket 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.UpsertCloudInventorySyncConfigRequest{
Data: datadogV2.UpsertCloudInventorySyncConfigRequestData{
Attributes: datadogV2.UpsertCloudInventorySyncConfigRequestAttributes{
Aws: &datadogV2.CloudInventorySyncConfigAWSRequestAttributes{
AwsAccountId: "123456789012",
DestinationBucketName: "my-inventory-bucket",
DestinationBucketRegion: "us-east-1",
DestinationPrefix: datadog.PtrString("logs/"),
},
Azure: &datadogV2.CloudInventorySyncConfigAzureRequestAttributes{
ClientId: "11111111-1111-1111-1111-111111111111",
Container: "inventory-container",
ResourceGroup: "my-resource-group",
StorageAccount: "mystorageaccount",
SubscriptionId: "33333333-3333-3333-3333-333333333333",
TenantId: "22222222-2222-2222-2222-222222222222",
},
Gcp: &datadogV2.CloudInventorySyncConfigGCPRequestAttributes{
DestinationBucketName: "my-inventory-reports",
ProjectId: "my-gcp-project",
ServiceAccountEmail: "reader@my-gcp-project.iam.gserviceaccount.com",
SourceBucketName: "my-monitored-bucket",
},
},
Id: datadogV2.CLOUDINVENTORYCLOUDPROVIDERID_AWS,
Type: datadogV2.CLOUDINVENTORYCLOUDPROVIDERREQUESTTYPE_CLOUD_PROVIDER,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewStorageManagementApi(apiClient)
resp, r, err := api.UpsertSyncConfig(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `StorageManagementApi.UpsertSyncConfig`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `StorageManagementApi.UpsertSyncConfig`:\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"// Enable Storage Management for a bucket returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.StorageManagementApi;
import com.datadog.api.client.v2.model.CloudInventoryCloudProviderId;
import com.datadog.api.client.v2.model.CloudInventoryCloudProviderRequestType;
import com.datadog.api.client.v2.model.CloudInventorySyncConfigAWSRequestAttributes;
import com.datadog.api.client.v2.model.CloudInventorySyncConfigAzureRequestAttributes;
import com.datadog.api.client.v2.model.CloudInventorySyncConfigGCPRequestAttributes;
import com.datadog.api.client.v2.model.CloudInventorySyncConfigResponse;
import com.datadog.api.client.v2.model.UpsertCloudInventorySyncConfigRequest;
import com.datadog.api.client.v2.model.UpsertCloudInventorySyncConfigRequestAttributes;
import com.datadog.api.client.v2.model.UpsertCloudInventorySyncConfigRequestData;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
StorageManagementApi apiInstance = new StorageManagementApi(defaultClient);
UpsertCloudInventorySyncConfigRequest body =
new UpsertCloudInventorySyncConfigRequest()
.data(
new UpsertCloudInventorySyncConfigRequestData()
.attributes(
new UpsertCloudInventorySyncConfigRequestAttributes()
.aws(
new CloudInventorySyncConfigAWSRequestAttributes()
.awsAccountId("123456789012")
.destinationBucketName("my-inventory-bucket")
.destinationBucketRegion("us-east-1")
.destinationPrefix("logs/"))
.azure(
new CloudInventorySyncConfigAzureRequestAttributes()
.clientId("11111111-1111-1111-1111-111111111111")
.container("inventory-container")
.resourceGroup("my-resource-group")
.storageAccount("mystorageaccount")
.subscriptionId("33333333-3333-3333-3333-333333333333")
.tenantId("22222222-2222-2222-2222-222222222222"))
.gcp(
new CloudInventorySyncConfigGCPRequestAttributes()
.destinationBucketName("my-inventory-reports")
.projectId("my-gcp-project")
.serviceAccountEmail(
"reader@my-gcp-project.iam.gserviceaccount.com")
.sourceBucketName("my-monitored-bucket")))
.id(CloudInventoryCloudProviderId.AWS)
.type(CloudInventoryCloudProviderRequestType.CLOUD_PROVIDER));
try {
CloudInventorySyncConfigResponse result = apiInstance.upsertSyncConfig(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling StorageManagementApi#upsertSyncConfig");
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""""
Enable Storage Management for a bucket returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.storage_management_api import StorageManagementApi
from datadog_api_client.v2.model.cloud_inventory_cloud_provider_id import CloudInventoryCloudProviderId
from datadog_api_client.v2.model.cloud_inventory_cloud_provider_request_type import (
CloudInventoryCloudProviderRequestType,
)
from datadog_api_client.v2.model.cloud_inventory_sync_config_aws_request_attributes import (
CloudInventorySyncConfigAWSRequestAttributes,
)
from datadog_api_client.v2.model.cloud_inventory_sync_config_azure_request_attributes import (
CloudInventorySyncConfigAzureRequestAttributes,
)
from datadog_api_client.v2.model.cloud_inventory_sync_config_gcp_request_attributes import (
CloudInventorySyncConfigGCPRequestAttributes,
)
from datadog_api_client.v2.model.upsert_cloud_inventory_sync_config_request import UpsertCloudInventorySyncConfigRequest
from datadog_api_client.v2.model.upsert_cloud_inventory_sync_config_request_attributes import (
UpsertCloudInventorySyncConfigRequestAttributes,
)
from datadog_api_client.v2.model.upsert_cloud_inventory_sync_config_request_data import (
UpsertCloudInventorySyncConfigRequestData,
)
body = UpsertCloudInventorySyncConfigRequest(
data=UpsertCloudInventorySyncConfigRequestData(
attributes=UpsertCloudInventorySyncConfigRequestAttributes(
aws=CloudInventorySyncConfigAWSRequestAttributes(
aws_account_id="123456789012",
destination_bucket_name="my-inventory-bucket",
destination_bucket_region="us-east-1",
destination_prefix="logs/",
),
azure=CloudInventorySyncConfigAzureRequestAttributes(
client_id="11111111-1111-1111-1111-111111111111",
container="inventory-container",
resource_group="my-resource-group",
storage_account="mystorageaccount",
subscription_id="33333333-3333-3333-3333-333333333333",
tenant_id="22222222-2222-2222-2222-222222222222",
),
gcp=CloudInventorySyncConfigGCPRequestAttributes(
destination_bucket_name="my-inventory-reports",
project_id="my-gcp-project",
service_account_email="reader@my-gcp-project.iam.gserviceaccount.com",
source_bucket_name="my-monitored-bucket",
),
),
id=CloudInventoryCloudProviderId.AWS,
type=CloudInventoryCloudProviderRequestType.CLOUD_PROVIDER,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = StorageManagementApi(api_client)
response = api_instance.upsert_sync_config(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"# Enable Storage Management for a bucket returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::StorageManagementAPI.new
body = DatadogAPIClient::V2::UpsertCloudInventorySyncConfigRequest.new({
data: DatadogAPIClient::V2::UpsertCloudInventorySyncConfigRequestData.new({
attributes: DatadogAPIClient::V2::UpsertCloudInventorySyncConfigRequestAttributes.new({
aws: DatadogAPIClient::V2::CloudInventorySyncConfigAWSRequestAttributes.new({
aws_account_id: "123456789012",
destination_bucket_name: "my-inventory-bucket",
destination_bucket_region: "us-east-1",
destination_prefix: "logs/",
}),
azure: DatadogAPIClient::V2::CloudInventorySyncConfigAzureRequestAttributes.new({
client_id: "11111111-1111-1111-1111-111111111111",
container: "inventory-container",
resource_group: "my-resource-group",
storage_account: "mystorageaccount",
subscription_id: "33333333-3333-3333-3333-333333333333",
tenant_id: "22222222-2222-2222-2222-222222222222",
}),
gcp: DatadogAPIClient::V2::CloudInventorySyncConfigGCPRequestAttributes.new({
destination_bucket_name: "my-inventory-reports",
project_id: "my-gcp-project",
service_account_email: "reader@my-gcp-project.iam.gserviceaccount.com",
source_bucket_name: "my-monitored-bucket",
}),
}),
id: DatadogAPIClient::V2::CloudInventoryCloudProviderId::AWS,
type: DatadogAPIClient::V2::CloudInventoryCloudProviderRequestType::CLOUD_PROVIDER,
}),
})
p api_instance.upsert_sync_config(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"// Enable Storage Management for a bucket returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_storage_management::StorageManagementAPI;
use datadog_api_client::datadogV2::model::CloudInventoryCloudProviderId;
use datadog_api_client::datadogV2::model::CloudInventoryCloudProviderRequestType;
use datadog_api_client::datadogV2::model::CloudInventorySyncConfigAWSRequestAttributes;
use datadog_api_client::datadogV2::model::CloudInventorySyncConfigAzureRequestAttributes;
use datadog_api_client::datadogV2::model::CloudInventorySyncConfigGCPRequestAttributes;
use datadog_api_client::datadogV2::model::UpsertCloudInventorySyncConfigRequest;
use datadog_api_client::datadogV2::model::UpsertCloudInventorySyncConfigRequestAttributes;
use datadog_api_client::datadogV2::model::UpsertCloudInventorySyncConfigRequestData;
#[tokio::main]
async fn main() {
let body =
UpsertCloudInventorySyncConfigRequest::new(UpsertCloudInventorySyncConfigRequestData::new(
UpsertCloudInventorySyncConfigRequestAttributes::new()
.aws(
CloudInventorySyncConfigAWSRequestAttributes::new(
"123456789012".to_string(),
"my-inventory-bucket".to_string(),
"us-east-1".to_string(),
)
.destination_prefix("logs/".to_string()),
)
.azure(CloudInventorySyncConfigAzureRequestAttributes::new(
"11111111-1111-1111-1111-111111111111".to_string(),
"inventory-container".to_string(),
"my-resource-group".to_string(),
"mystorageaccount".to_string(),
"33333333-3333-3333-3333-333333333333".to_string(),
"22222222-2222-2222-2222-222222222222".to_string(),
))
.gcp(CloudInventorySyncConfigGCPRequestAttributes::new(
"my-inventory-reports".to_string(),
"my-gcp-project".to_string(),
"reader@my-gcp-project.iam.gserviceaccount.com".to_string(),
"my-monitored-bucket".to_string(),
)),
CloudInventoryCloudProviderId::AWS,
CloudInventoryCloudProviderRequestType::CLOUD_PROVIDER,
));
let configuration = datadog::Configuration::new();
let api = StorageManagementAPI::with_config(configuration);
let resp = api.upsert_sync_config(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/**
* Enable Storage Management for a bucket 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,
},
},
});
const apiInstance = new v2.StorageManagementApi(configuration);
const params: v2.StorageManagementApiUpsertSyncConfigRequest = {
body: {
data: {
attributes: {
aws: {
awsAccountId: "123456789012",
destinationBucketName: "my-inventory-bucket",
destinationBucketRegion: "us-east-1",
destinationPrefix: "logs/",
},
azure: {
clientId: "11111111-1111-1111-1111-111111111111",
container: "inventory-container",
resourceGroup: "my-resource-group",
storageAccount: "mystorageaccount",
subscriptionId: "33333333-3333-3333-3333-333333333333",
tenantId: "22222222-2222-2222-2222-222222222222",
},
gcp: {
destinationBucketName: "my-inventory-reports",
projectId: "my-gcp-project",
serviceAccountEmail: "reader@my-gcp-project.iam.gserviceaccount.com",
sourceBucketName: "my-monitored-bucket",
},
},
id: "aws",
type: "cloud_provider",
},
},
};
apiInstance
.upsertSyncConfig(params)
.then((data: v2.CloudInventorySyncConfigResponse) => {
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"