Update reference table

PATCH https://api.ap1.datadoghq.com/api/v2/reference-tables/tables/{id}https://api.ap2.datadoghq.com/api/v2/reference-tables/tables/{id}https://api.datadoghq.eu/api/v2/reference-tables/tables/{id}https://api.ddog-gov.com/api/v2/reference-tables/tables/{id}https://api.us2.ddog-gov.com/api/v2/reference-tables/tables/{id}https://api.datadoghq.com/api/v2/reference-tables/tables/{id}https://api.us3.datadoghq.com/api/v2/reference-tables/tables/{id}https://api.us5.datadoghq.com/api/v2/reference-tables/tables/{id}

Overview

Update a reference table by ID. You can update the table’s data, description, and tags. Note: The source type cannot be changed after table creation. For data updates: For existing tables of type source:LOCAL_FILE, call POST api/v2/reference-tables/uploads first to get an upload ID, then PUT chunks of CSV data to each provided URL, and finally call this PATCH endpoint with the upload_id in file_metadata. For existing tables with source: types of S3, GCS, or AZURE, provide updated access_details in file_metadata pointing to a CSV file in the same type of cloud storage.

Arguments

Path Parameters

Name

Type

Description

id [required]

string

Unique identifier of the reference table to update

Request

Body Data (required)

Expand All

Field

Type

Description

data

object

The data object containing the partial table definition updates.

attributes

object

Attributes that define the updates to the reference table's configuration and properties.

description

string

Optional text describing the purpose or contents of this reference table.

file_metadata

 <oneOf>

Metadata specifying where and how to access the reference table's data file.

Option 1

object

Cloud storage file metadata for patch requests. Allows partial updates of access_details and sync_enabled.

access_details

object

Cloud storage access configuration for the reference table data file.

aws_detail

object

Amazon Web Services S3 storage access configuration.

aws_account_id

string

AWS account ID where the S3 bucket is located.

aws_bucket_name

string

S3 bucket containing the CSV file.

file_path

string

The relative file path from the S3 bucket root to the CSV file.

azure_detail

object

Azure Blob Storage access configuration.

azure_client_id

string

Azure service principal (application) client ID with permissions to read from the container.

azure_container_name

string

Azure Blob Storage container containing the CSV file.

azure_storage_account_name

string

Azure storage account where the container is located.

azure_tenant_id

string

Azure Active Directory tenant ID.

file_path

string

The relative file path from the Azure container root to the CSV file.

gcp_detail

object

Google Cloud Platform storage access configuration.

file_path

string

The relative file path from the GCS bucket root to the CSV file.

gcp_bucket_name

string

GCP bucket containing the CSV file.

gcp_project_id

string

GCP project ID where the bucket is located.

gcp_service_account_email

string

Service account email with read permissions for the GCS bucket.

sync_enabled

boolean

Whether this table is synced automatically.

Option 2

object

Local file metadata for patch requests using upload ID.

upload_id [required]

string

The upload ID.

schema

object

Schema defining the updates to the structure and columns of the reference table. Schema fields cannot be deleted or renamed.

fields [required]

[object]

The schema fields.

name [required]

string

The field name.

type [required]

enum

The field type for reference table schema fields. Allowed enum values: STRING,INT32

primary_keys [required]

[string]

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. Primary keys cannot be changed after table creation.

tags

[string]

Tags for organizing and filtering reference tables.

type [required]

enum

Reference table resource type. Allowed enum values: reference_table

default: reference_table

{
  "data": {
    "attributes": {
      "description": "example description",
      "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"
        ]
      },
      "tags": [
        "tag_1",
        "tag_2"
      ]
    },
    "type": "reference_table"
  }
}

Response

OK

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example

                  ## default
# 

