Create reference table
https://api.datadoghq.com/api/v2/reference-tables/tableshttps://api.us3.datadoghq.com/api/v2/reference-tables/tableshttps://api.us5.datadoghq.com/api/v2/reference-tables/tableshttps://api.datadoghq.eu/api/v2/reference-tables/tableshttps://api.ap1.datadoghq.com/api/v2/reference-tables/tableshttps://api.ap2.datadoghq.com/api/v2/reference-tables/tableshttps://api.uk1.datadoghq.com/api/v2/reference-tables/tableshttps://api.ddog-gov.com/api/v2/reference-tables/tableshttps://api.us2.ddog-gov.com/api/v2/reference-tables/tables概要
Creates a reference table. You can provide data in two ways:
- Call POST /api/v2/reference-tables/upload to get an upload ID. Then, PUT the CSV data
(not the file itself) in chunks to each URL in the request body. Finally, call this
POST endpoint with
upload_idinfile_metadata. - Provide
access_detailsinfile_metadatapointing to a CSV file in cloud storage.
リクエスト
Body Data (required)
dataThe data object containing the table definition.
attributesAttributes that define the reference table's configuration and properties.
descriptionOptional text describing the purpose or contents of this reference table.
file_metadataMetadata specifying where and how to access the reference table's data file.
Object 1Cloud storage file metadata for create requests. Both access_details and sync_enabled are required.
access_details [required]Cloud storage access configuration for the reference table data file.
aws_detailAmazon Web Services S3 storage access configuration.
aws_account_id [required]AWS account ID where the S3 bucket is located.
aws_bucket_name [required]S3 bucket containing the CSV file.
file_path [required]The relative file path from the S3 bucket root to the CSV file.
azure_detailAzure Blob Storage access configuration.
azure_client_id [required]Azure service principal (application) client ID with permissions to read from the container.
azure_container_name [required]Azure Blob Storage container containing the CSV file.
azure_storage_account_name [required]Azure storage account where the container is located.
azure_tenant_id [required]Azure Active Directory tenant ID.
file_path [required]The relative file path from the Azure container root to the CSV file.
gcp_detailGoogle Cloud Platform storage access configuration.
file_path [required]The relative file path from the GCS bucket root to the CSV file.
gcp_bucket_name [required]GCP bucket containing the CSV file.
gcp_project_id [required]GCP project ID where the bucket is located.
gcp_service_account_email [required]Service account email with read permissions for the GCS bucket.
sync_enabled [required]Whether this table is synced automatically.
Object 2Local file metadata for create requests using the upload ID.
upload_id [required]The upload ID.
schema [required]Schema defining the structure and columns of the reference table.
fields [required]The schema fields. Maximum of 200 columns.
name [required]The field name.
type [required]The field type for reference table schema fields.
STRING, INT32primary_keys [required]List of field names that serve as primary keys for the table. Only one primary key is supported, and it is used as an ID to retrieve rows.
source [required]The source type for creating reference table data. Only these source types can be created through this API.
LOCAL_FILE, S3, GCS, AZUREtable_name [required]Name to identify this reference table.
tagsTags for organizing and filtering reference tables.
type [required]Reference table resource type.
reference_tablereference_table{
"data": {
"attributes": {
"description": "string",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "123456789000",
"aws_bucket_name": "example-data-bucket",
"file_path": "reference-tables/users.csv"
},
"azure_detail": {
"azure_client_id": "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb",
"azure_container_name": "reference-data",
"azure_storage_account_name": "examplestorageaccount",
"azure_tenant_id": "cccccccc-4444-5555-6666-dddddddddddd",
"file_path": "tables/users.csv"
},
"gcp_detail": {
"file_path": "data/reference_tables/users.csv",
"gcp_bucket_name": "example-data-bucket",
"gcp_project_id": "example-gcp-project-12345",
"gcp_service_account_email": "example-service@example-gcp-project-12345.iam.gserviceaccount.com"
}
},
"sync_enabled": false
},
"schema": {
"fields": [
{
"name": "field_1",
"type": "STRING"
}
],
"primary_keys": [
"field_1"
]
},
"source": "LOCAL_FILE",
"table_name": "table_1",
"tags": [
"tag_1",
"tag_2"
]
},
"type": "reference_table"
}
}応答
Created
A reference table resource containing its full configuration and state.
dataThe data object containing the reference table configuration and state.
attributesAttributes that define the reference table's configuration and properties.
created_byUUID of the user who created the reference table.
descriptionOptional text describing the purpose or contents of this reference table.
file_metadataMetadata specifying where and how to access the reference table's data file.
For cloud storage tables (S3/GCS/Azure):
- sync_enabled and access_details will always be present
- error fields (error_message, error_row_count, error_type) are present only when errors occur
For local file tables:
- error fields (error_message, error_row_count) are present only when errors occur
- sync_enabled, access_details are never present
access_detailsCloud storage access configuration. Only present for cloud storage sources (S3, GCS, Azure).
aws_detailAmazon Web Services S3 storage access configuration.
aws_account_idAWS account ID where the S3 bucket is located.
aws_bucket_nameS3 bucket containing the CSV file.
file_pathThe relative file path from the S3 bucket root to the CSV file.
azure_detailAzure Blob Storage access configuration.
azure_client_idAzure service principal (application) client ID with permissions to read from the container.
azure_container_nameAzure Blob Storage container containing the CSV file.
azure_storage_account_nameAzure storage account where the container is located.
azure_tenant_idAzure Active Directory tenant ID.
file_pathThe relative file path from the Azure container root to the CSV file.
gcp_detailGoogle Cloud Platform storage access configuration.
file_pathThe relative file path from the GCS bucket root to the CSV file.
gcp_bucket_nameGCP bucket containing the CSV file.
gcp_project_idGCP project ID where the bucket is located.
gcp_service_account_emailService account email with read permissions for the GCS bucket.
error_messageThe error message returned from the last operation (sync for cloud storage, upload for local file).
error_row_countThe number of rows that failed to process.
error_typeThe type of error that occurred during file processing. Only applicable for cloud storage sources.
TABLE_SCHEMA_ERROR, FILE_FORMAT_ERROR, CONFIGURATION_ERROR, QUOTA_EXCEEDED, CONFLICT_ERROR, VALIDATION_ERROR, STATE_ERROR, OPERATION_ERROR, SYSTEM_ERRORsync_enabledWhether this table is synced automatically from cloud storage. Only applicable for cloud storage sources.
last_updated_byUUID of the user who last updated the reference table.
row_countThe number of successfully processed rows in the reference table.
schemaSchema defining the structure and columns of the reference table.
fields [required]The schema fields. Maximum of 200 columns.
name [required]The field name.
type [required]The field type for reference table schema fields.
STRING, INT32primary_keys [required]List of field names that serve as primary keys for the table. Only one primary key is supported, and it is used as an ID to retrieve rows.
sourceThe source type for reference table data. Includes all possible source types that can appear in responses.
LOCAL_FILE, S3, GCS, AZURE, SERVICENOW, SALESFORCE, DATABRICKS, SNOWFLAKEstatusThe processing status of the table.
table_nameUnique name to identify this reference table. Used in enrichment processors and API calls.
tagsTags for organizing and filtering reference tables.
updated_atWhen the reference table was last updated, in ISO 8601 format.
idUnique identifier for the reference table.
type [required]Reference table resource type.
reference_tablereference_table{
"data": {
"attributes": {
"created_by": "00000000-0000-0000-0000-000000000000",
"description": "example description",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "123456789000",
"aws_bucket_name": "my-bucket",
"file_path": "path/to/file.csv"
}
},
"sync_enabled": true
},
"last_updated_by": "00000000-0000-0000-0000-000000000000",
"row_count": 5,
"schema": {
"fields": [
{
"name": "id",
"type": "INT32"
},
{
"name": "name",
"type": "STRING"
}
],
"primary_keys": [
"id"
]
},
"source": "S3",
"status": "DONE",
"table_name": "test_reference_table",
"tags": [
"tag1",
"tag2"
],
"updated_at": "2000-01-01T01:00:00+00:00"
},
"id": "00000000-0000-0000-0000-000000000000",
"type": "reference_table"
}
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"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"
]
}コード例
## Create table from cloud storage (S3)
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## default
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## Create table from local file upload
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Product catalog uploaded via local file",
"file_metadata": {
"upload_id": "00000000-0000-0000-0000-000000000000"
},
"schema": {
"fields": [
{
"name": "product_id",
"type": "STRING"
},
{
"name": "product_name",
"type": "STRING"
},
{
"name": "price",
"type": "DOUBLE"
}
],
"primary_keys": [
"product_id"
]
},
"source": "LOCAL_FILE",
"table_name": "product_catalog",
"tags": [
"team:ecommerce"
]
},
"type": "reference_table"
}
}
EOF## Create table from cloud storage (S3)
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## default
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## Create table from local file upload
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Product catalog uploaded via local file",
"file_metadata": {
"upload_id": "00000000-0000-0000-0000-000000000000"
},
"schema": {
"fields": [
{
"name": "product_id",
"type": "STRING"
},
{
"name": "product_name",
"type": "STRING"
},
{
"name": "price",
"type": "DOUBLE"
}
],
"primary_keys": [
"product_id"
]
},
"source": "LOCAL_FILE",
"table_name": "product_catalog",
"tags": [
"team:ecommerce"
]
},
"type": "reference_table"
}
}
EOF## Create table from cloud storage (S3)
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## default
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## Create table from local file upload
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Product catalog uploaded via local file",
"file_metadata": {
"upload_id": "00000000-0000-0000-0000-000000000000"
},
"schema": {
"fields": [
{
"name": "product_id",
"type": "STRING"
},
{
"name": "product_name",
"type": "STRING"
},
{
"name": "price",
"type": "DOUBLE"
}
],
"primary_keys": [
"product_id"
]
},
"source": "LOCAL_FILE",
"table_name": "product_catalog",
"tags": [
"team:ecommerce"
]
},
"type": "reference_table"
}
}
EOF## Create table from cloud storage (S3)
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## default
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## Create table from local file upload
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Product catalog uploaded via local file",
"file_metadata": {
"upload_id": "00000000-0000-0000-0000-000000000000"
},
"schema": {
"fields": [
{
"name": "product_id",
"type": "STRING"
},
{
"name": "product_name",
"type": "STRING"
},
{
"name": "price",
"type": "DOUBLE"
}
],
"primary_keys": [
"product_id"
]
},
"source": "LOCAL_FILE",
"table_name": "product_catalog",
"tags": [
"team:ecommerce"
]
},
"type": "reference_table"
}
}
EOF## Create table from cloud storage (S3)
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## default
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## Create table from local file upload
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Product catalog uploaded via local file",
"file_metadata": {
"upload_id": "00000000-0000-0000-0000-000000000000"
},
"schema": {
"fields": [
{
"name": "product_id",
"type": "STRING"
},
{
"name": "product_name",
"type": "STRING"
},
{
"name": "price",
"type": "DOUBLE"
}
],
"primary_keys": [
"product_id"
]
},
"source": "LOCAL_FILE",
"table_name": "product_catalog",
"tags": [
"team:ecommerce"
]
},
"type": "reference_table"
}
}
EOF## Create table from cloud storage (S3)
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## default
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## Create table from local file upload
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Product catalog uploaded via local file",
"file_metadata": {
"upload_id": "00000000-0000-0000-0000-000000000000"
},
"schema": {
"fields": [
{
"name": "product_id",
"type": "STRING"
},
{
"name": "product_name",
"type": "STRING"
},
{
"name": "price",
"type": "DOUBLE"
}
],
"primary_keys": [
"product_id"
]
},
"source": "LOCAL_FILE",
"table_name": "product_catalog",
"tags": [
"team:ecommerce"
]
},
"type": "reference_table"
}
}
EOF## Create table from cloud storage (S3)
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## default
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## Create table from local file upload
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Product catalog uploaded via local file",
"file_metadata": {
"upload_id": "00000000-0000-0000-0000-000000000000"
},
"schema": {
"fields": [
{
"name": "product_id",
"type": "STRING"
},
{
"name": "product_name",
"type": "STRING"
},
{
"name": "price",
"type": "DOUBLE"
}
],
"primary_keys": [
"product_id"
]
},
"source": "LOCAL_FILE",
"table_name": "product_catalog",
"tags": [
"team:ecommerce"
]
},
"type": "reference_table"
}
}
EOF## Create table from cloud storage (S3)
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## default
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## Create table from local file upload
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Product catalog uploaded via local file",
"file_metadata": {
"upload_id": "00000000-0000-0000-0000-000000000000"
},
"schema": {
"fields": [
{
"name": "product_id",
"type": "STRING"
},
{
"name": "product_name",
"type": "STRING"
},
{
"name": "price",
"type": "DOUBLE"
}
],
"primary_keys": [
"product_id"
]
},
"source": "LOCAL_FILE",
"table_name": "product_catalog",
"tags": [
"team:ecommerce"
]
},
"type": "reference_table"
}
}
EOF## Create table from cloud storage (S3)
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## default
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Customer reference data synced from S3",
"file_metadata": {
"access_details": {
"aws_detail": {
"aws_account_id": "924305315327",
"aws_bucket_name": "my-data-bucket",
"file_path": "customers.csv"
}
},
"sync_enabled": true
},
"schema": {
"fields": [
{
"name": "customer_id",
"type": "STRING"
},
{
"name": "customer_name",
"type": "STRING"
},
{
"name": "email",
"type": "STRING"
}
],
"primary_keys": [
"customer_id"
]
},
"source": "S3",
"table_name": "customer_reference_data",
"tags": [
"team:data-platform"
]
},
"type": "reference_table"
}
}
EOF
## Create table from local file upload
# 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/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Product catalog uploaded via local file",
"file_metadata": {
"upload_id": "00000000-0000-0000-0000-000000000000"
},
"schema": {
"fields": [
{
"name": "product_id",
"type": "STRING"
},
{
"name": "product_name",
"type": "STRING"
},
{
"name": "price",
"type": "DOUBLE"
}
],
"primary_keys": [
"product_id"
]
},
"source": "LOCAL_FILE",
"table_name": "product_catalog",
"tags": [
"team:ecommerce"
]
},
"type": "reference_table"
}
}
EOF// Create reference table returns "Created" 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.CreateTableRequest{
Data: &datadogV2.CreateTableRequestData{
Attributes: &datadogV2.CreateTableRequestDataAttributes{
FileMetadata: &datadogV2.CreateTableRequestDataAttributesFileMetadata{
CreateTableRequestDataAttributesFileMetadataCloudStorage: &datadogV2.CreateTableRequestDataAttributesFileMetadataCloudStorage{
AccessDetails: datadogV2.CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails{
AwsDetail: &datadogV2.CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail{
AwsAccountId: "123456789000",
AwsBucketName: "example-data-bucket",
FilePath: "reference-tables/users.csv",
},
AzureDetail: &datadogV2.CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail{
AzureClientId: "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb",
AzureContainerName: "reference-data",
AzureStorageAccountName: "examplestorageaccount",
AzureTenantId: "cccccccc-4444-5555-6666-dddddddddddd",
FilePath: "tables/users.csv",
},
GcpDetail: &datadogV2.CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail{
FilePath: "data/reference_tables/users.csv",
GcpBucketName: "example-data-bucket",
GcpProjectId: "example-gcp-project-12345",
GcpServiceAccountEmail: "example-service@example-gcp-project-12345.iam.gserviceaccount.com",
},
},
SyncEnabled: false,
}},
Schema: datadogV2.CreateTableRequestDataAttributesSchema{
Fields: []datadogV2.CreateTableRequestDataAttributesSchemaFieldsItems{
{
Name: "field_1",
Type: datadogV2.REFERENCETABLESCHEMAFIELDTYPE_STRING,
},
},
PrimaryKeys: []string{
"field_1",
},
},
Source: datadogV2.REFERENCETABLECREATESOURCETYPE_LOCAL_FILE,
TableName: "table_1",
Tags: []string{
"tag_1",
"tag_2",
},
},
Type: datadogV2.CREATETABLEREQUESTDATATYPE_REFERENCE_TABLE,
},
}
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.NewReferenceTablesApi(apiClient)
resp, r, err := api.CreateReferenceTable(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ReferenceTablesApi.CreateReferenceTable`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `ReferenceTablesApi.CreateReferenceTable`:\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 reference table returns "Created" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ReferenceTablesApi;
import com.datadog.api.client.v2.model.CreateTableRequest;
import com.datadog.api.client.v2.model.CreateTableRequestData;
import com.datadog.api.client.v2.model.CreateTableRequestDataAttributes;
import com.datadog.api.client.v2.model.CreateTableRequestDataAttributesFileMetadata;
import com.datadog.api.client.v2.model.CreateTableRequestDataAttributesFileMetadataCloudStorage;
import com.datadog.api.client.v2.model.CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails;
import com.datadog.api.client.v2.model.CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail;
import com.datadog.api.client.v2.model.CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail;
import com.datadog.api.client.v2.model.CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail;
import com.datadog.api.client.v2.model.CreateTableRequestDataAttributesSchema;
import com.datadog.api.client.v2.model.CreateTableRequestDataAttributesSchemaFieldsItems;
import com.datadog.api.client.v2.model.CreateTableRequestDataType;
import com.datadog.api.client.v2.model.ReferenceTableCreateSourceType;
import com.datadog.api.client.v2.model.ReferenceTableSchemaFieldType;
import com.datadog.api.client.v2.model.TableResultV2;
import java.util.Arrays;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
ReferenceTablesApi apiInstance = new ReferenceTablesApi(defaultClient);
CreateTableRequest body =
new CreateTableRequest()
.data(
new CreateTableRequestData()
.attributes(
new CreateTableRequestDataAttributes()
.fileMetadata(
new CreateTableRequestDataAttributesFileMetadata(
new CreateTableRequestDataAttributesFileMetadataCloudStorage()
.accessDetails(
new CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails()
.awsDetail(
new CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail()
.awsAccountId("123456789000")
.awsBucketName("example-data-bucket")
.filePath("reference-tables/users.csv"))
.azureDetail(
new CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail()
.azureClientId(
"aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb")
.azureContainerName("reference-data")
.azureStorageAccountName(
"examplestorageaccount")
.azureTenantId(
"cccccccc-4444-5555-6666-dddddddddddd")
.filePath("tables/users.csv"))
.gcpDetail(
new CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail()
.filePath("data/reference_tables/users.csv")
.gcpBucketName("example-data-bucket")
.gcpProjectId("example-gcp-project-12345")
.gcpServiceAccountEmail(
"example-service@example-gcp-project-12345.iam.gserviceaccount.com")))
.syncEnabled(false)))
.schema(
new CreateTableRequestDataAttributesSchema()
.fields(
Collections.singletonList(
new CreateTableRequestDataAttributesSchemaFieldsItems()
.name("field_1")
.type(ReferenceTableSchemaFieldType.STRING)))
.primaryKeys(Collections.singletonList("field_1")))
.source(ReferenceTableCreateSourceType.LOCAL_FILE)
.tableName("table_1")
.tags(Arrays.asList("tag_1", "tag_2")))
.type(CreateTableRequestDataType.REFERENCE_TABLE));
try {
TableResultV2 result = apiInstance.createReferenceTable(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ReferenceTablesApi#createReferenceTable");
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 reference table returns "Created" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.reference_tables_api import ReferenceTablesApi
from datadog_api_client.v2.model.create_table_request import CreateTableRequest
from datadog_api_client.v2.model.create_table_request_data import CreateTableRequestData
from datadog_api_client.v2.model.create_table_request_data_attributes import CreateTableRequestDataAttributes
from datadog_api_client.v2.model.create_table_request_data_attributes_file_metadata_cloud_storage import (
CreateTableRequestDataAttributesFileMetadataCloudStorage,
)
from datadog_api_client.v2.model.create_table_request_data_attributes_file_metadata_one_of_access_details import (
CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails,
)
from datadog_api_client.v2.model.create_table_request_data_attributes_file_metadata_one_of_access_details_aws_detail import (
CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail,
)
from datadog_api_client.v2.model.create_table_request_data_attributes_file_metadata_one_of_access_details_azure_detail import (
CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail,
)
from datadog_api_client.v2.model.create_table_request_data_attributes_file_metadata_one_of_access_details_gcp_detail import (
CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail,
)
from datadog_api_client.v2.model.create_table_request_data_attributes_schema import (
CreateTableRequestDataAttributesSchema,
)
from datadog_api_client.v2.model.create_table_request_data_attributes_schema_fields_items import (
CreateTableRequestDataAttributesSchemaFieldsItems,
)
from datadog_api_client.v2.model.create_table_request_data_type import CreateTableRequestDataType
from datadog_api_client.v2.model.reference_table_create_source_type import ReferenceTableCreateSourceType
from datadog_api_client.v2.model.reference_table_schema_field_type import ReferenceTableSchemaFieldType
body = CreateTableRequest(
data=CreateTableRequestData(
attributes=CreateTableRequestDataAttributes(
file_metadata=CreateTableRequestDataAttributesFileMetadataCloudStorage(
access_details=CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails(
aws_detail=CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail(
aws_account_id="123456789000",
aws_bucket_name="example-data-bucket",
file_path="reference-tables/users.csv",
),
azure_detail=CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail(
azure_client_id="aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb",
azure_container_name="reference-data",
azure_storage_account_name="examplestorageaccount",
azure_tenant_id="cccccccc-4444-5555-6666-dddddddddddd",
file_path="tables/users.csv",
),
gcp_detail=CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail(
file_path="data/reference_tables/users.csv",
gcp_bucket_name="example-data-bucket",
gcp_project_id="example-gcp-project-12345",
gcp_service_account_email="example-service@example-gcp-project-12345.iam.gserviceaccount.com",
),
),
sync_enabled=False,
),
schema=CreateTableRequestDataAttributesSchema(
fields=[
CreateTableRequestDataAttributesSchemaFieldsItems(
name="field_1",
type=ReferenceTableSchemaFieldType.STRING,
),
],
primary_keys=[
"field_1",
],
),
source=ReferenceTableCreateSourceType.LOCAL_FILE,
table_name="table_1",
tags=[
"tag_1",
"tag_2",
],
),
type=CreateTableRequestDataType.REFERENCE_TABLE,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = ReferenceTablesApi(api_client)
response = api_instance.create_reference_table(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 reference table returns "Created" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::ReferenceTablesAPI.new
body = DatadogAPIClient::V2::CreateTableRequest.new({
data: DatadogAPIClient::V2::CreateTableRequestData.new({
attributes: DatadogAPIClient::V2::CreateTableRequestDataAttributes.new({
file_metadata: DatadogAPIClient::V2::CreateTableRequestDataAttributesFileMetadataCloudStorage.new({
access_details: DatadogAPIClient::V2::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails.new({
aws_detail: DatadogAPIClient::V2::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail.new({
aws_account_id: "123456789000",
aws_bucket_name: "example-data-bucket",
file_path: "reference-tables/users.csv",
}),
azure_detail: DatadogAPIClient::V2::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail.new({
azure_client_id: "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb",
azure_container_name: "reference-data",
azure_storage_account_name: "examplestorageaccount",
azure_tenant_id: "cccccccc-4444-5555-6666-dddddddddddd",
file_path: "tables/users.csv",
}),
gcp_detail: DatadogAPIClient::V2::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail.new({
file_path: "data/reference_tables/users.csv",
gcp_bucket_name: "example-data-bucket",
gcp_project_id: "example-gcp-project-12345",
gcp_service_account_email: "example-service@example-gcp-project-12345.iam.gserviceaccount.com",
}),
}),
sync_enabled: false,
}),
schema: DatadogAPIClient::V2::CreateTableRequestDataAttributesSchema.new({
fields: [
DatadogAPIClient::V2::CreateTableRequestDataAttributesSchemaFieldsItems.new({
name: "field_1",
type: DatadogAPIClient::V2::ReferenceTableSchemaFieldType::STRING,
}),
],
primary_keys: [
"field_1",
],
}),
source: DatadogAPIClient::V2::ReferenceTableCreateSourceType::LOCAL_FILE,
table_name: "table_1",
tags: [
"tag_1",
"tag_2",
],
}),
type: DatadogAPIClient::V2::CreateTableRequestDataType::REFERENCE_TABLE,
}),
})
p api_instance.create_reference_table(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 reference table returns "Created" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_reference_tables::ReferenceTablesAPI;
use datadog_api_client::datadogV2::model::CreateTableRequest;
use datadog_api_client::datadogV2::model::CreateTableRequestData;
use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributes;
use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesFileMetadata;
use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesFileMetadataCloudStorage;
use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails;
use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail;
use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail;
use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail;
use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesSchema;
use datadog_api_client::datadogV2::model::CreateTableRequestDataAttributesSchemaFieldsItems;
use datadog_api_client::datadogV2::model::CreateTableRequestDataType;
use datadog_api_client::datadogV2::model::ReferenceTableCreateSourceType;
use datadog_api_client::datadogV2::model::ReferenceTableSchemaFieldType;
#[tokio::main]
async fn main() {
let body =
CreateTableRequest
::new().data(
CreateTableRequestData::new(
CreateTableRequestDataType::REFERENCE_TABLE,
).attributes(
CreateTableRequestDataAttributes::new(
CreateTableRequestDataAttributesSchema::new(
vec![
CreateTableRequestDataAttributesSchemaFieldsItems::new(
"field_1".to_string(),
ReferenceTableSchemaFieldType::STRING,
)
],
vec!["field_1".to_string()],
),
ReferenceTableCreateSourceType::LOCAL_FILE,
"table_1".to_string(),
)
.file_metadata(
CreateTableRequestDataAttributesFileMetadata
::CreateTableRequestDataAttributesFileMetadataCloudStorage(
Box::new(
CreateTableRequestDataAttributesFileMetadataCloudStorage::new(
CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails::new()
.aws_detail(
CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail
::new(
"123456789000".to_string(),
"example-data-bucket".to_string(),
"reference-tables/users.csv".to_string(),
),
)
.azure_detail(
CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail
::new(
"aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb".to_string(),
"reference-data".to_string(),
"examplestorageaccount".to_string(),
"cccccccc-4444-5555-6666-dddddddddddd".to_string(),
"tables/users.csv".to_string(),
),
)
.gcp_detail(
CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail
::new(
"data/reference_tables/users.csv".to_string(),
"example-data-bucket".to_string(),
"example-gcp-project-12345".to_string(),
"example-service@example-gcp-project-12345.iam.gserviceaccount.com".to_string(),
),
),
false,
),
),
),
)
.tags(vec!["tag_1".to_string(), "tag_2".to_string()]),
),
);
let configuration = datadog::Configuration::new();
let api = ReferenceTablesAPI::with_config(configuration);
let resp = api.create_reference_table(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/**
* Create reference table returns "Created" 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.ReferenceTablesApi(configuration);
const params: v2.ReferenceTablesApiCreateReferenceTableRequest = {
body: {
data: {
attributes: {
fileMetadata: {
accessDetails: {
awsDetail: {
awsAccountId: "123456789000",
awsBucketName: "example-data-bucket",
filePath: "reference-tables/users.csv",
},
azureDetail: {
azureClientId: "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb",
azureContainerName: "reference-data",
azureStorageAccountName: "examplestorageaccount",
azureTenantId: "cccccccc-4444-5555-6666-dddddddddddd",
filePath: "tables/users.csv",
},
gcpDetail: {
filePath: "data/reference_tables/users.csv",
gcpBucketName: "example-data-bucket",
gcpProjectId: "example-gcp-project-12345",
gcpServiceAccountEmail:
"example-service@example-gcp-project-12345.iam.gserviceaccount.com",
},
},
syncEnabled: false,
},
schema: {
fields: [
{
name: "field_1",
type: "STRING",
},
],
primaryKeys: ["field_1"],
},
source: "LOCAL_FILE",
tableName: "table_1",
tags: ["tag_1", "tag_2"],
},
type: "reference_table",
},
},
};
apiInstance
.createReferenceTable(params)
.then((data: v2.TableResultV2) => {
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"