# Path parameters
export id="CHANGE_ME"
# Curl command
curl -X PATCH "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/reference-tables/tables/${id}" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "data": { "attributes": { "description": "this is a cloud table generated via a cloud bucket sync", "file_metadata": { "access_details": { "aws_detail": { "aws_account_id": "test-account-id", "aws_bucket_name": "test-bucket", "file_path": "test_rt.csv" } }, "sync_enabled": true }, "schema": { "fields": [ { "name": "id", "type": "INT32" }, { "name": "name", "type": "STRING" } ], "primary_keys": [ "id" ] }, "tags": [ "test_tag" ] }, "type": "reference_table" } } EOF
"""
Update reference table returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.reference_tables_api import ReferenceTablesApi
from datadog_api_client.v2.model.patch_table_request import PatchTableRequest
from datadog_api_client.v2.model.patch_table_request_data import PatchTableRequestData
from datadog_api_client.v2.model.patch_table_request_data_attributes import PatchTableRequestDataAttributes
from datadog_api_client.v2.model.patch_table_request_data_attributes_file_metadata_cloud_storage import (
    PatchTableRequestDataAttributesFileMetadataCloudStorage,
)
from datadog_api_client.v2.model.patch_table_request_data_attributes_file_metadata_one_of_access_details import (
    PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails,
)
from datadog_api_client.v2.model.patch_table_request_data_attributes_file_metadata_one_of_access_details_aws_detail import (
    PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail,
)
from datadog_api_client.v2.model.patch_table_request_data_attributes_schema import PatchTableRequestDataAttributesSchema
from datadog_api_client.v2.model.patch_table_request_data_attributes_schema_fields_items import (
    PatchTableRequestDataAttributesSchemaFieldsItems,
)
from datadog_api_client.v2.model.patch_table_request_data_type import PatchTableRequestDataType
from datadog_api_client.v2.model.reference_table_schema_field_type import ReferenceTableSchemaFieldType

body = PatchTableRequest(
    data=PatchTableRequestData(
        attributes=PatchTableRequestDataAttributes(
            description="this is a cloud table generated via a cloud bucket sync",
            file_metadata=PatchTableRequestDataAttributesFileMetadataCloudStorage(
                access_details=PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails(
                    aws_detail=PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail(
                        aws_account_id="test-account-id",
                        aws_bucket_name="test-bucket",
                        file_path="test_rt.csv",
                    ),
                ),
                sync_enabled=True,
            ),
            schema=PatchTableRequestDataAttributesSchema(
                fields=[
                    PatchTableRequestDataAttributesSchemaFieldsItems(
                        name="id",
                        type=ReferenceTableSchemaFieldType.INT32,
                    ),
                    PatchTableRequestDataAttributesSchemaFieldsItems(
                        name="name",
                        type=ReferenceTableSchemaFieldType.STRING,
                    ),
                ],
                primary_keys=[
                    "id",
                ],
            ),
            tags=[
                "test_tag",
            ],
        ),
        type=PatchTableRequestDataType.REFERENCE_TABLE,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = ReferenceTablesApi(api_client)
    api_instance.update_reference_table(id="id", body=body)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Update reference table returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::ReferenceTablesAPI.new

body = DatadogAPIClient::V2::PatchTableRequest.new({
  data: DatadogAPIClient::V2::PatchTableRequestData.new({
    attributes: DatadogAPIClient::V2::PatchTableRequestDataAttributes.new({
      description: "this is a cloud table generated via a cloud bucket sync",
      file_metadata: DatadogAPIClient::V2::PatchTableRequestDataAttributesFileMetadataCloudStorage.new({
        access_details: DatadogAPIClient::V2::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails.new({
          aws_detail: DatadogAPIClient::V2::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail.new({
            aws_account_id: "test-account-id",
            aws_bucket_name: "test-bucket",
            file_path: "test_rt.csv",
          }),
        }),
        sync_enabled: true,
      }),
      schema: DatadogAPIClient::V2::PatchTableRequestDataAttributesSchema.new({
        fields: [
          DatadogAPIClient::V2::PatchTableRequestDataAttributesSchemaFieldsItems.new({
            name: "id",
            type: DatadogAPIClient::V2::ReferenceTableSchemaFieldType::INT32,
          }),
          DatadogAPIClient::V2::PatchTableRequestDataAttributesSchemaFieldsItems.new({
            name: "name",
            type: DatadogAPIClient::V2::ReferenceTableSchemaFieldType::STRING,
          }),
        ],
        primary_keys: [
          "id",
        ],
      }),
      tags: [
        "test_tag",
      ],
    }),
    type: DatadogAPIClient::V2::PatchTableRequestDataType::REFERENCE_TABLE,
  }),
})
p api_instance.update_reference_table("id", body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Update reference table returns "OK" response

package main

import (
	"context"
	"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.PatchTableRequest{
		Data: &datadogV2.PatchTableRequestData{
			Attributes: &datadogV2.PatchTableRequestDataAttributes{
				Description: datadog.PtrString("this is a cloud table generated via a cloud bucket sync"),
				FileMetadata: &datadogV2.PatchTableRequestDataAttributesFileMetadata{
					PatchTableRequestDataAttributesFileMetadataCloudStorage: &datadogV2.PatchTableRequestDataAttributesFileMetadataCloudStorage{
						AccessDetails: &datadogV2.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails{
							AwsDetail: &datadogV2.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail{
								AwsAccountId:  datadog.PtrString("test-account-id"),
								AwsBucketName: datadog.PtrString("test-bucket"),
								FilePath:      datadog.PtrString("test_rt.csv"),
							},
						},
						SyncEnabled: datadog.PtrBool(true),
					}},
				Schema: &datadogV2.PatchTableRequestDataAttributesSchema{
					Fields: []datadogV2.PatchTableRequestDataAttributesSchemaFieldsItems{
						{
							Name: "id",
							Type: datadogV2.REFERENCETABLESCHEMAFIELDTYPE_INT32,
						},
						{
							Name: "name",
							Type: datadogV2.REFERENCETABLESCHEMAFIELDTYPE_STRING,
						},
					},
					PrimaryKeys: []string{
						"id",
					},
				},
				Tags: []string{
					"test_tag",
				},
			},
			Type: datadogV2.PATCHTABLEREQUESTDATATYPE_REFERENCE_TABLE,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewReferenceTablesApi(apiClient)
	r, err := api.UpdateReferenceTable(ctx, "id", body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `ReferenceTablesApi.UpdateReferenceTable`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Update reference table returns "OK" 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.PatchTableRequest;
import com.datadog.api.client.v2.model.PatchTableRequestData;
import com.datadog.api.client.v2.model.PatchTableRequestDataAttributes;
import com.datadog.api.client.v2.model.PatchTableRequestDataAttributesFileMetadata;
import com.datadog.api.client.v2.model.PatchTableRequestDataAttributesFileMetadataCloudStorage;
import com.datadog.api.client.v2.model.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails;
import com.datadog.api.client.v2.model.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail;
import com.datadog.api.client.v2.model.PatchTableRequestDataAttributesSchema;
import com.datadog.api.client.v2.model.PatchTableRequestDataAttributesSchemaFieldsItems;
import com.datadog.api.client.v2.model.PatchTableRequestDataType;
import com.datadog.api.client.v2.model.ReferenceTableSchemaFieldType;
import java.util.Arrays;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    ReferenceTablesApi apiInstance = new ReferenceTablesApi(defaultClient);

    PatchTableRequest body =
        new PatchTableRequest()
            .data(
                new PatchTableRequestData()
                    .attributes(
                        new PatchTableRequestDataAttributes()
                            .description("this is a cloud table generated via a cloud bucket sync")
                            .fileMetadata(
                                new PatchTableRequestDataAttributesFileMetadata(
                                    new PatchTableRequestDataAttributesFileMetadataCloudStorage()
                                        .accessDetails(
                                            new PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails()
                                                .awsDetail(
                                                    new PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail()
                                                        .awsAccountId("test-account-id")
                                                        .awsBucketName("test-bucket")
                                                        .filePath("test_rt.csv")))
                                        .syncEnabled(true)))
                            .schema(
                                new PatchTableRequestDataAttributesSchema()
                                    .fields(
                                        Arrays.asList(
                                            new PatchTableRequestDataAttributesSchemaFieldsItems()
                                                .name("id")
                                                .type(ReferenceTableSchemaFieldType.INT32),
                                            new PatchTableRequestDataAttributesSchemaFieldsItems()
                                                .name("name")
                                                .type(ReferenceTableSchemaFieldType.STRING)))
                                    .primaryKeys(Collections.singletonList("id")))
                            .tags(Collections.singletonList("test_tag")))
                    .type(PatchTableRequestDataType.REFERENCE_TABLE));

    try {
      apiInstance.updateReferenceTable("id", body);
    } catch (ApiException e) {
      System.err.println("Exception when calling ReferenceTablesApi#updateReferenceTable");
      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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// Update reference table returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_reference_tables::ReferenceTablesAPI;
use datadog_api_client::datadogV2::model::PatchTableRequest;
use datadog_api_client::datadogV2::model::PatchTableRequestData;
use datadog_api_client::datadogV2::model::PatchTableRequestDataAttributes;
use datadog_api_client::datadogV2::model::PatchTableRequestDataAttributesFileMetadata;
use datadog_api_client::datadogV2::model::PatchTableRequestDataAttributesFileMetadataCloudStorage;
use datadog_api_client::datadogV2::model::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails;
use datadog_api_client::datadogV2::model::PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail;
use datadog_api_client::datadogV2::model::PatchTableRequestDataAttributesSchema;
use datadog_api_client::datadogV2::model::PatchTableRequestDataAttributesSchemaFieldsItems;
use datadog_api_client::datadogV2::model::PatchTableRequestDataType;
use datadog_api_client::datadogV2::model::ReferenceTableSchemaFieldType;

#[tokio::main]
async fn main() {
    let body =
        PatchTableRequest
        ::new().data(
            PatchTableRequestData::new(
                PatchTableRequestDataType::REFERENCE_TABLE,
            ).attributes(
                PatchTableRequestDataAttributes::new()
                    .description("this is a cloud table generated via a cloud bucket sync".to_string())
                    .file_metadata(
                        PatchTableRequestDataAttributesFileMetadata
                        ::PatchTableRequestDataAttributesFileMetadataCloudStorage(
                            Box::new(
                                PatchTableRequestDataAttributesFileMetadataCloudStorage::new()
                                    .access_details(
                                        PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails
                                        ::new().aws_detail(
                                            PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail
                                            ::new()
                                                .aws_account_id("test-account-id".to_string())
                                                .aws_bucket_name("test-bucket".to_string())
                                                .file_path("test_rt.csv".to_string()),
                                        ),
                                    )
                                    .sync_enabled(true),
                            ),
                        ),
                    )
                    .schema(
                        PatchTableRequestDataAttributesSchema::new(
                            vec![
                                PatchTableRequestDataAttributesSchemaFieldsItems::new(
                                    "id".to_string(),
                                    ReferenceTableSchemaFieldType::INT32,
                                ),
                                PatchTableRequestDataAttributesSchemaFieldsItems::new(
                                    "name".to_string(),
                                    ReferenceTableSchemaFieldType::STRING,
                                )
                            ],
                            vec!["id".to_string()],
                        ),
                    )
                    .tags(vec!["test_tag".to_string()]),
            ),
        );
    let configuration = datadog::Configuration::new();
    let api = ReferenceTablesAPI::with_config(configuration);
    let resp = api.update_reference_table("id".to_string(), body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}

Instructions

First install the library and its dependencies and then save the example to src/main.rs and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
 * Update reference table returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.ReferenceTablesApi(configuration);

const params: v2.ReferenceTablesApiUpdateReferenceTableRequest = {
  body: {
    data: {
      attributes: {
        description: "this is a cloud table generated via a cloud bucket sync",
        fileMetadata: {
          accessDetails: {
            awsDetail: {
              awsAccountId: "test-account-id",
              awsBucketName: "test-bucket",
              filePath: "test_rt.csv",
            },
          },
          syncEnabled: true,
        },
        schema: {
          fields: [
            {
              name: "id",
              type: "INT32",
            },
            {
              name: "name",
              type: "STRING",
            },
          ],
          primaryKeys: ["id"],
        },
        tags: ["test_tag"],
      },
      type: "reference_table",
    },
  },
  id: "id",
};

apiInstance
  .updateReferenceTable(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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"