diff --git a/datadog/fwprovider/data_source_datadog_reference_table.go b/datadog/fwprovider/data_source_datadog_reference_table.go new file mode 100644 index 0000000000..d0ce431ddc --- /dev/null +++ b/datadog/fwprovider/data_source_datadog_reference_table.go @@ -0,0 +1,458 @@ +package fwprovider + +import ( + "context" + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/terraform-providers/terraform-provider-datadog/datadog/internal/utils" +) + +var ( + _ datasource.DataSource = &datadogReferenceTableDataSource{} +) + +type datadogReferenceTableDataSource struct { + Api *datadogV2.ReferenceTablesApi + Auth context.Context +} + +type datadogReferenceTableDataSourceModel struct { + // Query Parameters (mutually exclusive) + ID types.String `tfsdk:"id"` + TableName types.String `tfsdk:"table_name"` + + // Computed values + CreatedBy types.String `tfsdk:"created_by"` + Description types.String `tfsdk:"description"` + LastUpdatedBy types.String `tfsdk:"last_updated_by"` + RowCount types.Int64 `tfsdk:"row_count"` + Source types.String `tfsdk:"source"` + Status types.String `tfsdk:"status"` + UpdatedAt types.String `tfsdk:"updated_at"` + Tags types.List `tfsdk:"tags"` + FileMetadata *fileMetadataModel `tfsdk:"file_metadata"` + Schema *schemaModel `tfsdk:"schema"` +} + +func NewDatadogReferenceTableDataSource() datasource.DataSource { + return &datadogReferenceTableDataSource{} +} + +func (d *datadogReferenceTableDataSource) Configure(_ context.Context, request datasource.ConfigureRequest, response *datasource.ConfigureResponse) { + providerData, _ := request.ProviderData.(*FrameworkProvider) + d.Api = providerData.DatadogApiInstances.GetReferenceTablesApiV2() + d.Auth = providerData.Auth +} + +func (d *datadogReferenceTableDataSource) Metadata(_ context.Context, request datasource.MetadataRequest, response *datasource.MetadataResponse) { + response.TypeName = "reference_table" +} + +func (d *datadogReferenceTableDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, response *datasource.SchemaResponse) { + response.Schema = schema.Schema{ + Description: "Use this data source to retrieve information about an existing Datadog reference table. Query by either table_name or id (mutually exclusive). Supports all source types including cloud storage (S3, GCS, Azure) and external integrations (ServiceNow, Salesforce, Databricks, Snowflake, LOCAL_FILE).", + Attributes: map[string]schema.Attribute{ + // Query Parameters (mutually exclusive) + "id": schema.StringAttribute{ + Optional: true, + Computed: true, + Description: "The UUID of the reference table. Either id or table_name must be specified, but not both.", + }, + "table_name": schema.StringAttribute{ + Optional: true, + Computed: true, + Description: "The name of the reference table. Either id or table_name must be specified, but not both.", + }, + // Computed values + "created_by": schema.StringAttribute{ + Computed: true, + Description: "UUID of the user who created the reference table.", + }, + "description": schema.StringAttribute{ + Computed: true, + Description: "The description of the reference table.", + }, + "last_updated_by": schema.StringAttribute{ + Computed: true, + Description: "UUID of the user who last updated the reference table.", + }, + "row_count": schema.Int64Attribute{ + Computed: true, + Description: "The number of successfully processed rows in the reference table.", + }, + "source": schema.StringAttribute{ + Computed: true, + Description: "The source type for the reference table (e.g., S3, GCS, AZURE, SERVICENOW, SALESFORCE, DATABRICKS, SNOWFLAKE, LOCAL_FILE).", + }, + "status": schema.StringAttribute{ + Computed: true, + Description: "The status of the reference table (e.g., DONE, PROCESSING, ERROR).", + }, + "updated_at": schema.StringAttribute{ + Computed: true, + Description: "The timestamp of the last update to the reference table in ISO 8601 format.", + }, + "tags": schema.ListAttribute{ + Computed: true, + Description: "The tags associated with the reference table.", + ElementType: types.StringType, + }, + }, + Blocks: map[string]schema.Block{ + "file_metadata": schema.SingleNestedBlock{ + Description: "File metadata for the reference table. Contains sync settings for cloud storage sources.", + Attributes: map[string]schema.Attribute{ + "sync_enabled": schema.BoolAttribute{ + Computed: true, + Description: "Whether automatic sync is enabled for this table. Only present for cloud storage sources (S3, GCS, Azure).", + }, + "error_message": schema.StringAttribute{ + Computed: true, + Description: "Error message from the last sync attempt, if any.", + }, + "error_row_count": schema.Int64Attribute{ + Computed: true, + Description: "The number of rows that failed to sync.", + }, + "error_type": schema.StringAttribute{ + Computed: true, + Description: "The type of error that occurred during file processing. Only present for cloud storage sources.", + }, + }, + Blocks: map[string]schema.Block{ + "access_details": schema.SingleNestedBlock{ + Description: "Cloud storage access configuration. Only present for cloud storage sources (S3, GCS, Azure).", + Blocks: map[string]schema.Block{ + "aws_detail": schema.SingleNestedBlock{ + Description: "AWS S3 access configuration.", + Attributes: map[string]schema.Attribute{ + "aws_account_id": schema.StringAttribute{ + Computed: true, + Description: "The ID of the AWS account.", + }, + "aws_bucket_name": schema.StringAttribute{ + Computed: true, + Description: "The name of the AWS S3 bucket.", + }, + "file_path": schema.StringAttribute{ + Computed: true, + Description: "The relative file path from the S3 bucket root.", + }, + }, + }, + "gcp_detail": schema.SingleNestedBlock{ + Description: "Google Cloud Storage access configuration.", + Attributes: map[string]schema.Attribute{ + "gcp_project_id": schema.StringAttribute{ + Computed: true, + Description: "The ID of the GCP project.", + }, + "gcp_bucket_name": schema.StringAttribute{ + Computed: true, + Description: "The name of the GCP bucket.", + }, + "file_path": schema.StringAttribute{ + Computed: true, + Description: "The relative file path from the GCS bucket root.", + }, + "gcp_service_account_email": schema.StringAttribute{ + Computed: true, + Description: "The email of the GCP service account.", + }, + }, + }, + "azure_detail": schema.SingleNestedBlock{ + Description: "Azure Blob Storage access configuration.", + Attributes: map[string]schema.Attribute{ + "azure_tenant_id": schema.StringAttribute{ + Computed: true, + Description: "The ID of the Azure tenant.", + }, + "azure_client_id": schema.StringAttribute{ + Computed: true, + Description: "The Azure client ID.", + }, + "azure_storage_account_name": schema.StringAttribute{ + Computed: true, + Description: "The name of the Azure storage account.", + }, + "azure_container_name": schema.StringAttribute{ + Computed: true, + Description: "The name of the Azure container.", + }, + "file_path": schema.StringAttribute{ + Computed: true, + Description: "The relative file path from the Azure container root.", + }, + }, + }, + }, + }, + }, + }, + "schema": schema.SingleNestedBlock{ + Description: "The schema definition for the reference table.", + Attributes: map[string]schema.Attribute{ + "primary_keys": schema.ListAttribute{ + Computed: true, + Description: "List of field names that serve as primary keys for the table.", + ElementType: types.StringType, + }, + }, + Blocks: map[string]schema.Block{ + "fields": schema.ListNestedBlock{ + Description: "List of fields in the table schema.", + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + Computed: true, + Description: "The name of the field.", + }, + "type": schema.StringAttribute{ + Computed: true, + Description: "The data type of the field (e.g., STRING, INT32).", + }, + }, + }, + }, + }, + }, + }, + } +} + +func (d *datadogReferenceTableDataSource) Read(ctx context.Context, request datasource.ReadRequest, response *datasource.ReadResponse) { + var state datadogReferenceTableDataSourceModel + response.Diagnostics.Append(request.Config.Get(ctx, &state)...) + if response.Diagnostics.HasError() { + return + } + + // Validate that exactly one of id or table_name is specified + hasID := !state.ID.IsNull() && state.ID.ValueString() != "" + hasTableName := !state.TableName.IsNull() && state.TableName.ValueString() != "" + + if !hasID && !hasTableName { + response.Diagnostics.AddError( + "Missing required argument", + "Either 'id' or 'table_name' must be specified", + ) + return + } + + if hasID && hasTableName { + response.Diagnostics.AddError( + "Conflicting arguments", + "Only one of 'id' or 'table_name' can be specified, not both", + ) + return + } + + // Query by ID + if hasID { + tableId := state.ID.ValueString() + ddResp, _, err := d.Api.GetTable(d.Auth, tableId) + if err != nil { + response.Diagnostics.Append(utils.FrameworkErrorDiag(err, "error getting datadog reference table")) + return + } + + d.updateState(ctx, &state, ddResp.Data) + } else { + // Query by table_name using list endpoint with exact match + tableName := state.TableName.ValueString() + optionalParams := datadogV2.ListTablesOptionalParameters{ + FilterTableNameExact: &tableName, + } + + ddResp, _, err := d.Api.ListTables(d.Auth, optionalParams) + if err != nil { + response.Diagnostics.Append(utils.FrameworkErrorDiag(err, "error listing datadog reference tables")) + return + } + + if len(ddResp.Data) == 0 { + response.Diagnostics.AddError( + "Reference table not found", + fmt.Sprintf("No reference table found with table_name='%s'", tableName), + ) + return + } + + if len(ddResp.Data) > 1 { + response.Diagnostics.AddError( + "Multiple reference tables found", + fmt.Sprintf("Found %d reference tables with table_name='%s', expected exactly 1", len(ddResp.Data), tableName), + ) + return + } + + // Get full details using the ID from list response + tableId := ddResp.Data[0].GetId() + fullResp, _, err := d.Api.GetTable(d.Auth, tableId) + if err != nil { + response.Diagnostics.Append(utils.FrameworkErrorDiag(err, "error getting datadog reference table details")) + return + } + + d.updateState(ctx, &state, fullResp.Data) + } + + // Save data into Terraform state + response.Diagnostics.Append(response.State.Set(ctx, &state)...) +} + +func (d *datadogReferenceTableDataSource) updateState(ctx context.Context, state *datadogReferenceTableDataSourceModel, referenceTableData *datadogV2.TableResultV2Data) { + attributes := referenceTableData.GetAttributes() + + // Set basic attributes + state.ID = types.StringValue(referenceTableData.GetId()) + state.TableName = types.StringValue(attributes.GetTableName()) + + if createdBy, ok := attributes.GetCreatedByOk(); ok { + state.CreatedBy = types.StringValue(*createdBy) + } + + if description, ok := attributes.GetDescriptionOk(); ok { + state.Description = types.StringValue(*description) + } + + if lastUpdatedBy, ok := attributes.GetLastUpdatedByOk(); ok { + state.LastUpdatedBy = types.StringValue(*lastUpdatedBy) + } + + if rowCount, ok := attributes.GetRowCountOk(); ok { + state.RowCount = types.Int64Value(int64(*rowCount)) + } + + if source, ok := attributes.GetSourceOk(); ok { + state.Source = types.StringValue(string(*source)) + } + + if status, ok := attributes.GetStatusOk(); ok { + state.Status = types.StringValue(*status) + } + + if updatedAt, ok := attributes.GetUpdatedAtOk(); ok { + state.UpdatedAt = types.StringValue(*updatedAt) + } + + if tags, ok := attributes.GetTagsOk(); ok && len(*tags) > 0 { + state.Tags, _ = types.ListValueFrom(ctx, types.StringType, *tags) + } + + // Handle FileMetadata from API response (flattened structure, no longer OneOf) + if fileMetadata, ok := attributes.GetFileMetadataOk(); ok { + fileMetadataTf := &fileMetadataModel{} + + // FileMetadata is now a flattened struct with direct fields + if syncEnabled, ok := fileMetadata.GetSyncEnabledOk(); ok { + fileMetadataTf.SyncEnabled = types.BoolValue(*syncEnabled) + } + + if errorMessage, ok := fileMetadata.GetErrorMessageOk(); ok { + fileMetadataTf.ErrorMessage = types.StringValue(*errorMessage) + } + + if errorRowCount, ok := fileMetadata.GetErrorRowCountOk(); ok { + fileMetadataTf.ErrorRowCount = types.Int64Value(*errorRowCount) + } + + if errorType, ok := fileMetadata.GetErrorTypeOk(); ok { + fileMetadataTf.ErrorType = types.StringValue(string(*errorType)) + } + + // Extract access_details (only present for cloud storage sources) + if accessDetails, ok := fileMetadata.GetAccessDetailsOk(); ok { + accessDetailsTf := &accessDetailsModel{} + + // AWS details + if awsDetail := accessDetails.AwsDetail; awsDetail != nil { + awsDetailTf := &awsDetailModel{} + if awsAccountId, ok := awsDetail.GetAwsAccountIdOk(); ok { + awsDetailTf.AwsAccountId = types.StringValue(*awsAccountId) + } + if awsBucketName, ok := awsDetail.GetAwsBucketNameOk(); ok { + awsDetailTf.AwsBucketName = types.StringValue(*awsBucketName) + } + if filePath, ok := awsDetail.GetFilePathOk(); ok { + awsDetailTf.FilePath = types.StringValue(*filePath) + } + accessDetailsTf.AwsDetail = awsDetailTf + } + + // GCP details + if gcpDetail := accessDetails.GcpDetail; gcpDetail != nil { + gcpDetailTf := &gcpDetailModel{} + if gcpProjectId, ok := gcpDetail.GetGcpProjectIdOk(); ok { + gcpDetailTf.GcpProjectId = types.StringValue(*gcpProjectId) + } + if gcpBucketName, ok := gcpDetail.GetGcpBucketNameOk(); ok { + gcpDetailTf.GcpBucketName = types.StringValue(*gcpBucketName) + } + if filePath, ok := gcpDetail.GetFilePathOk(); ok { + gcpDetailTf.FilePath = types.StringValue(*filePath) + } + if gcpServiceAccountEmail, ok := gcpDetail.GetGcpServiceAccountEmailOk(); ok { + gcpDetailTf.GcpServiceAccountEmail = types.StringValue(*gcpServiceAccountEmail) + } + accessDetailsTf.GcpDetail = gcpDetailTf + } + + // Azure details + if azureDetail := accessDetails.AzureDetail; azureDetail != nil { + azureDetailTf := &azureDetailModel{} + if azureTenantId, ok := azureDetail.GetAzureTenantIdOk(); ok { + azureDetailTf.AzureTenantId = types.StringValue(*azureTenantId) + } + if azureClientId, ok := azureDetail.GetAzureClientIdOk(); ok { + azureDetailTf.AzureClientId = types.StringValue(*azureClientId) + } + if azureStorageAccountName, ok := azureDetail.GetAzureStorageAccountNameOk(); ok { + azureDetailTf.AzureStorageAccountName = types.StringValue(*azureStorageAccountName) + } + if azureContainerName, ok := azureDetail.GetAzureContainerNameOk(); ok { + azureDetailTf.AzureContainerName = types.StringValue(*azureContainerName) + } + if filePath, ok := azureDetail.GetFilePathOk(); ok { + azureDetailTf.FilePath = types.StringValue(*filePath) + } + accessDetailsTf.AzureDetail = azureDetailTf + } + + fileMetadataTf.AccessDetails = accessDetailsTf + } + + state.FileMetadata = fileMetadataTf + } + + // Handle Schema + if schema, ok := attributes.GetSchemaOk(); ok { + schemaTf := &schemaModel{} + + if primaryKeys, ok := schema.GetPrimaryKeysOk(); ok && len(*primaryKeys) > 0 { + schemaTf.PrimaryKeys, _ = types.ListValueFrom(ctx, types.StringType, *primaryKeys) + } + + if fields, ok := schema.GetFieldsOk(); ok && len(*fields) > 0 { + schemaTf.Fields = []*fieldsModel{} + for _, fieldDd := range *fields { + fieldTf := &fieldsModel{} + if name, ok := fieldDd.GetNameOk(); ok { + fieldTf.Name = types.StringValue(*name) + } + if typeVar, ok := fieldDd.GetTypeOk(); ok { + fieldTf.Type = types.StringValue(string(*typeVar)) + } + schemaTf.Fields = append(schemaTf.Fields, fieldTf) + } + } + + state.Schema = schemaTf + } +} diff --git a/datadog/fwprovider/data_source_datadog_reference_table_rows.go b/datadog/fwprovider/data_source_datadog_reference_table_rows.go new file mode 100644 index 0000000000..ab5a2aab98 --- /dev/null +++ b/datadog/fwprovider/data_source_datadog_reference_table_rows.go @@ -0,0 +1,165 @@ +package fwprovider + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/terraform-providers/terraform-provider-datadog/datadog/internal/utils" +) + +var ( + _ datasource.DataSource = &datadogReferenceTableRowsDataSource{} +) + +type datadogReferenceTableRowsDataSource struct { + Api *datadogV2.ReferenceTablesApi + Auth context.Context +} + +type datadogReferenceTableRowsDataSourceModel struct { + // Query Parameters + TableId types.String `tfsdk:"table_id"` + RowIds types.List `tfsdk:"row_ids"` + + // Computed values (list of rows) + Rows []*rowModel `tfsdk:"rows"` +} + +type rowModel struct { + Id types.String `tfsdk:"id"` + Values types.Map `tfsdk:"values"` +} + +func NewDatadogReferenceTableRowsDataSource() datasource.DataSource { + return &datadogReferenceTableRowsDataSource{} +} + +func (d *datadogReferenceTableRowsDataSource) Configure(_ context.Context, request datasource.ConfigureRequest, response *datasource.ConfigureResponse) { + providerData, _ := request.ProviderData.(*FrameworkProvider) + d.Api = providerData.DatadogApiInstances.GetReferenceTablesApiV2() + d.Auth = providerData.Auth +} + +func (d *datadogReferenceTableRowsDataSource) Metadata(_ context.Context, request datasource.MetadataRequest, response *datasource.MetadataResponse) { + response.TypeName = "reference_table_rows" +} + +func (d *datadogReferenceTableRowsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, response *datasource.SchemaResponse) { + response.Schema = schema.Schema{ + Description: "Use this data source to retrieve specific rows from a Datadog reference table by their primary key values. Works with all reference table source types.", + Attributes: map[string]schema.Attribute{ + "table_id": schema.StringAttribute{ + Required: true, + Description: "The UUID of the reference table to query rows from.", + }, + "row_ids": schema.ListAttribute{ + Required: true, + Description: "List of primary key values (row IDs) to retrieve. These are the values of the table's primary key field(s).", + ElementType: types.StringType, + }, + }, + Blocks: map[string]schema.Block{ + "rows": schema.ListNestedBlock{ + Description: "List of retrieved rows. Each row contains its ID and field values.", + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + Description: "The primary key value of the row.", + }, + "values": schema.MapAttribute{ + Computed: true, + Description: "Map of field names to values for this row. All values are returned as strings.", + ElementType: types.StringType, + }, + }, + }, + }, + }, + } +} + +func (d *datadogReferenceTableRowsDataSource) Read(ctx context.Context, request datasource.ReadRequest, response *datasource.ReadResponse) { + var state datadogReferenceTableRowsDataSourceModel + response.Diagnostics.Append(request.Config.Get(ctx, &state)...) + if response.Diagnostics.HasError() { + return + } + + tableId := state.TableId.ValueString() + + // Extract row IDs from the list + var rowIds []string + response.Diagnostics.Append(state.RowIds.ElementsAs(ctx, &rowIds, false)...) + if response.Diagnostics.HasError() { + return + } + + // Call API to get rows by ID with retry logic + // Rows are written asynchronously, so we need to retry if the table hasn't synced yet + // Use a 5-second interval to avoid spamming the API while waiting for sync + var ddResp datadogV2.TableRowResourceArray + var httpResp *http.Response + var err error + + retryErr := utils.Retry(5*time.Second, 10, func() error { + ddResp, httpResp, err = d.Api.GetRowsByID(d.Auth, tableId, rowIds) + if err != nil { + // If we get a 404, the table might not have synced yet - retry + if httpResp != nil && httpResp.StatusCode == 404 { + return &utils.RetryableError{Prob: fmt.Sprintf("rows not found (table may not have synced yet): %v", err)} + } + // For other errors, don't retry + return &utils.FatalError{Prob: fmt.Sprintf("error getting reference table rows: %v", err)} + } + // Success - check if we got the expected number of rows + if len(ddResp.Data) == len(rowIds) { + return nil + } + // If we got some rows but not all, the table might still be syncing - retry + if len(ddResp.Data) > 0 && len(ddResp.Data) < len(rowIds) { + return &utils.RetryableError{Prob: fmt.Sprintf("only %d of %d rows found (table may still be syncing)", len(ddResp.Data), len(rowIds))} + } + // If we got no rows, retry + return &utils.RetryableError{Prob: "no rows found (table may not have synced yet)"} + }) + + if retryErr != nil { + response.Diagnostics.Append(utils.FrameworkErrorDiag(retryErr, "error getting reference table rows")) + return + } + + // Convert API response to state + state.Rows = make([]*rowModel, len(ddResp.Data)) + for i, row := range ddResp.Data { + rowTf := &rowModel{ + Id: types.StringValue(row.GetId()), + } + + // Convert values map to types.Map with string values + if attrs, ok := row.GetAttributesOk(); ok && attrs.Values != nil { + // Type assert Values to map[string]interface{} + if valuesMap, ok := attrs.Values.(map[string]interface{}); ok { + // Convert all values to strings for the map + stringValues := make(map[string]string) + for k, v := range valuesMap { + // Convert value to string representation + stringValues[k] = fmt.Sprintf("%v", v) + } + rowTf.Values, _ = types.MapValueFrom(ctx, types.StringType, stringValues) + } + } + + state.Rows[i] = rowTf + } + + // Save data into Terraform state + response.Diagnostics.Append(response.State.Set(ctx, &state)...) +} diff --git a/datadog/fwprovider/framework_provider.go b/datadog/fwprovider/framework_provider.go index aaace9e33d..06309f644d 100644 --- a/datadog/fwprovider/framework_provider.go +++ b/datadog/fwprovider/framework_provider.go @@ -107,6 +107,7 @@ var Resources = []func() resource.Resource{ NewDatadogCustomAllocationRuleResource, NewCustomAllocationRulesResource, NewAzureUcConfigResource, + NewReferenceTableResource, } var Datasources = []func() datasource.DataSource{ @@ -154,6 +155,8 @@ var Datasources = []func() datasource.DataSource{ NewDatadogGcpUcConfigDataSource, NewDatadogCustomAllocationRuleDataSource, NewDatadogAzureUcConfigDataSource, + NewDatadogReferenceTableDataSource, + NewDatadogReferenceTableRowsDataSource, } // FrameworkProvider struct diff --git a/datadog/fwprovider/models_reference_table.go b/datadog/fwprovider/models_reference_table.go new file mode 100644 index 0000000000..c0d44dfa71 --- /dev/null +++ b/datadog/fwprovider/models_reference_table.go @@ -0,0 +1,44 @@ +package fwprovider + +import ( + "github.com/hashicorp/terraform-plugin-framework/types" +) + +// Shared model definitions for reference table resource and data sources + +type schemaModel struct { + PrimaryKeys types.List `tfsdk:"primary_keys"` + Fields []*fieldsModel `tfsdk:"fields"` +} + +type fieldsModel struct { + Name types.String `tfsdk:"name"` + Type types.String `tfsdk:"type"` +} + +type accessDetailsModel struct { + AwsDetail *awsDetailModel `tfsdk:"aws_detail"` + AzureDetail *azureDetailModel `tfsdk:"azure_detail"` + GcpDetail *gcpDetailModel `tfsdk:"gcp_detail"` +} + +type awsDetailModel struct { + AwsAccountId types.String `tfsdk:"aws_account_id"` + AwsBucketName types.String `tfsdk:"aws_bucket_name"` + FilePath types.String `tfsdk:"file_path"` +} + +type azureDetailModel struct { + AzureTenantId types.String `tfsdk:"azure_tenant_id"` + AzureClientId types.String `tfsdk:"azure_client_id"` + AzureStorageAccountName types.String `tfsdk:"azure_storage_account_name"` + AzureContainerName types.String `tfsdk:"azure_container_name"` + FilePath types.String `tfsdk:"file_path"` +} + +type gcpDetailModel struct { + GcpProjectId types.String `tfsdk:"gcp_project_id"` + GcpBucketName types.String `tfsdk:"gcp_bucket_name"` + FilePath types.String `tfsdk:"file_path"` + GcpServiceAccountEmail types.String `tfsdk:"gcp_service_account_email"` +} diff --git a/datadog/fwprovider/resource_datadog_integration_gcp_sts.go b/datadog/fwprovider/resource_datadog_integration_gcp_sts.go index cd16a4ac09..d0c2391461 100644 --- a/datadog/fwprovider/resource_datadog_integration_gcp_sts.go +++ b/datadog/fwprovider/resource_datadog_integration_gcp_sts.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/terraform-providers/terraform-provider-datadog/datadog/internal/utils" ) diff --git a/datadog/fwprovider/resource_datadog_reference_table.go b/datadog/fwprovider/resource_datadog_reference_table.go new file mode 100644 index 0000000000..49c812653c --- /dev/null +++ b/datadog/fwprovider/resource_datadog_reference_table.go @@ -0,0 +1,1099 @@ +package fwprovider + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/diag" + frameworkPath "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/terraform-providers/terraform-provider-datadog/datadog/internal/utils" +) + +var ( + _ resource.ResourceWithConfigure = &referenceTableResource{} + _ resource.ResourceWithImportState = &referenceTableResource{} + _ resource.ResourceWithModifyPlan = &referenceTableResource{} +) + +type referenceTableResource struct { + Api *datadogV2.ReferenceTablesApi + Auth context.Context +} + +type referenceTableModel struct { + ID types.String `tfsdk:"id"` + Source types.String `tfsdk:"source"` + TableName types.String `tfsdk:"table_name"` + FileMetadata *fileMetadataModel `tfsdk:"file_metadata"` + Schema *schemaModel `tfsdk:"schema"` + CreatedBy types.String `tfsdk:"created_by"` + LastUpdatedBy types.String `tfsdk:"last_updated_by"` + RowCount types.Int64 `tfsdk:"row_count"` + Status types.String `tfsdk:"status"` + UpdatedAt types.String `tfsdk:"updated_at"` + Tags types.List `tfsdk:"tags"` + Description types.String `tfsdk:"description"` +} + +type fileMetadataModel struct { + SyncEnabled types.Bool `tfsdk:"sync_enabled"` + AccessDetails *accessDetailsModel `tfsdk:"access_details"` + ErrorMessage types.String `tfsdk:"error_message"` + ErrorRowCount types.Int64 `tfsdk:"error_row_count"` + ErrorType types.String `tfsdk:"error_type"` +} + +func NewReferenceTableResource() resource.Resource { + return &referenceTableResource{} +} + +func (r *referenceTableResource) Configure(_ context.Context, request resource.ConfigureRequest, response *resource.ConfigureResponse) { + providerData, _ := request.ProviderData.(*FrameworkProvider) + r.Api = providerData.DatadogApiInstances.GetReferenceTablesApiV2() + r.Auth = providerData.Auth +} + +func (r *referenceTableResource) Metadata(_ context.Context, request resource.MetadataRequest, response *resource.MetadataResponse) { + response.TypeName = "reference_table" +} + +func (r *referenceTableResource) Schema(_ context.Context, _ resource.SchemaRequest, response *resource.SchemaResponse) { + response.Schema = schema.Schema{ + Description: "Provides a Datadog Reference Table resource for cloud storage sources (S3, GCS, Azure). This can be used to create and manage Datadog reference tables that sync data from cloud storage.", + Attributes: map[string]schema.Attribute{ + "id": utils.ResourceIDAttribute(), + "table_name": schema.StringAttribute{ + Required: true, + Description: "The name of the reference table. This must be unique within your organization.", + }, + "source": schema.StringAttribute{ + Required: true, + Description: "The source type for the reference table. Must be one of: S3, GCS, AZURE.", + Validators: []validator.String{ + stringvalidator.OneOf("S3", "GCS", "AZURE"), + }, + }, + "description": schema.StringAttribute{ + Optional: true, + Description: "The description of the reference table.", + }, + "tags": schema.ListAttribute{ + Optional: true, + Description: "A list of tags to associate with the reference table.", + ElementType: types.StringType, + }, + // Computed attributes + "created_by": schema.StringAttribute{ + Computed: true, + Description: "UUID of the user who created the reference table.", + }, + "last_updated_by": schema.StringAttribute{ + Computed: true, + Description: "UUID of the user who last updated the reference table.", + }, + "row_count": schema.Int64Attribute{ + Computed: true, + Description: "The number of successfully processed rows in the reference table.", + // Removed UseStateForUnknown() to allow Terraform to accept changes to this computed value + // This is necessary for async resources where row_count changes as files are processed + }, + "status": schema.StringAttribute{ + Computed: true, + Description: "The status of the reference table (e.g., DONE, PROCESSING, ERROR).", + // Removed UseStateForUnknown() to allow Terraform to accept changes to this computed value + // This is necessary for async resources where status changes as files are processed + }, + "updated_at": schema.StringAttribute{ + Computed: true, + Description: "The timestamp of the last update to the reference table in ISO 8601 format.", + }, + }, + Blocks: map[string]schema.Block{ + "file_metadata": schema.SingleNestedBlock{ + Description: "Configuration for cloud storage file access and sync settings.", + Attributes: map[string]schema.Attribute{ + "sync_enabled": schema.BoolAttribute{ + Required: true, + Description: "Whether this table should automatically sync with the cloud storage source.", + }, + "error_message": schema.StringAttribute{ + Computed: true, + Description: "Error message from the last sync attempt, if any.", + }, + "error_row_count": schema.Int64Attribute{ + Computed: true, + Description: "The number of rows that failed to sync.", + }, + "error_type": schema.StringAttribute{ + Computed: true, + Description: "The type of error that occurred during file processing.", + }, + }, + Blocks: map[string]schema.Block{ + "access_details": schema.SingleNestedBlock{ + Description: "Cloud storage access configuration. Exactly one of aws_detail, gcp_detail, or azure_detail must be specified.", + Blocks: map[string]schema.Block{ + "aws_detail": schema.SingleNestedBlock{ + Description: "AWS S3 access configuration. Required when source is S3.", + Attributes: map[string]schema.Attribute{ + "aws_account_id": schema.StringAttribute{ + Optional: true, + Description: "The ID of the AWS account.", + }, + "aws_bucket_name": schema.StringAttribute{ + Optional: true, + Description: "The name of the Amazon S3 bucket.", + }, + "file_path": schema.StringAttribute{ + Optional: true, + Description: "The relative file path from the S3 bucket root to the CSV file.", + }, + }, + }, + "gcp_detail": schema.SingleNestedBlock{ + Description: "Google Cloud Storage access configuration. Required when source is GCS.", + Attributes: map[string]schema.Attribute{ + "gcp_project_id": schema.StringAttribute{ + Optional: true, + Description: "The ID of the GCP project.", + }, + "gcp_bucket_name": schema.StringAttribute{ + Optional: true, + Description: "The name of the GCP bucket.", + }, + "file_path": schema.StringAttribute{ + Optional: true, + Description: "The relative file path from the GCS bucket root to the CSV file.", + }, + "gcp_service_account_email": schema.StringAttribute{ + Optional: true, + Description: "The email of the GCP service account used to access the bucket.", + }, + }, + }, + "azure_detail": schema.SingleNestedBlock{ + Description: "Azure Blob Storage access configuration. Required when source is AZURE.", + Attributes: map[string]schema.Attribute{ + "azure_tenant_id": schema.StringAttribute{ + Optional: true, + Description: "The ID of the Azure tenant.", + }, + "azure_client_id": schema.StringAttribute{ + Optional: true, + Description: "The Azure client ID (application ID).", + }, + "azure_storage_account_name": schema.StringAttribute{ + Optional: true, + Description: "The name of the Azure storage account.", + }, + "azure_container_name": schema.StringAttribute{ + Optional: true, + Description: "The name of the Azure container.", + }, + "file_path": schema.StringAttribute{ + Optional: true, + Description: "The relative file path from the Azure container root to the CSV file.", + }, + }, + }, + }, + }, + }, + }, + "schema": schema.SingleNestedBlock{ + Description: "The schema definition for the reference table, including field definitions and primary keys.", + Attributes: map[string]schema.Attribute{ + "primary_keys": schema.ListAttribute{ + Required: true, + Description: "List of field names that serve as primary keys for the table. Currently only one primary key is supported.", + ElementType: types.StringType, + }, + }, + Blocks: map[string]schema.Block{ + "fields": schema.ListNestedBlock{ + Description: "List of fields in the table schema. Must include at least one field.", + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + Required: true, + Description: "The name of the field.", + }, + "type": schema.StringAttribute{ + Required: true, + Description: "The data type of the field. Must be one of: STRING, INT32.", + Validators: []validator.String{ + stringvalidator.OneOf("STRING", "INT32"), + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func (r *referenceTableResource) ImportState(ctx context.Context, request resource.ImportStateRequest, response *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, frameworkPath.Root("id"), request, response) +} + +func (r *referenceTableResource) Read(ctx context.Context, request resource.ReadRequest, response *resource.ReadResponse) { + var state referenceTableModel + response.Diagnostics.Append(request.State.Get(ctx, &state)...) + if response.Diagnostics.HasError() { + return + } + id := state.ID.ValueString() + + resp, httpResp, err := r.Api.GetTable(r.Auth, id) + if err != nil { + if httpResp != nil && httpResp.StatusCode == 404 { + response.State.RemoveResource(ctx) + return + } + response.Diagnostics.Append(utils.FrameworkErrorDiag(err, "error retrieving ReferenceTable")) + return + } + if err := utils.CheckForUnparsed(resp); err != nil { + response.Diagnostics.AddError("response contains unparsedObject", err.Error()) + return + } + + r.updateState(ctx, &state, &resp) + + // Save data into Terraform state + response.Diagnostics.Append(response.State.Set(ctx, &state)...) +} + +func (r *referenceTableResource) Create(ctx context.Context, request resource.CreateRequest, response *resource.CreateResponse) { + var state referenceTableModel + response.Diagnostics.Append(request.Plan.Get(ctx, &state)...) + if response.Diagnostics.HasError() { + return + } + + body, diags := r.buildReferenceTableRequestBody(ctx, &state) + response.Diagnostics.Append(diags...) + if response.Diagnostics.HasError() { + return + } + + resp, httpResp, err := r.Api.CreateReferenceTable(r.Auth, *body) + if err != nil { + response.Diagnostics.Append(utils.FrameworkErrorDiag(err, "error creating ReferenceTable")) + return + } + if err := utils.CheckForUnparsed(resp); err != nil { + response.Diagnostics.AddError("response contains unparsedObject", err.Error()) + return + } + + // If the create response doesn't include data, fetch it with a list+filter request + if resp.Data == nil { + if httpResp != nil && httpResp.StatusCode == 201 { + // Table was created successfully, but response was empty - list tables and find by exact name + tableName := state.TableName.ValueString() + listResp, _, listErr := r.Api.ListTables(r.Auth) + if listErr != nil { + response.Diagnostics.Append(utils.FrameworkErrorDiag(listErr, "table created but error listing tables")) + return + } + + // Find the table by exact name match + var foundTable *datadogV2.TableResultV2Data + if listResp.Data != nil { + for _, table := range listResp.Data { + if attrs, ok := table.GetAttributesOk(); ok { + if name, nameOk := attrs.GetTableNameOk(); nameOk && *name == tableName { + tableCopy := table + foundTable = &tableCopy + break + } + } + } + } + + if foundTable == nil { + response.Diagnostics.AddError("API Error", fmt.Sprintf("Table %s was created but not found in list", tableName)) + return + } + + // Get the full table details by ID + tableID := foundTable.GetId() + getResp, _, getErr := r.Api.GetTable(r.Auth, tableID) + if getErr != nil { + response.Diagnostics.Append(utils.FrameworkErrorDiag(getErr, fmt.Sprintf("table created but error fetching details for ID %s", tableID))) + return + } + resp = getResp + } else { + statusCode := 0 + if httpResp != nil { + statusCode = httpResp.StatusCode + } + response.Diagnostics.AddError("API Error", fmt.Sprintf("CreateReferenceTable returned an empty response (HTTP %d).", statusCode)) + return + } + } + + r.updateState(ctx, &state, &resp) + + // Save data into Terraform state + response.Diagnostics.Append(response.State.Set(ctx, &state)...) +} + +func (r *referenceTableResource) Update(ctx context.Context, request resource.UpdateRequest, response *resource.UpdateResponse) { + var planState referenceTableModel + response.Diagnostics.Append(request.Plan.Get(ctx, &planState)...) + if response.Diagnostics.HasError() { + return + } + + var currentState referenceTableModel + response.Diagnostics.Append(request.State.Get(ctx, ¤tState)...) + if response.Diagnostics.HasError() { + return + } + + id := planState.ID.ValueString() + + // If we're updating schema for a cloud file table, ensure the table is ready (not processing) + // This prevents race conditions where we try to update while the initial sync is still running + isUpdatingSchema := planState.Schema != nil + if isUpdatingSchema && currentState.Source.ValueString() != "LOCAL_FILE" { + // Check current status - if still processing, wait for it to complete + currentResp, _, err := r.Api.GetTable(r.Auth, id) + if err == nil && currentResp.Data != nil { + attrs := currentResp.Data.GetAttributes() + if status, ok := attrs.GetStatusOk(); ok && status != nil { + statusStr := string(*status) + if statusStr != "DONE" && statusStr != "ERROR" { + // Table is still processing - wait for it to complete before updating + var finalResp datadogV2.TableResultV2 + waitErr := utils.Retry(3*time.Second, 20, func() error { + checkResp, _, checkErr := r.Api.GetTable(r.Auth, id) + if checkErr != nil { + return &utils.FatalError{Prob: fmt.Sprintf("error checking table status: %v", checkErr)} + } + if checkResp.Data != nil { + checkAttrs := checkResp.Data.GetAttributes() + if checkStatus, ok := checkAttrs.GetStatusOk(); ok && checkStatus != nil { + checkStatusStr := string(*checkStatus) + if checkStatusStr == "DONE" || checkStatusStr == "ERROR" { + finalResp = checkResp + return nil // Table is ready + } + return &utils.RetryableError{Prob: fmt.Sprintf("table status is %s, waiting for sync to complete before updating", checkStatusStr)} + } + } + return &utils.RetryableError{Prob: "unable to check table status"} + }) + if waitErr != nil { + response.Diagnostics.Append(utils.FrameworkErrorDiag(waitErr, "error waiting for table to be ready before update")) + return + } + // Refresh currentState with fresh API data after waiting + r.updateState(ctx, ¤tState, &finalResp) + } else { + // Status is already DONE/ERROR, refresh currentState with fresh API data + // to ensure we have the latest state (e.g., row_count, schema, etc.) + r.updateState(ctx, ¤tState, ¤tResp) + } + } + } + } + + body, diags := r.buildReferenceTableUpdateRequestBody(ctx, &planState, ¤tState) + response.Diagnostics.Append(diags...) + if response.Diagnostics.HasError() { + return + } + + _, err := r.Api.UpdateReferenceTable(r.Auth, id, *body) + if err != nil { + response.Diagnostics.Append(utils.FrameworkErrorDiag(err, "error updating ReferenceTable")) + return + } + + // Check if we're updating the schema - if so, we need to retry until the schema is updated + // Schema updates happen asynchronously when the file sync completes + var expectedFieldCount int + if isUpdatingSchema && planState.Schema.Fields != nil { + expectedFieldCount = len(planState.Schema.Fields) + } + + // Wait a bit before first check to give the API time to start processing + // This matches what we did in the direct API test (waited before checking) + if isUpdatingSchema && expectedFieldCount > 0 { + time.Sleep(3 * time.Second) + } + + // Read back the updated resource with retry logic if schema was updated + // Schema updates are asynchronous - the file sync needs to complete before schema is updated + var resp datadogV2.TableResultV2 + var httpResp *http.Response + retryErr := utils.Retry(5*time.Second, 10, func() error { + var err error + resp, httpResp, err = r.Api.GetTable(r.Auth, id) + if err != nil { + if httpResp != nil && httpResp.StatusCode == 404 { + return &utils.RetryableError{Prob: fmt.Sprintf("table not found (may still be processing): %v", err)} + } + return &utils.FatalError{Prob: fmt.Sprintf("error reading ReferenceTable after update: %v", err)} + } + + // If we're updating the schema, check if it matches the expected schema + // Schema can update while status is still PROCESSING, so check schema first + if isUpdatingSchema && expectedFieldCount > 0 { + if resp.Data != nil { + attrs := resp.Data.GetAttributes() + // Check for file processing errors - if file has more columns than schema, retry + // This can happen when schema update is async but file processing starts immediately + if fileMetadata, ok := attrs.GetFileMetadataOk(); ok && fileMetadata != nil { + if errorMsg, ok := fileMetadata.GetErrorMessageOk(); ok && errorMsg != nil && *errorMsg != "" { + if errorRowCount, ok := fileMetadata.GetErrorRowCountOk(); ok && errorRowCount != nil && *errorRowCount > 0 { + // File processing error detected - likely schema mismatch, retry + return &utils.RetryableError{Prob: fmt.Sprintf("file processing error detected (may be schema mismatch): %s (%d rows failed). Retrying until schema is updated.", *errorMsg, *errorRowCount)} + } + } + } + // Check schema first - it may update before status becomes DONE + if schema, ok := attrs.GetSchemaOk(); ok && schema != nil { + if fields, ok := schema.GetFieldsOk(); ok && fields != nil { + actualFieldCount := len(*fields) + if actualFieldCount == expectedFieldCount { + return nil // Schema matches, we're done + } + // Schema doesn't match yet - check status to provide better error message + if status, ok := attrs.GetStatusOk(); ok && status != nil { + statusStr := string(*status) + return &utils.RetryableError{Prob: fmt.Sprintf("schema not yet updated: expected %d fields, got %d (status: %s, file sync may still be processing)", expectedFieldCount, actualFieldCount, statusStr)} + } + // Schema doesn't match yet, retry + return &utils.RetryableError{Prob: fmt.Sprintf("schema not yet updated: expected %d fields, got %d (file sync may still be processing)", expectedFieldCount, actualFieldCount)} + } + } + } + // If we can't check the schema, retry + return &utils.RetryableError{Prob: "unable to verify schema update (file sync may still be processing)"} + } + + // No schema update or schema matches, we're done + return nil + }) + + if retryErr != nil { + response.Diagnostics.Append(utils.FrameworkErrorDiag(retryErr, "error reading ReferenceTable after update")) + return + } + + r.updateState(ctx, &planState, &resp) + + // Save data into Terraform state + response.Diagnostics.Append(response.State.Set(ctx, &planState)...) +} + +func (r *referenceTableResource) Delete(ctx context.Context, request resource.DeleteRequest, response *resource.DeleteResponse) { + var state referenceTableModel + response.Diagnostics.Append(request.State.Get(ctx, &state)...) + if response.Diagnostics.HasError() { + return + } + + id := state.ID.ValueString() + + httpResp, err := r.Api.DeleteTable(r.Auth, id) + if err != nil { + if httpResp != nil && httpResp.StatusCode == 404 { + return + } + response.Diagnostics.Append(utils.FrameworkErrorDiag(err, "error deleting reference_table")) + return + } +} + +func (r *referenceTableResource) updateState(ctx context.Context, state *referenceTableModel, resp *datadogV2.TableResultV2) { + // Check if Data is present + if resp == nil || resp.Data == nil { + return + } + + attributes := resp.Data.GetAttributes() + + state.ID = types.StringValue(*resp.GetData().Id) + + if createdBy, ok := attributes.GetCreatedByOk(); ok { + state.CreatedBy = types.StringValue(*createdBy) + } + + if description, ok := attributes.GetDescriptionOk(); ok { + state.Description = types.StringValue(*description) + } + + if lastUpdatedBy, ok := attributes.GetLastUpdatedByOk(); ok { + state.LastUpdatedBy = types.StringValue(*lastUpdatedBy) + } + + if rowCount, ok := attributes.GetRowCountOk(); ok { + state.RowCount = types.Int64Value(*rowCount) + } + + if source, ok := attributes.GetSourceOk(); ok { + state.Source = types.StringValue(string(*source)) + } + + if status, ok := attributes.GetStatusOk(); ok { + state.Status = types.StringValue(*status) + } + + if tableName, ok := attributes.GetTableNameOk(); ok { + state.TableName = types.StringValue(*tableName) + } + + if updatedAt, ok := attributes.GetUpdatedAtOk(); ok { + state.UpdatedAt = types.StringValue(*updatedAt) + } + + if tags, ok := attributes.GetTagsOk(); ok && len(*tags) > 0 { + state.Tags, _ = types.ListValueFrom(ctx, types.StringType, *tags) + } + + // Handle FileMetadata from API response (flattened structure, no longer OneOf) + if fileMetadata, ok := attributes.GetFileMetadataOk(); ok { + fileMetadataTf := &fileMetadataModel{} + + // FileMetadata is now a flattened struct with direct fields + if syncEnabled, ok := fileMetadata.GetSyncEnabledOk(); ok { + fileMetadataTf.SyncEnabled = types.BoolValue(*syncEnabled) + } else { + // If sync_enabled is not in API response, preserve existing value from state + // This handles cases where the API doesn't return sync_enabled in the response + if state.FileMetadata != nil && !state.FileMetadata.SyncEnabled.IsNull() { + fileMetadataTf.SyncEnabled = state.FileMetadata.SyncEnabled + } + } + + if errorMessage, ok := fileMetadata.GetErrorMessageOk(); ok { + fileMetadataTf.ErrorMessage = types.StringValue(*errorMessage) + } + + if errorRowCount, ok := fileMetadata.GetErrorRowCountOk(); ok { + fileMetadataTf.ErrorRowCount = types.Int64Value(*errorRowCount) + } + + if errorType, ok := fileMetadata.GetErrorTypeOk(); ok { + fileMetadataTf.ErrorType = types.StringValue(string(*errorType)) + } + + // Extract access_details (only present for cloud storage sources) + if accessDetails, ok := fileMetadata.GetAccessDetailsOk(); ok { + accessDetailsTf := &accessDetailsModel{} + + // AWS details + if awsDetail := accessDetails.AwsDetail; awsDetail != nil { + awsDetailTf := &awsDetailModel{} + if awsAccountId, ok := awsDetail.GetAwsAccountIdOk(); ok { + awsDetailTf.AwsAccountId = types.StringValue(*awsAccountId) + } + if awsBucketName, ok := awsDetail.GetAwsBucketNameOk(); ok { + awsDetailTf.AwsBucketName = types.StringValue(*awsBucketName) + } + if filePath, ok := awsDetail.GetFilePathOk(); ok { + awsDetailTf.FilePath = types.StringValue(*filePath) + } + accessDetailsTf.AwsDetail = awsDetailTf + } + + // GCP details + if gcpDetail := accessDetails.GcpDetail; gcpDetail != nil { + gcpDetailTf := &gcpDetailModel{} + if gcpProjectId, ok := gcpDetail.GetGcpProjectIdOk(); ok { + gcpDetailTf.GcpProjectId = types.StringValue(*gcpProjectId) + } + if gcpBucketName, ok := gcpDetail.GetGcpBucketNameOk(); ok { + gcpDetailTf.GcpBucketName = types.StringValue(*gcpBucketName) + } + if filePath, ok := gcpDetail.GetFilePathOk(); ok { + gcpDetailTf.FilePath = types.StringValue(*filePath) + } + if gcpServiceAccountEmail, ok := gcpDetail.GetGcpServiceAccountEmailOk(); ok { + gcpDetailTf.GcpServiceAccountEmail = types.StringValue(*gcpServiceAccountEmail) + } + accessDetailsTf.GcpDetail = gcpDetailTf + } + + // Azure details + if azureDetail := accessDetails.AzureDetail; azureDetail != nil { + azureDetailTf := &azureDetailModel{} + if azureTenantId, ok := azureDetail.GetAzureTenantIdOk(); ok { + azureDetailTf.AzureTenantId = types.StringValue(*azureTenantId) + } + if azureClientId, ok := azureDetail.GetAzureClientIdOk(); ok { + azureDetailTf.AzureClientId = types.StringValue(*azureClientId) + } + if azureStorageAccountName, ok := azureDetail.GetAzureStorageAccountNameOk(); ok { + azureDetailTf.AzureStorageAccountName = types.StringValue(*azureStorageAccountName) + } + if azureContainerName, ok := azureDetail.GetAzureContainerNameOk(); ok { + azureDetailTf.AzureContainerName = types.StringValue(*azureContainerName) + } + if filePath, ok := azureDetail.GetFilePathOk(); ok { + azureDetailTf.FilePath = types.StringValue(*filePath) + } + accessDetailsTf.AzureDetail = azureDetailTf + } + + fileMetadataTf.AccessDetails = accessDetailsTf + } + + state.FileMetadata = fileMetadataTf + } + + // Handle Schema + if schema, ok := attributes.GetSchemaOk(); ok { + schemaTf := schemaModel{} + if fields, ok := schema.GetFieldsOk(); ok && len(*fields) > 0 { + schemaTf.Fields = []*fieldsModel{} + for _, fieldsDd := range *fields { + fieldsTf := fieldsModel{} + if name, ok := fieldsDd.GetNameOk(); ok { + fieldsTf.Name = types.StringValue(*name) + } + if typeVar, ok := fieldsDd.GetTypeOk(); ok { + fieldsTf.Type = types.StringValue(string(*typeVar)) + } + schemaTf.Fields = append(schemaTf.Fields, &fieldsTf) + } + } + if primaryKeys, ok := schema.GetPrimaryKeysOk(); ok && len(*primaryKeys) > 0 { + schemaTf.PrimaryKeys, _ = types.ListValueFrom(ctx, types.StringType, *primaryKeys) + } + state.Schema = &schemaTf + } +} + +func (r *referenceTableResource) buildReferenceTableRequestBody(ctx context.Context, state *referenceTableModel) (*datadogV2.CreateTableRequest, diag.Diagnostics) { + diags := diag.Diagnostics{} + attributes := datadogV2.NewCreateTableRequestDataAttributesWithDefaults() + + if !state.Description.IsNull() { + attributes.SetDescription(state.Description.ValueString()) + } + if !state.Source.IsNull() { + attributes.SetSource(datadogV2.ReferenceTableCreateSourceType(state.Source.ValueString())) + } + if !state.TableName.IsNull() { + attributes.SetTableName(state.TableName.ValueString()) + } + + if !state.Tags.IsNull() { + var tags []string + diags.Append(state.Tags.ElementsAs(ctx, &tags, false)...) + attributes.SetTags(tags) + } + + // Build file_metadata for cloud storage + if state.FileMetadata != nil { + cloudStorageMetadata := datadogV2.CreateTableRequestDataAttributesFileMetadataCloudStorage{} + cloudStorageMetadata.SetSyncEnabled(state.FileMetadata.SyncEnabled.ValueBool()) + + if state.FileMetadata.AccessDetails != nil { + accessDetails := datadogV2.CreateTableRequestDataAttributesFileMetadataOneOfAccessDetails{} + + // AWS details + if state.FileMetadata.AccessDetails.AwsDetail != nil { + awsDetail := datadogV2.CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail{} + awsDetail.SetAwsAccountId(state.FileMetadata.AccessDetails.AwsDetail.AwsAccountId.ValueString()) + awsDetail.SetAwsBucketName(state.FileMetadata.AccessDetails.AwsDetail.AwsBucketName.ValueString()) + awsDetail.SetFilePath(state.FileMetadata.AccessDetails.AwsDetail.FilePath.ValueString()) + accessDetails.AwsDetail = &awsDetail + } + + // GCP details + if state.FileMetadata.AccessDetails.GcpDetail != nil { + gcpDetail := datadogV2.CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail{} + gcpDetail.SetGcpProjectId(state.FileMetadata.AccessDetails.GcpDetail.GcpProjectId.ValueString()) + gcpDetail.SetGcpBucketName(state.FileMetadata.AccessDetails.GcpDetail.GcpBucketName.ValueString()) + gcpDetail.SetFilePath(state.FileMetadata.AccessDetails.GcpDetail.FilePath.ValueString()) + gcpDetail.SetGcpServiceAccountEmail(state.FileMetadata.AccessDetails.GcpDetail.GcpServiceAccountEmail.ValueString()) + accessDetails.GcpDetail = &gcpDetail + } + + // Azure details + if state.FileMetadata.AccessDetails.AzureDetail != nil { + azureDetail := datadogV2.CreateTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail{} + azureDetail.SetAzureTenantId(state.FileMetadata.AccessDetails.AzureDetail.AzureTenantId.ValueString()) + azureDetail.SetAzureClientId(state.FileMetadata.AccessDetails.AzureDetail.AzureClientId.ValueString()) + azureDetail.SetAzureStorageAccountName(state.FileMetadata.AccessDetails.AzureDetail.AzureStorageAccountName.ValueString()) + azureDetail.SetAzureContainerName(state.FileMetadata.AccessDetails.AzureDetail.AzureContainerName.ValueString()) + azureDetail.SetFilePath(state.FileMetadata.AccessDetails.AzureDetail.FilePath.ValueString()) + accessDetails.AzureDetail = &azureDetail + } + + cloudStorageMetadata.SetAccessDetails(accessDetails) + } + + // Set the file_metadata as a oneOf union type + fileMetadata := datadogV2.CreateTableRequestDataAttributesFileMetadataCloudStorageAsCreateTableRequestDataAttributesFileMetadata(&cloudStorageMetadata) + attributes.SetFileMetadata(fileMetadata) + } + + // Build schema + if state.Schema != nil { + schema := datadogV2.CreateTableRequestDataAttributesSchema{} + + var primaryKeys []string + diags.Append(state.Schema.PrimaryKeys.ElementsAs(ctx, &primaryKeys, false)...) + schema.SetPrimaryKeys(primaryKeys) + + if state.Schema.Fields != nil { + var fields []datadogV2.CreateTableRequestDataAttributesSchemaFieldsItems + for _, fieldsTFItem := range state.Schema.Fields { + if !fieldsTFItem.Name.IsNull() && !fieldsTFItem.Type.IsNull() { + fieldsDDItem := datadogV2.NewCreateTableRequestDataAttributesSchemaFieldsItems( + fieldsTFItem.Name.ValueString(), + datadogV2.ReferenceTableSchemaFieldType(fieldsTFItem.Type.ValueString()), + ) + fields = append(fields, *fieldsDDItem) + } + } + schema.SetFields(fields) + } + attributes.Schema = schema + } + + req := datadogV2.NewCreateTableRequestWithDefaults() + req.Data = datadogV2.NewCreateTableRequestData(datadogV2.CREATETABLEREQUESTDATATYPE_REFERENCE_TABLE) + req.Data.SetAttributes(*attributes) + + return req, diags +} + +func (r *referenceTableResource) buildReferenceTableUpdateRequestBody(ctx context.Context, planState *referenceTableModel, currentState *referenceTableModel) (*datadogV2.PatchTableRequest, diag.Diagnostics) { + diags := diag.Diagnostics{} + attributes := datadogV2.NewPatchTableRequestDataAttributesWithDefaults() + + if !planState.Description.IsNull() { + attributes.SetDescription(planState.Description.ValueString()) + } + + if !planState.Tags.IsNull() { + var tags []string + diags.Append(planState.Tags.ElementsAs(ctx, &tags, false)...) + attributes.SetTags(tags) + } + + // Check if we're updating the schema - if so, we need access_details or upload_id + isUpdatingSchema := planState.Schema != nil + + // Build file_metadata for cloud storage updates + if planState.FileMetadata != nil { + cloudStorageMetadata := datadogV2.PatchTableRequestDataAttributesFileMetadataCloudStorage{} + + if !planState.FileMetadata.SyncEnabled.IsNull() { + cloudStorageMetadata.SetSyncEnabled(planState.FileMetadata.SyncEnabled.ValueBool()) + } + + // If updating schema and access_details not in plan or null/unknown, use current state's access_details + accessDetailsToUse := planState.FileMetadata.AccessDetails + if isUpdatingSchema { + // Check if access_details is missing, null, or has no actual detail values + hasAccessDetails := accessDetailsToUse != nil && + (accessDetailsToUse.AwsDetail != nil || + accessDetailsToUse.GcpDetail != nil || + accessDetailsToUse.AzureDetail != nil) + if !hasAccessDetails && currentState.FileMetadata != nil && currentState.FileMetadata.AccessDetails != nil { + accessDetailsToUse = currentState.FileMetadata.AccessDetails + } + } + + // Check if we have valid access_details (at least one detail field must be set) + hasValidAccessDetails := accessDetailsToUse != nil && + (accessDetailsToUse.AwsDetail != nil || + accessDetailsToUse.GcpDetail != nil || + accessDetailsToUse.AzureDetail != nil) + + if hasValidAccessDetails { + accessDetails := datadogV2.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails{} + + // AWS details + if accessDetailsToUse.AwsDetail != nil { + awsDetail := datadogV2.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail{} + awsDetail.SetAwsAccountId(accessDetailsToUse.AwsDetail.AwsAccountId.ValueString()) + awsDetail.SetAwsBucketName(accessDetailsToUse.AwsDetail.AwsBucketName.ValueString()) + awsDetail.SetFilePath(accessDetailsToUse.AwsDetail.FilePath.ValueString()) + accessDetails.AwsDetail = &awsDetail + } + + // GCP details + if accessDetailsToUse.GcpDetail != nil { + gcpDetail := datadogV2.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail{} + gcpDetail.SetGcpProjectId(accessDetailsToUse.GcpDetail.GcpProjectId.ValueString()) + gcpDetail.SetGcpBucketName(accessDetailsToUse.GcpDetail.GcpBucketName.ValueString()) + gcpDetail.SetFilePath(accessDetailsToUse.GcpDetail.FilePath.ValueString()) + gcpDetail.SetGcpServiceAccountEmail(accessDetailsToUse.GcpDetail.GcpServiceAccountEmail.ValueString()) + accessDetails.GcpDetail = &gcpDetail + } + + // Azure details + if accessDetailsToUse.AzureDetail != nil { + azureDetail := datadogV2.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail{} + azureDetail.SetAzureTenantId(accessDetailsToUse.AzureDetail.AzureTenantId.ValueString()) + azureDetail.SetAzureClientId(accessDetailsToUse.AzureDetail.AzureClientId.ValueString()) + azureDetail.SetAzureStorageAccountName(accessDetailsToUse.AzureDetail.AzureStorageAccountName.ValueString()) + azureDetail.SetAzureContainerName(accessDetailsToUse.AzureDetail.AzureContainerName.ValueString()) + azureDetail.SetFilePath(accessDetailsToUse.AzureDetail.FilePath.ValueString()) + accessDetails.AzureDetail = &azureDetail + } + + cloudStorageMetadata.SetAccessDetails(accessDetails) + fileMetadata := datadogV2.PatchTableRequestDataAttributesFileMetadataCloudStorageAsPatchTableRequestDataAttributesFileMetadata(&cloudStorageMetadata) + attributes.SetFileMetadata(fileMetadata) + } else if isUpdatingSchema { + // Schema updates require access_details for cloud storage sources + // Try to get access_details from current state + currentStateHasValidAccessDetails := currentState.FileMetadata != nil && + currentState.FileMetadata.AccessDetails != nil && + (currentState.FileMetadata.AccessDetails.AwsDetail != nil || + currentState.FileMetadata.AccessDetails.GcpDetail != nil || + currentState.FileMetadata.AccessDetails.AzureDetail != nil) + if currentStateHasValidAccessDetails { + // Use current state's access_details + accessDetails := datadogV2.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails{} + if currentState.FileMetadata.AccessDetails.AwsDetail != nil { + awsDetail := datadogV2.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail{} + awsDetail.SetAwsAccountId(currentState.FileMetadata.AccessDetails.AwsDetail.AwsAccountId.ValueString()) + awsDetail.SetAwsBucketName(currentState.FileMetadata.AccessDetails.AwsDetail.AwsBucketName.ValueString()) + awsDetail.SetFilePath(currentState.FileMetadata.AccessDetails.AwsDetail.FilePath.ValueString()) + accessDetails.AwsDetail = &awsDetail + } + if currentState.FileMetadata.AccessDetails.GcpDetail != nil { + gcpDetail := datadogV2.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail{} + gcpDetail.SetGcpProjectId(currentState.FileMetadata.AccessDetails.GcpDetail.GcpProjectId.ValueString()) + gcpDetail.SetGcpBucketName(currentState.FileMetadata.AccessDetails.GcpDetail.GcpBucketName.ValueString()) + gcpDetail.SetFilePath(currentState.FileMetadata.AccessDetails.GcpDetail.FilePath.ValueString()) + gcpDetail.SetGcpServiceAccountEmail(currentState.FileMetadata.AccessDetails.GcpDetail.GcpServiceAccountEmail.ValueString()) + accessDetails.GcpDetail = &gcpDetail + } + if currentState.FileMetadata.AccessDetails.AzureDetail != nil { + azureDetail := datadogV2.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail{} + azureDetail.SetAzureTenantId(currentState.FileMetadata.AccessDetails.AzureDetail.AzureTenantId.ValueString()) + azureDetail.SetAzureClientId(currentState.FileMetadata.AccessDetails.AzureDetail.AzureClientId.ValueString()) + azureDetail.SetAzureStorageAccountName(currentState.FileMetadata.AccessDetails.AzureDetail.AzureStorageAccountName.ValueString()) + azureDetail.SetAzureContainerName(currentState.FileMetadata.AccessDetails.AzureDetail.AzureContainerName.ValueString()) + azureDetail.SetFilePath(currentState.FileMetadata.AccessDetails.AzureDetail.FilePath.ValueString()) + accessDetails.AzureDetail = &azureDetail + } + if !currentState.FileMetadata.SyncEnabled.IsNull() { + cloudStorageMetadata.SetSyncEnabled(currentState.FileMetadata.SyncEnabled.ValueBool()) + } + cloudStorageMetadata.SetAccessDetails(accessDetails) + fileMetadata := datadogV2.PatchTableRequestDataAttributesFileMetadataCloudStorageAsPatchTableRequestDataAttributesFileMetadata(&cloudStorageMetadata) + attributes.SetFileMetadata(fileMetadata) + } else { + diags.AddError("Schema update requires access_details", + "When updating the schema, file_metadata must include access_details (for cloud storage sources)") + return nil, diags + } + } + } else if isUpdatingSchema { + // Schema update but no file_metadata in plan - try to get from current state + if currentState.FileMetadata != nil { + if currentState.FileMetadata.AccessDetails != nil { + // Use current state's access_details + cloudStorageMetadata := datadogV2.PatchTableRequestDataAttributesFileMetadataCloudStorage{} + if !currentState.FileMetadata.SyncEnabled.IsNull() { + cloudStorageMetadata.SetSyncEnabled(currentState.FileMetadata.SyncEnabled.ValueBool()) + } + accessDetails := datadogV2.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetails{} + if currentState.FileMetadata.AccessDetails.AwsDetail != nil { + awsDetail := datadogV2.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAwsDetail{} + awsDetail.SetAwsAccountId(currentState.FileMetadata.AccessDetails.AwsDetail.AwsAccountId.ValueString()) + awsDetail.SetAwsBucketName(currentState.FileMetadata.AccessDetails.AwsDetail.AwsBucketName.ValueString()) + awsDetail.SetFilePath(currentState.FileMetadata.AccessDetails.AwsDetail.FilePath.ValueString()) + accessDetails.AwsDetail = &awsDetail + } + if currentState.FileMetadata.AccessDetails.GcpDetail != nil { + gcpDetail := datadogV2.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsGcpDetail{} + gcpDetail.SetGcpProjectId(currentState.FileMetadata.AccessDetails.GcpDetail.GcpProjectId.ValueString()) + gcpDetail.SetGcpBucketName(currentState.FileMetadata.AccessDetails.GcpDetail.GcpBucketName.ValueString()) + gcpDetail.SetFilePath(currentState.FileMetadata.AccessDetails.GcpDetail.FilePath.ValueString()) + gcpDetail.SetGcpServiceAccountEmail(currentState.FileMetadata.AccessDetails.GcpDetail.GcpServiceAccountEmail.ValueString()) + accessDetails.GcpDetail = &gcpDetail + } + if currentState.FileMetadata.AccessDetails.AzureDetail != nil { + azureDetail := datadogV2.PatchTableRequestDataAttributesFileMetadataOneOfAccessDetailsAzureDetail{} + azureDetail.SetAzureTenantId(currentState.FileMetadata.AccessDetails.AzureDetail.AzureTenantId.ValueString()) + azureDetail.SetAzureClientId(currentState.FileMetadata.AccessDetails.AzureDetail.AzureClientId.ValueString()) + azureDetail.SetAzureStorageAccountName(currentState.FileMetadata.AccessDetails.AzureDetail.AzureStorageAccountName.ValueString()) + azureDetail.SetAzureContainerName(currentState.FileMetadata.AccessDetails.AzureDetail.AzureContainerName.ValueString()) + azureDetail.SetFilePath(currentState.FileMetadata.AccessDetails.AzureDetail.FilePath.ValueString()) + accessDetails.AzureDetail = &azureDetail + } + cloudStorageMetadata.SetAccessDetails(accessDetails) + fileMetadata := datadogV2.PatchTableRequestDataAttributesFileMetadataCloudStorageAsPatchTableRequestDataAttributesFileMetadata(&cloudStorageMetadata) + attributes.SetFileMetadata(fileMetadata) + } + } + } + + // Build schema for updates + if planState.Schema != nil { + schema := datadogV2.PatchTableRequestDataAttributesSchema{} + + if !planState.Schema.PrimaryKeys.IsNull() { + var primaryKeys []string + diags.Append(planState.Schema.PrimaryKeys.ElementsAs(ctx, &primaryKeys, false)...) + schema.SetPrimaryKeys(primaryKeys) + } + + if planState.Schema.Fields != nil { + var fields []datadogV2.PatchTableRequestDataAttributesSchemaFieldsItems + for _, fieldsTFItem := range planState.Schema.Fields { + if !fieldsTFItem.Name.IsNull() && !fieldsTFItem.Type.IsNull() { + fieldsDDItem := datadogV2.NewPatchTableRequestDataAttributesSchemaFieldsItems( + fieldsTFItem.Name.ValueString(), + datadogV2.ReferenceTableSchemaFieldType(fieldsTFItem.Type.ValueString()), + ) + fields = append(fields, *fieldsDDItem) + } + } + schema.SetFields(fields) + } + attributes.Schema = &schema + } + + req := datadogV2.NewPatchTableRequestWithDefaults() + req.Data = datadogV2.NewPatchTableRequestData(datadogV2.PATCHTABLEREQUESTDATATYPE_REFERENCE_TABLE) + req.Data.SetAttributes(*attributes) + + return req, diags +} + +func (r *referenceTableResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + // If the plan is null (resource is being destroyed) or no state exists yet, return early + if req.Plan.Raw.IsNull() || req.State.Raw.IsNull() { + return + } + + var plan, state referenceTableModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + // Validate schema changes + if plan.Schema != nil && state.Schema != nil { + planSchema := plan.Schema + stateSchema := state.Schema + + // Check primary keys changes (destructive) + var planPrimaryKeys, statePrimaryKeys []string + if !planSchema.PrimaryKeys.IsNull() && !stateSchema.PrimaryKeys.IsNull() { + planSchema.PrimaryKeys.ElementsAs(ctx, &planPrimaryKeys, false) + stateSchema.PrimaryKeys.ElementsAs(ctx, &statePrimaryKeys, false) + + // Check if primary keys have changed + if len(planPrimaryKeys) != len(statePrimaryKeys) { + resp.Diagnostics.AddError( + "Destructive schema changes are not supported", + fmt.Sprintf("Cannot change primary keys from %v to %v.\n\n"+ + "The planned schema change would modify primary keys, which requires table recreation and causes downtime.\n\n"+ + "To proceed:\n"+ + "1. Remove the resource from Terraform state: terraform state rm datadog_reference_table.%s\n"+ + "2. Update your configuration with the new schema\n"+ + "3. Run terraform apply to recreate the table\n\n"+ + "Note: The table will be unavailable during recreation, causing enrichment processors to fail.", + statePrimaryKeys, planPrimaryKeys, state.TableName.ValueString()), + ) + return + } + + for i, planKey := range planPrimaryKeys { + if i >= len(statePrimaryKeys) || planKey != statePrimaryKeys[i] { + resp.Diagnostics.AddError( + "Destructive schema changes are not supported", + fmt.Sprintf("Cannot change primary keys from %v to %v.\n\n"+ + "The planned schema change would modify primary keys, which requires table recreation and causes downtime.\n\n"+ + "To proceed:\n"+ + "1. Remove the resource from Terraform state: terraform state rm datadog_reference_table.%s\n"+ + "2. Update your configuration with the new schema\n"+ + "3. Run terraform apply to recreate the table\n\n"+ + "Note: The table will be unavailable during recreation, causing enrichment processors to fail.", + statePrimaryKeys, planPrimaryKeys, state.TableName.ValueString()), + ) + return + } + } + } + + // Build field maps for comparison + stateFieldMap := make(map[string]string) // field name -> type + if stateSchema.Fields != nil { + for _, field := range stateSchema.Fields { + if !field.Name.IsNull() && !field.Type.IsNull() { + stateFieldMap[field.Name.ValueString()] = field.Type.ValueString() + } + } + } + + planFieldMap := make(map[string]string) + if planSchema.Fields != nil { + for _, field := range planSchema.Fields { + if !field.Name.IsNull() && !field.Type.IsNull() { + planFieldMap[field.Name.ValueString()] = field.Type.ValueString() + } + } + } + + // Check for removed fields (destructive) + for fieldName := range stateFieldMap { + if _, exists := planFieldMap[fieldName]; !exists { + resp.Diagnostics.AddError( + "Destructive schema changes are not supported", + fmt.Sprintf("Cannot remove field '%s' from the schema.\n\n"+ + "The planned schema change would remove fields, which requires table recreation and causes downtime.\n\n"+ + "To proceed:\n"+ + "1. Remove the resource from Terraform state: terraform state rm datadog_reference_table.%s\n"+ + "2. Update your configuration with the new schema\n"+ + "3. Run terraform apply to recreate the table\n\n"+ + "Note: The table will be unavailable during recreation, causing enrichment processors to fail.", + fieldName, state.TableName.ValueString()), + ) + return + } + } + + // Check for field type changes (destructive) + for fieldName, planType := range planFieldMap { + if stateType, exists := stateFieldMap[fieldName]; exists { + if stateType != planType { + resp.Diagnostics.AddError( + "Destructive schema changes are not supported", + fmt.Sprintf("Cannot change type of field '%s' from '%s' to '%s'.\n\n"+ + "The planned schema change would modify field types, which requires table recreation and causes downtime.\n\n"+ + "To proceed:\n"+ + "1. Remove the resource from Terraform state: terraform state rm datadog_reference_table.%s\n"+ + "2. Update your configuration with the new schema\n"+ + "3. Run terraform apply to recreate the table\n\n"+ + "Note: The table will be unavailable during recreation, causing enrichment processors to fail.", + fieldName, stateType, planType, state.TableName.ValueString()), + ) + return + } + } + // New fields (additive) are allowed - no error + } + } +} diff --git a/datadog/internal/utils/api_instances_helper.go b/datadog/internal/utils/api_instances_helper.go index 7904458fa9..65fca0a298 100644 --- a/datadog/internal/utils/api_instances_helper.go +++ b/datadog/internal/utils/api_instances_helper.go @@ -83,6 +83,7 @@ type ApiInstances struct { orgConnectionsApiV2 *datadogV2.OrgConnectionsApi processesApiV2 *datadogV2.ProcessesApi powerpackApiV2 *datadogV2.PowerpackApi + referenceTablesApiV2 *datadogV2.ReferenceTablesApi restrictionPolicyApiV2 *datadogV2.RestrictionPoliciesApi rolesApiV2 *datadogV2.RolesApi rumApiV2 *datadogV2.RUMApi @@ -786,3 +787,11 @@ func (i *ApiInstances) GetCloudCostManagementApiV2() *datadogV2.CloudCostManagem } return i.ccmApiV2 } + +// GetReferenceTablesApiV2 get instance of ReferenceTablesApi +func (i *ApiInstances) GetReferenceTablesApiV2() *datadogV2.ReferenceTablesApi { + if i.referenceTablesApiV2 == nil { + i.referenceTablesApiV2 = datadogV2.NewReferenceTablesApi(i.HttpClient) + } + return i.referenceTablesApiV2 +} diff --git a/datadog/tests/cassettes/TestAccDatadogReferenceTableDataSource.freeze b/datadog/tests/cassettes/TestAccDatadogReferenceTableDataSource.freeze new file mode 100644 index 0000000000..21fb2304bc --- /dev/null +++ b/datadog/tests/cassettes/TestAccDatadogReferenceTableDataSource.freeze @@ -0,0 +1 @@ +2025-11-19T14:48:10.363541-05:00 \ No newline at end of file diff --git a/datadog/tests/cassettes/TestAccDatadogReferenceTableDataSource.yaml b/datadog/tests/cassettes/TestAccDatadogReferenceTableDataSource.yaml new file mode 100644 index 0000000000..f1eb7d3078 --- /dev/null +++ b/datadog/tests/cassettes/TestAccDatadogReferenceTableDataSource.yaml @@ -0,0 +1,468 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 519 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: | + {"data":{"attributes":{"description":"Test data source","file_metadata":{"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}},"sync_enabled":true},"schema":{"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}],"primary_keys":["a"]},"source":"S3","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"]},"type":"reference_table"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created + code: 201 + duration: 749.475ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"data":[{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"72dc199d-6401-4527-b2e5-4cafaca6927c","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test schema evolution","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_evolution_tf_testaccreferencetable_schemaevolution_local_1763581690","tags":["test:terraform"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"8c4be62b-1b6c-4578-89b8-79c5f04b02b6","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test sync_enabled update","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_sync_tf_testaccreferencetable_updatesyncenabled_local_1763581690","tags":["test:terraform"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"134ee13a-0917-40d1-b0c8-6123f05ac568","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetables3_basic_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"e15180ff-b17b-423a-b8cf-4c6fc3f78928","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source for rows","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_rows_tf_testaccdatadogreferencetablerowsdatasource_local_1763581690","tags":["test:datasource-rows"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"5b7451b5-f91a-4547-8e06-7da0664fecff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetable_import_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"42b5c9ca-898a-466c-a54a-0481c9ab696f","type":"reference_table","attributes":{"created_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","description":"","last_updated_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","row_count":2,"schema":{"primary_keys":["name"],"fields":[{"name":"name","type":"STRING"},{"name":"url","type":"STRING"}]},"source":"SERVICENOW","status":"DONE","table_name":"http_bulk_client_e2e","tags":null,"updated_at":"2025-11-19T19:47:18Z"}},{"id":"f8ff12c9-4bdd-49e1-8956-4895cfcddbc3","type":"reference_table","attributes":{"created_by":"","description":"","file_metadata":{"error_row_count":342,"error_message":"","access_details":{}},"last_updated_by":"","row_count":4244780,"schema":{"primary_keys":["org_id"],"fields":[{"name":"account_family_customer_tier","type":"STRING"},{"name":"account_family_mrr","type":"STRING"},{"name":"account_health_status","type":"STRING"},{"name":"account_owner","type":"STRING"},{"name":"account_owner_email","type":"STRING"},{"name":"account_owner_role","type":"STRING"},{"name":"account_owner_territory","type":"STRING"},{"name":"account_sales_engineer","type":"STRING"},{"name":"account_status","type":"STRING"},{"name":"account_status_detail","type":"STRING"},{"name":"churn_reason","type":"STRING"},{"name":"churn_risk_likelihood","type":"STRING"},{"name":"churn_risk_reason","type":"STRING"},{"name":"country","type":"STRING"},{"name":"customer_success_rep","type":"STRING"},{"name":"customer_success_rep_email","type":"STRING"},{"name":"customer_tier","type":"STRING"},{"name":"employee_count","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"is_msp","type":"STRING"},{"name":"is_premier_support_enabled","type":"STRING"},{"name":"master_org_id","type":"STRING"},{"name":"master_org_name","type":"STRING"},{"name":"org_id","type":"STRING"},{"name":"org_name","type":"STRING"},{"name":"owner_sales_department","type":"STRING"},{"name":"owner_sales_team","type":"STRING"},{"name":"partner_tier","type":"STRING"},{"name":"premier_support_mrr","type":"STRING"},{"name":"region","type":"STRING"},{"name":"sales_engineer","type":"STRING"},{"name":"sales_engineer_email","type":"STRING"},{"name":"sales_segment","type":"STRING"},{"name":"technical_product_health_status","type":"STRING"},{"name":"type","type":"STRING"},{"name":"row_created_at","type":"STRING"},{"name":"row_updated_at","type":"STRING"}]},"source":"SNOWFLAKE","status":"DONE_WITH_ERRORS","table_name":"test_product_analytics_write_dest_saas","tags":["product_analytics_beta_enabled:true"],"updated_at":"2025-11-19T19:46:12Z"}},{"id":"f704bb0a-9eaf-4734-bd22-1caaca09d6ca","type":"reference_table","attributes":{"created_by":"972dde90-34e1-11eb-958e-f7f08ce02c26","description":"","file_metadata":{"error_row_count":172,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"727006795293","aws_bucket_name":"dd-logs-threat-intel-staging","file_path":"threat_intel_ip_abuse_ch_threatfox.csv"}}},"last_updated_by":"","row_count":1706,"schema":{"primary_keys":["ip_address"],"fields":[{"name":"ip_address","type":"STRING"},{"name":"intention","type":"STRING"},{"name":"category","type":"STRING"},{"name":"source","type":"STRING"},{"name":"additional_data","type":"STRING"}]},"source":"S3","status":"DONE_WITH_ERRORS","table_name":"threat_intel_ip_abuse_ch_threatfox","tags":null,"updated_at":"2025-11-19T19:45:55Z"}},{"id":"34c341b1-a97a-4893-b821-475f8bbf0561","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":1,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_crud_flow_7730722353299252260","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"cbc703e8-45a7-428d-9a85-079c9b4abcbf","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":2,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_v2_row_crud_flow_3796209879804171102","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"1fd37f6a-75a6-44b7-bb9a-2f8558fd2d6b","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":1,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_row_crud_flow_151529577687372015","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"ae91c101-a2e2-41d2-b99f-0cb5ff87e72a","type":"reference_table","attributes":{"created_by":"","description":"This is NOT an actual Snowflake table - it''s a test table updated by this synthetics: https://ddstaging.datadoghq.com/synthetics/details/ajx-zbt-khs?from_ts=1741296820320\u0026to_ts=1741300420320\u0026live=true.","file_metadata":{"error_row_count":1,"error_message":"","access_details":{}},"last_updated_by":"","row_count":1,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"name","type":"STRING"}]},"source":"SNOWFLAKE","status":"DONE_WITH_ERRORS","table_name":"synthetics_grpc_saas2","tags":null,"updated_at":"2025-11-19T19:43:35Z"}},{"id":"481ded06-c51f-48a3-97a6-aab88fd27b53","type":"reference_table","attributes":{"created_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","description":"","last_updated_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","row_count":29,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"name","type":"STRING"}]},"source":"API","status":"DONE","table_name":"test_sync_nov_18","tags":null,"updated_at":"2025-11-19T19:38:08Z"}},{"id":"4acf614f-6ee4-404b-8c36-4f0c1f9df648","type":"reference_table","attributes":{"created_by":"","description":"","last_updated_by":"","row_count":2,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"createdat","type":"STRING"},{"name":"updatedat","type":"STRING"},{"name":"archived","type":"STRING"},{"name":"url","type":"STRING"},{"name":"address","type":"STRING"},{"name":"address2","type":"STRING"},{"name":"annualrevenue","type":"STRING"},{"name":"city","type":"STRING"},{"name":"country","type":"STRING"},{"name":"days_to_close","type":"STRING"},{"name":"description","type":"STRING"},{"name":"domain","type":"STRING"},{"name":"founded_year","type":"STRING"},{"name":"hs_analytics_first_timestamp","type":"STRING"},{"name":"hs_industry_group","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"lifecyclestage","type":"STRING"},{"name":"name","type":"STRING"},{"name":"numberofemployees","type":"STRING"},{"name":"owneremail","type":"STRING"},{"name":"ownername","type":"STRING"},{"name":"state","type":"STRING"},{"name":"total_revenue","type":"STRING"},{"name":"website","type":"STRING"},{"name":"zip","type":"STRING"}]},"source":"HUBSPOT_CONTENT_HUB","status":"DONE","table_name":"hubspot_companies_212c3bff_146e_4812_982f_2340e6efad58","tags":null,"updated_at":"2025-11-19T19:36:17Z"}}],"meta":{"page":{"type":"offset_limit","offset":0,"limit":15,"total":null,"first_offset":0,"prev_offset":null,"next_offset":15,"last_offset":null}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 288.170083ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e7d84519-47cb-4d39-ac2b-c51a64f0f8ff + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 783 + uncompressed: false + body: '{"data":{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 54.653ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e7d84519-47cb-4d39-ac2b-c51a64f0f8ff + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 783 + uncompressed: false + body: '{"data":{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 46.638792ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables?filter%5Btable_name%5D%5Bexact%5D=tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 932 + uncompressed: false + body: '{"data":[{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}}],"meta":{"page":{"type":"offset_limit","offset":0,"limit":15,"total":null,"first_offset":0,"prev_offset":null,"next_offset":15,"last_offset":null}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 244.735667ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e7d84519-47cb-4d39-ac2b-c51a64f0f8ff + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 783 + uncompressed: false + body: '{"data":{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 41.256875ms + - id: 6 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e7d84519-47cb-4d39-ac2b-c51a64f0f8ff + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 783 + uncompressed: false + body: '{"data":{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 58.675ms + - id: 7 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables?filter%5Btable_name%5D%5Bexact%5D=tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 932 + uncompressed: false + body: '{"data":[{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}}],"meta":{"page":{"type":"offset_limit","offset":0,"limit":15,"total":null,"first_offset":0,"prev_offset":null,"next_offset":15,"last_offset":null}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 258.126334ms + - id: 8 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e7d84519-47cb-4d39-ac2b-c51a64f0f8ff + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 783 + uncompressed: false + body: '{"data":{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 47.11175ms + - id: 9 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e7d84519-47cb-4d39-ac2b-c51a64f0f8ff + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 783 + uncompressed: false + body: '{"data":{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 104.207792ms + - id: 10 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e7d84519-47cb-4d39-ac2b-c51a64f0f8ff + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 783 + uncompressed: false + body: '{"data":{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 50.034375ms + - id: 11 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables?filter%5Btable_name%5D%5Bexact%5D=tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 932 + uncompressed: false + body: '{"data":[{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}}],"meta":{"page":{"type":"offset_limit","offset":0,"limit":15,"total":null,"first_offset":0,"prev_offset":null,"next_offset":15,"last_offset":null}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 241.136541ms + - id: 12 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e7d84519-47cb-4d39-ac2b-c51a64f0f8ff + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 783 + uncompressed: false + body: '{"data":{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 42.410583ms + - id: 13 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - '*/*' + url: https://api.datad0g.com/api/v2/reference-tables/tables/e7d84519-47cb-4d39-ac2b-c51a64f0f8ff + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 327.407625ms diff --git a/datadog/tests/cassettes/TestAccDatadogReferenceTableRowsDataSource.freeze b/datadog/tests/cassettes/TestAccDatadogReferenceTableRowsDataSource.freeze new file mode 100644 index 0000000000..87219524dd --- /dev/null +++ b/datadog/tests/cassettes/TestAccDatadogReferenceTableRowsDataSource.freeze @@ -0,0 +1 @@ +2025-11-19T14:48:10.362679-05:00 \ No newline at end of file diff --git a/datadog/tests/cassettes/TestAccDatadogReferenceTableRowsDataSource.yaml b/datadog/tests/cassettes/TestAccDatadogReferenceTableRowsDataSource.yaml new file mode 100644 index 0000000000..19280a60c3 --- /dev/null +++ b/datadog/tests/cassettes/TestAccDatadogReferenceTableRowsDataSource.yaml @@ -0,0 +1,402 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 542 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: | + {"data":{"attributes":{"description":"Test data source for rows","file_metadata":{"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}},"sync_enabled":true},"schema":{"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}],"primary_keys":["a"]},"source":"S3","table_name":"tf_test_ds_rows_tf_testaccdatadogreferencetablerowsdatasource_local_1763581690","tags":["test:datasource-rows"]},"type":"reference_table"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created + code: 201 + duration: 826.020417ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"data":[{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"72dc199d-6401-4527-b2e5-4cafaca6927c","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test schema evolution","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_evolution_tf_testaccreferencetable_schemaevolution_local_1763581690","tags":["test:terraform"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"8c4be62b-1b6c-4578-89b8-79c5f04b02b6","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test sync_enabled update","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_sync_tf_testaccreferencetable_updatesyncenabled_local_1763581690","tags":["test:terraform"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"134ee13a-0917-40d1-b0c8-6123f05ac568","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetables3_basic_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"e15180ff-b17b-423a-b8cf-4c6fc3f78928","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source for rows","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_rows_tf_testaccdatadogreferencetablerowsdatasource_local_1763581690","tags":["test:datasource-rows"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"5b7451b5-f91a-4547-8e06-7da0664fecff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetable_import_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"42b5c9ca-898a-466c-a54a-0481c9ab696f","type":"reference_table","attributes":{"created_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","description":"","last_updated_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","row_count":2,"schema":{"primary_keys":["name"],"fields":[{"name":"name","type":"STRING"},{"name":"url","type":"STRING"}]},"source":"SERVICENOW","status":"DONE","table_name":"http_bulk_client_e2e","tags":null,"updated_at":"2025-11-19T19:47:18Z"}},{"id":"f8ff12c9-4bdd-49e1-8956-4895cfcddbc3","type":"reference_table","attributes":{"created_by":"","description":"","file_metadata":{"error_row_count":342,"error_message":"","access_details":{}},"last_updated_by":"","row_count":4244780,"schema":{"primary_keys":["org_id"],"fields":[{"name":"account_family_customer_tier","type":"STRING"},{"name":"account_family_mrr","type":"STRING"},{"name":"account_health_status","type":"STRING"},{"name":"account_owner","type":"STRING"},{"name":"account_owner_email","type":"STRING"},{"name":"account_owner_role","type":"STRING"},{"name":"account_owner_territory","type":"STRING"},{"name":"account_sales_engineer","type":"STRING"},{"name":"account_status","type":"STRING"},{"name":"account_status_detail","type":"STRING"},{"name":"churn_reason","type":"STRING"},{"name":"churn_risk_likelihood","type":"STRING"},{"name":"churn_risk_reason","type":"STRING"},{"name":"country","type":"STRING"},{"name":"customer_success_rep","type":"STRING"},{"name":"customer_success_rep_email","type":"STRING"},{"name":"customer_tier","type":"STRING"},{"name":"employee_count","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"is_msp","type":"STRING"},{"name":"is_premier_support_enabled","type":"STRING"},{"name":"master_org_id","type":"STRING"},{"name":"master_org_name","type":"STRING"},{"name":"org_id","type":"STRING"},{"name":"org_name","type":"STRING"},{"name":"owner_sales_department","type":"STRING"},{"name":"owner_sales_team","type":"STRING"},{"name":"partner_tier","type":"STRING"},{"name":"premier_support_mrr","type":"STRING"},{"name":"region","type":"STRING"},{"name":"sales_engineer","type":"STRING"},{"name":"sales_engineer_email","type":"STRING"},{"name":"sales_segment","type":"STRING"},{"name":"technical_product_health_status","type":"STRING"},{"name":"type","type":"STRING"},{"name":"row_created_at","type":"STRING"},{"name":"row_updated_at","type":"STRING"}]},"source":"SNOWFLAKE","status":"DONE_WITH_ERRORS","table_name":"test_product_analytics_write_dest_saas","tags":["product_analytics_beta_enabled:true"],"updated_at":"2025-11-19T19:46:12Z"}},{"id":"f704bb0a-9eaf-4734-bd22-1caaca09d6ca","type":"reference_table","attributes":{"created_by":"972dde90-34e1-11eb-958e-f7f08ce02c26","description":"","file_metadata":{"error_row_count":172,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"727006795293","aws_bucket_name":"dd-logs-threat-intel-staging","file_path":"threat_intel_ip_abuse_ch_threatfox.csv"}}},"last_updated_by":"","row_count":1706,"schema":{"primary_keys":["ip_address"],"fields":[{"name":"ip_address","type":"STRING"},{"name":"intention","type":"STRING"},{"name":"category","type":"STRING"},{"name":"source","type":"STRING"},{"name":"additional_data","type":"STRING"}]},"source":"S3","status":"DONE_WITH_ERRORS","table_name":"threat_intel_ip_abuse_ch_threatfox","tags":null,"updated_at":"2025-11-19T19:45:55Z"}},{"id":"34c341b1-a97a-4893-b821-475f8bbf0561","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":1,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_crud_flow_7730722353299252260","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"cbc703e8-45a7-428d-9a85-079c9b4abcbf","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":2,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_v2_row_crud_flow_3796209879804171102","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"1fd37f6a-75a6-44b7-bb9a-2f8558fd2d6b","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":1,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_row_crud_flow_151529577687372015","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"ae91c101-a2e2-41d2-b99f-0cb5ff87e72a","type":"reference_table","attributes":{"created_by":"","description":"This is NOT an actual Snowflake table - it''s a test table updated by this synthetics: https://ddstaging.datadoghq.com/synthetics/details/ajx-zbt-khs?from_ts=1741296820320\u0026to_ts=1741300420320\u0026live=true.","file_metadata":{"error_row_count":1,"error_message":"","access_details":{}},"last_updated_by":"","row_count":1,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"name","type":"STRING"}]},"source":"SNOWFLAKE","status":"DONE_WITH_ERRORS","table_name":"synthetics_grpc_saas2","tags":null,"updated_at":"2025-11-19T19:43:35Z"}},{"id":"481ded06-c51f-48a3-97a6-aab88fd27b53","type":"reference_table","attributes":{"created_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","description":"","last_updated_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","row_count":29,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"name","type":"STRING"}]},"source":"API","status":"DONE","table_name":"test_sync_nov_18","tags":null,"updated_at":"2025-11-19T19:38:08Z"}},{"id":"4acf614f-6ee4-404b-8c36-4f0c1f9df648","type":"reference_table","attributes":{"created_by":"","description":"","last_updated_by":"","row_count":2,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"createdat","type":"STRING"},{"name":"updatedat","type":"STRING"},{"name":"archived","type":"STRING"},{"name":"url","type":"STRING"},{"name":"address","type":"STRING"},{"name":"address2","type":"STRING"},{"name":"annualrevenue","type":"STRING"},{"name":"city","type":"STRING"},{"name":"country","type":"STRING"},{"name":"days_to_close","type":"STRING"},{"name":"description","type":"STRING"},{"name":"domain","type":"STRING"},{"name":"founded_year","type":"STRING"},{"name":"hs_analytics_first_timestamp","type":"STRING"},{"name":"hs_industry_group","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"lifecyclestage","type":"STRING"},{"name":"name","type":"STRING"},{"name":"numberofemployees","type":"STRING"},{"name":"owneremail","type":"STRING"},{"name":"ownername","type":"STRING"},{"name":"state","type":"STRING"},{"name":"total_revenue","type":"STRING"},{"name":"website","type":"STRING"},{"name":"zip","type":"STRING"}]},"source":"HUBSPOT_CONTENT_HUB","status":"DONE","table_name":"hubspot_companies_212c3bff_146e_4812_982f_2340e6efad58","tags":null,"updated_at":"2025-11-19T19:36:17Z"}}],"meta":{"page":{"type":"offset_limit","offset":0,"limit":15,"total":null,"first_offset":0,"prev_offset":null,"next_offset":15,"last_offset":null}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 264.79ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e15180ff-b17b-423a-b8cf-4c6fc3f78928 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 806 + uncompressed: false + body: '{"data":{"id":"e15180ff-b17b-423a-b8cf-4c6fc3f78928","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source for rows","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_rows_tf_testaccdatadogreferencetablerowsdatasource_local_1763581690","tags":["test:datasource-rows"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 39.915292ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e15180ff-b17b-423a-b8cf-4c6fc3f78928 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 806 + uncompressed: false + body: '{"data":{"id":"e15180ff-b17b-423a-b8cf-4c6fc3f78928","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source for rows","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_rows_tf_testaccdatadogreferencetablerowsdatasource_local_1763581690","tags":["test:datasource-rows"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 62.009834ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e15180ff-b17b-423a-b8cf-4c6fc3f78928 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 806 + uncompressed: false + body: '{"data":{"id":"e15180ff-b17b-423a-b8cf-4c6fc3f78928","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source for rows","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_rows_tf_testaccdatadogreferencetablerowsdatasource_local_1763581690","tags":["test:datasource-rows"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 55.681958ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e15180ff-b17b-423a-b8cf-4c6fc3f78928/rows?row_id=1&row_id=2 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 78 + uncompressed: false + body: '{"data":[],"meta":{"requested_count":2,"found_count":0,"not_found":["1","2"]}}' + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found + code: 404 + duration: 51.141417ms + - id: 6 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e15180ff-b17b-423a-b8cf-4c6fc3f78928/rows?row_id=1&row_id=2 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 78 + uncompressed: false + body: '{"data":[],"meta":{"requested_count":2,"found_count":0,"not_found":["1","2"]}}' + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found + code: 404 + duration: 46.713708ms + - id: 7 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e15180ff-b17b-423a-b8cf-4c6fc3f78928/rows?row_id=1&row_id=2 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 218 + uncompressed: false + body: '{"data":[{"id":"1","type":"row","attributes":{"values":{"a":"1","b":"2","c":"3"}}},{"id":"2","type":"row","attributes":{"values":{"a":"2","b":"3","c":"4"}}}],"meta":{"requested_count":2,"found_count":2,"not_found":[]}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 61.361625ms + - id: 8 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e15180ff-b17b-423a-b8cf-4c6fc3f78928/rows?row_id=1&row_id=2 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 218 + uncompressed: false + body: '{"data":[{"id":"1","type":"row","attributes":{"values":{"a":"1","b":"2","c":"3"}}},{"id":"2","type":"row","attributes":{"values":{"a":"2","b":"3","c":"4"}}}],"meta":{"requested_count":2,"found_count":2,"not_found":[]}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 51.656792ms + - id: 9 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e15180ff-b17b-423a-b8cf-4c6fc3f78928 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 799 + uncompressed: false + body: '{"data":{"id":"e15180ff-b17b-423a-b8cf-4c6fc3f78928","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source for rows","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":4,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"DONE","table_name":"tf_test_ds_rows_tf_testaccdatadogreferencetablerowsdatasource_local_1763581690","tags":["test:datasource-rows"],"updated_at":"2025-11-19T19:48:20Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 49.358209ms + - id: 10 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/e15180ff-b17b-423a-b8cf-4c6fc3f78928/rows?row_id=1&row_id=2 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 218 + uncompressed: false + body: '{"data":[{"id":"1","type":"row","attributes":{"values":{"a":"1","b":"2","c":"3"}}},{"id":"2","type":"row","attributes":{"values":{"a":"2","b":"3","c":"4"}}}],"meta":{"requested_count":2,"found_count":2,"not_found":[]}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 52.242041ms + - id: 11 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - '*/*' + url: https://api.datad0g.com/api/v2/reference-tables/tables/e15180ff-b17b-423a-b8cf-4c6fc3f78928 + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 425.639834ms diff --git a/datadog/tests/cassettes/TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables.freeze b/datadog/tests/cassettes/TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables.freeze index 88c1abc605..0f7ee45296 100644 --- a/datadog/tests/cassettes/TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables.freeze +++ b/datadog/tests/cassettes/TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables.freeze @@ -1 +1 @@ -2025-09-15T16:33:11.400007+02:00 \ No newline at end of file +2025-11-19T14:48:10.524044-05:00 \ No newline at end of file diff --git a/datadog/tests/cassettes/TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables.yaml b/datadog/tests/cassettes/TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables.yaml index 1370135421..1bf46e4e3c 100644 --- a/datadog/tests/cassettes/TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables.yaml +++ b/datadog/tests/cassettes/TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables.yaml @@ -9,23 +9,23 @@ interactions: content_length: 1481 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: | - {"cases":[{"condition":"first \u003e 3 || second \u003e 10","name":"high case","notifications":["@user"],"status":"high"},{"condition":"first \u003e 0 || second \u003e 0","name":"warning case","notifications":[],"status":"medium"},{"condition":"third \u003e 9000","name":"low case","notifications":[],"status":"low"}],"hasExtendedTitle":true,"isEnabled":false,"message":"acceptance rule triggered","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791","options":{"decreaseCriticalityBasedOnEnv":true,"detectionMethod":"threshold","evaluationWindow":300,"keepAlive":600,"maxSignalDuration":900},"queries":[{"aggregation":"count","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first","query":"does not really match much"},{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"second","query":"does not really match much either"},{"aggregation":"sum","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"@network.bytes_read","metrics":[],"name":"third","query":"does not really match much either"}],"referenceTables":[{"checkPresence":true,"columnName":"column1","logFieldPath":"@testattribute","ruleQueryName":"first","tableName":"table1"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} + {"cases":[{"condition":"first \u003e 3 || second \u003e 10","name":"high case","notifications":["@user"],"status":"high"},{"condition":"first \u003e 0 || second \u003e 0","name":"warning case","notifications":[],"status":"medium"},{"condition":"third \u003e 9000","name":"low case","notifications":[],"status":"low"}],"hasExtendedTitle":true,"isEnabled":false,"message":"acceptance rule triggered","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690","options":{"decreaseCriticalityBasedOnEnv":true,"detectionMethod":"threshold","evaluationWindow":300,"keepAlive":600,"maxSignalDuration":900},"queries":[{"aggregation":"count","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first","query":"does not really match much"},{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"second","query":"does not really match much either"},{"aggregation":"sum","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"@network.bytes_read","metrics":[],"name":"third","query":"does not really match much either"}],"referenceTables":[{"checkPresence":true,"columnName":"column1","logFieldPath":"@testattribute","ruleQueryName":"first","tableName":"table1"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} form: {} headers: Accept: - '*/*' Content-Type: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/validation + url: https://api.datad0g.com/api/v2/security_monitoring/rules/validation method: POST response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 0 @@ -34,7 +34,7 @@ interactions: headers: {} status: 204 No Content code: 204 - duration: 773.93625ms + duration: 65.650833ms - id: 1 request: proto: HTTP/1.1 @@ -43,23 +43,23 @@ interactions: content_length: 1481 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: | - {"cases":[{"condition":"first \u003e 3 || second \u003e 10","name":"high case","notifications":["@user"],"status":"high"},{"condition":"first \u003e 0 || second \u003e 0","name":"warning case","notifications":[],"status":"medium"},{"condition":"third \u003e 9000","name":"low case","notifications":[],"status":"low"}],"hasExtendedTitle":true,"isEnabled":false,"message":"acceptance rule triggered","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791","options":{"decreaseCriticalityBasedOnEnv":true,"detectionMethod":"threshold","evaluationWindow":300,"keepAlive":600,"maxSignalDuration":900},"queries":[{"aggregation":"count","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first","query":"does not really match much"},{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"second","query":"does not really match much either"},{"aggregation":"sum","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"@network.bytes_read","metrics":[],"name":"third","query":"does not really match much either"}],"referenceTables":[{"checkPresence":true,"columnName":"column1","logFieldPath":"@testattribute","ruleQueryName":"first","tableName":"table1"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} + {"cases":[{"condition":"first \u003e 3 || second \u003e 10","name":"high case","notifications":["@user"],"status":"high"},{"condition":"first \u003e 0 || second \u003e 0","name":"warning case","notifications":[],"status":"medium"},{"condition":"third \u003e 9000","name":"low case","notifications":[],"status":"low"}],"hasExtendedTitle":true,"isEnabled":false,"message":"acceptance rule triggered","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690","options":{"decreaseCriticalityBasedOnEnv":true,"detectionMethod":"threshold","evaluationWindow":300,"keepAlive":600,"maxSignalDuration":900},"queries":[{"aggregation":"count","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first","query":"does not really match much"},{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"second","query":"does not really match much either"},{"aggregation":"sum","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"@network.bytes_read","metrics":[],"name":"third","query":"does not really match much either"}],"referenceTables":[{"checkPresence":true,"columnName":"column1","logFieldPath":"@testattribute","ruleQueryName":"first","tableName":"table1"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} form: {} headers: Accept: - '*/*' Content-Type: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/validation + url: https://api.datad0g.com/api/v2/security_monitoring/rules/validation method: POST response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 0 @@ -68,7 +68,7 @@ interactions: headers: {} status: 204 No Content code: 204 - duration: 265.906334ms + duration: 52.948666ms - id: 2 request: proto: HTTP/1.1 @@ -77,34 +77,34 @@ interactions: content_length: 1481 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: | - {"cases":[{"condition":"first \u003e 3 || second \u003e 10","name":"high case","notifications":["@user"],"status":"high"},{"condition":"first \u003e 0 || second \u003e 0","name":"warning case","notifications":[],"status":"medium"},{"condition":"third \u003e 9000","name":"low case","notifications":[],"status":"low"}],"hasExtendedTitle":true,"isEnabled":false,"message":"acceptance rule triggered","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791","options":{"decreaseCriticalityBasedOnEnv":true,"detectionMethod":"threshold","evaluationWindow":300,"keepAlive":600,"maxSignalDuration":900},"queries":[{"aggregation":"count","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first","query":"does not really match much"},{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"second","query":"does not really match much either"},{"aggregation":"sum","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"@network.bytes_read","metrics":[],"name":"third","query":"does not really match much either"}],"referenceTables":[{"checkPresence":true,"columnName":"column1","logFieldPath":"@testattribute","ruleQueryName":"first","tableName":"table1"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} + {"cases":[{"condition":"first \u003e 3 || second \u003e 10","name":"high case","notifications":["@user"],"status":"high"},{"condition":"first \u003e 0 || second \u003e 0","name":"warning case","notifications":[],"status":"medium"},{"condition":"third \u003e 9000","name":"low case","notifications":[],"status":"low"}],"hasExtendedTitle":true,"isEnabled":false,"message":"acceptance rule triggered","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690","options":{"decreaseCriticalityBasedOnEnv":true,"detectionMethod":"threshold","evaluationWindow":300,"keepAlive":600,"maxSignalDuration":900},"queries":[{"aggregation":"count","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first","query":"does not really match much"},{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"second","query":"does not really match much either"},{"aggregation":"sum","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"@network.bytes_read","metrics":[],"name":"third","query":"does not really match much either"}],"referenceTables":[{"checkPresence":true,"columnName":"column1","logFieldPath":"@testattribute","ruleQueryName":"first","tableName":"table1"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} form: {} headers: Accept: - application/json Content-Type: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules + url: https://api.datad0g.com/api/v2/security_monitoring/rules method: POST response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: -1 uncompressed: true - body: '{"name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791","createdAt":1757946794010,"isDefault":false,"isPartner":false,"isEnabled":false,"isBeta":false,"isDeleted":false,"isDeprecated":false,"queries":[{"query":"does not really match much","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"aggregation":"count","name":"first","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":["@orgId"],"aggregation":"cardinality","name":"second","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"metric":"@network.bytes_read","metrics":["@network.bytes_read"],"aggregation":"sum","name":"third","dataSource":"logs"}],"options":{"evaluationWindow":300,"detectionMethod":"threshold","maxSignalDuration":900,"keepAlive":600,"decreaseCriticalityBasedOnEnv":true},"cases":[{"name":"high case","status":"high","notifications":["@user"],"condition":"first \u003e 3 || second \u003e 10"},{"name":"warning case","status":"medium","notifications":[],"condition":"first \u003e 0 || second \u003e 0"},{"name":"low case","status":"low","notifications":[],"condition":"third \u003e 9000"}],"message":"acceptance rule triggered","tags":["u:tomato","i:tomato"],"hasExtendedTitle":true,"type":"log_detection","filters":[],"version":1,"id":"qvv-t5g-ak7","blocking":false,"metadata":{"entities":null,"sources":null},"referenceTables":[{"tableName":"table1","columnName":"column1","logFieldPath":"@testattribute","checkPresence":true,"ruleQueryName":"first"}],"creationAuthorId":1445416,"creator":{"handle":"frog@datadoghq.com","name":"frog"},"updater":{"handle":"","name":""}}' + body: '{"name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690","createdAt":1763581693468,"isDefault":false,"isPartner":false,"isEnabled":false,"isBeta":false,"isDeleted":false,"isDeprecated":false,"queries":[{"query":"does not really match much","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"aggregation":"count","name":"first","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":["@orgId"],"aggregation":"cardinality","name":"second","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"metric":"@network.bytes_read","metrics":["@network.bytes_read"],"aggregation":"sum","name":"third","dataSource":"logs"}],"options":{"evaluationWindow":300,"detectionMethod":"threshold","maxSignalDuration":900,"keepAlive":600,"decreaseCriticalityBasedOnEnv":true},"cases":[{"name":"high case","status":"high","notifications":["@user"],"condition":"first \u003e 3 || second \u003e 10"},{"name":"warning case","status":"medium","notifications":[],"condition":"first \u003e 0 || second \u003e 0"},{"name":"low case","status":"low","notifications":[],"condition":"third \u003e 9000"}],"message":"acceptance rule triggered","tags":["u:tomato","i:tomato"],"hasExtendedTitle":true,"type":"log_detection","filters":[],"version":1,"id":"bzs-ccd-zoh","blocking":false,"metadata":{"entities":null,"sources":null},"referenceTables":[{"tableName":"table1","columnName":"column1","logFieldPath":"@testattribute","checkPresence":true,"ruleQueryName":"first"}],"creationAuthorId":40426,"creator":{"handle":"guillaume.brizolier@datadoghq.com","name":"Guillaume Brizolier"},"updater":{"handle":"","name":""}}' headers: Content-Type: - application/json status: 200 OK code: 200 - duration: 141.084167ms + duration: 59.239208ms - id: 3 request: proto: HTTP/1.1 @@ -113,7 +113,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -121,23 +121,23 @@ interactions: headers: Accept: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/qvv-t5g-ak7 + url: https://api.datad0g.com/api/v2/security_monitoring/rules/bzs-ccd-zoh method: GET response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: -1 uncompressed: true - body: '{"name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791","createdAt":1757946794010,"isDefault":false,"isPartner":false,"isEnabled":false,"isBeta":false,"isDeleted":false,"isDeprecated":false,"queries":[{"query":"does not really match much","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"aggregation":"count","name":"first","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":["@orgId"],"aggregation":"cardinality","name":"second","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"metric":"@network.bytes_read","metrics":["@network.bytes_read"],"aggregation":"sum","name":"third","dataSource":"logs"}],"options":{"evaluationWindow":300,"detectionMethod":"threshold","maxSignalDuration":900,"keepAlive":600,"decreaseCriticalityBasedOnEnv":true},"cases":[{"name":"high case","status":"high","notifications":["@user"],"condition":"first \u003e 3 || second \u003e 10"},{"name":"warning case","status":"medium","notifications":[],"condition":"first \u003e 0 || second \u003e 0"},{"name":"low case","status":"low","notifications":[],"condition":"third \u003e 9000"}],"message":"acceptance rule triggered","tags":["u:tomato","i:tomato"],"hasExtendedTitle":true,"type":"log_detection","filters":[],"version":1,"id":"qvv-t5g-ak7","blocking":false,"metadata":{"entities":null,"sources":null},"referenceTables":[{"tableName":"table1","columnName":"column1","logFieldPath":"@testattribute","checkPresence":true,"ruleQueryName":"first"}],"creationAuthorId":1445416,"creator":{"handle":"frog@datadoghq.com","name":"frog"},"updater":{"handle":"","name":""}}' + body: '{"name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690","createdAt":1763581693468,"isDefault":false,"isPartner":false,"isEnabled":false,"isBeta":false,"isDeleted":false,"isDeprecated":false,"queries":[{"query":"does not really match much","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"aggregation":"count","name":"first","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":["@orgId"],"aggregation":"cardinality","name":"second","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"metric":"@network.bytes_read","metrics":["@network.bytes_read"],"aggregation":"sum","name":"third","dataSource":"logs"}],"options":{"evaluationWindow":300,"detectionMethod":"threshold","maxSignalDuration":900,"keepAlive":600,"decreaseCriticalityBasedOnEnv":true},"cases":[{"name":"high case","status":"high","notifications":["@user"],"condition":"first \u003e 3 || second \u003e 10"},{"name":"warning case","status":"medium","notifications":[],"condition":"first \u003e 0 || second \u003e 0"},{"name":"low case","status":"low","notifications":[],"condition":"third \u003e 9000"}],"message":"acceptance rule triggered","tags":["u:tomato","i:tomato"],"hasExtendedTitle":true,"type":"log_detection","filters":[],"version":1,"id":"bzs-ccd-zoh","blocking":false,"metadata":{"entities":null,"sources":null},"referenceTables":[{"tableName":"table1","columnName":"column1","logFieldPath":"@testattribute","checkPresence":true,"ruleQueryName":"first"}],"creationAuthorId":40426,"creator":{"handle":"guillaume.brizolier@datadoghq.com","name":"Guillaume Brizolier"},"updater":{"handle":"","name":""}}' headers: Content-Type: - application/json status: 200 OK code: 200 - duration: 161.501042ms + duration: 40.8145ms - id: 4 request: proto: HTTP/1.1 @@ -146,23 +146,23 @@ interactions: content_length: 1481 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: | - {"cases":[{"condition":"first \u003e 3 || second \u003e 10","name":"high case","notifications":["@user"],"status":"high"},{"condition":"first \u003e 0 || second \u003e 0","name":"warning case","notifications":[],"status":"medium"},{"condition":"third \u003e 9000","name":"low case","notifications":[],"status":"low"}],"hasExtendedTitle":true,"isEnabled":false,"message":"acceptance rule triggered","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791","options":{"decreaseCriticalityBasedOnEnv":true,"detectionMethod":"threshold","evaluationWindow":300,"keepAlive":600,"maxSignalDuration":900},"queries":[{"aggregation":"count","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first","query":"does not really match much"},{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"second","query":"does not really match much either"},{"aggregation":"sum","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"@network.bytes_read","metrics":[],"name":"third","query":"does not really match much either"}],"referenceTables":[{"checkPresence":true,"columnName":"column1","logFieldPath":"@testattribute","ruleQueryName":"first","tableName":"table1"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} + {"cases":[{"condition":"first \u003e 3 || second \u003e 10","name":"high case","notifications":["@user"],"status":"high"},{"condition":"first \u003e 0 || second \u003e 0","name":"warning case","notifications":[],"status":"medium"},{"condition":"third \u003e 9000","name":"low case","notifications":[],"status":"low"}],"hasExtendedTitle":true,"isEnabled":false,"message":"acceptance rule triggered","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690","options":{"decreaseCriticalityBasedOnEnv":true,"detectionMethod":"threshold","evaluationWindow":300,"keepAlive":600,"maxSignalDuration":900},"queries":[{"aggregation":"count","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first","query":"does not really match much"},{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"second","query":"does not really match much either"},{"aggregation":"sum","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"@network.bytes_read","metrics":[],"name":"third","query":"does not really match much either"}],"referenceTables":[{"checkPresence":true,"columnName":"column1","logFieldPath":"@testattribute","ruleQueryName":"first","tableName":"table1"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} form: {} headers: Accept: - '*/*' Content-Type: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/validation + url: https://api.datad0g.com/api/v2/security_monitoring/rules/validation method: POST response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 0 @@ -171,7 +171,7 @@ interactions: headers: {} status: 204 No Content code: 204 - duration: 120.418917ms + duration: 94.66075ms - id: 5 request: proto: HTTP/1.1 @@ -180,7 +180,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -188,23 +188,23 @@ interactions: headers: Accept: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/qvv-t5g-ak7 + url: https://api.datad0g.com/api/v2/security_monitoring/rules/bzs-ccd-zoh method: GET response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: -1 uncompressed: true - body: '{"name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791","createdAt":1757946794010,"isDefault":false,"isPartner":false,"isEnabled":false,"isBeta":false,"isDeleted":false,"isDeprecated":false,"queries":[{"query":"does not really match much","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"aggregation":"count","name":"first","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":["@orgId"],"aggregation":"cardinality","name":"second","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"metric":"@network.bytes_read","metrics":["@network.bytes_read"],"aggregation":"sum","name":"third","dataSource":"logs"}],"options":{"evaluationWindow":300,"detectionMethod":"threshold","maxSignalDuration":900,"keepAlive":600,"decreaseCriticalityBasedOnEnv":true},"cases":[{"name":"high case","status":"high","notifications":["@user"],"condition":"first \u003e 3 || second \u003e 10"},{"name":"warning case","status":"medium","notifications":[],"condition":"first \u003e 0 || second \u003e 0"},{"name":"low case","status":"low","notifications":[],"condition":"third \u003e 9000"}],"message":"acceptance rule triggered","tags":["u:tomato","i:tomato"],"hasExtendedTitle":true,"type":"log_detection","filters":[],"version":1,"id":"qvv-t5g-ak7","blocking":false,"metadata":{"entities":null,"sources":null},"referenceTables":[{"tableName":"table1","columnName":"column1","logFieldPath":"@testattribute","checkPresence":true,"ruleQueryName":"first"}],"creationAuthorId":1445416,"creator":{"handle":"frog@datadoghq.com","name":"frog"},"updater":{"handle":"","name":""}}' + body: '{"name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690","createdAt":1763581693468,"isDefault":false,"isPartner":false,"isEnabled":false,"isBeta":false,"isDeleted":false,"isDeprecated":false,"queries":[{"query":"does not really match much","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"aggregation":"count","name":"first","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":["@orgId"],"aggregation":"cardinality","name":"second","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"metric":"@network.bytes_read","metrics":["@network.bytes_read"],"aggregation":"sum","name":"third","dataSource":"logs"}],"options":{"evaluationWindow":300,"detectionMethod":"threshold","maxSignalDuration":900,"keepAlive":600,"decreaseCriticalityBasedOnEnv":true},"cases":[{"name":"high case","status":"high","notifications":["@user"],"condition":"first \u003e 3 || second \u003e 10"},{"name":"warning case","status":"medium","notifications":[],"condition":"first \u003e 0 || second \u003e 0"},{"name":"low case","status":"low","notifications":[],"condition":"third \u003e 9000"}],"message":"acceptance rule triggered","tags":["u:tomato","i:tomato"],"hasExtendedTitle":true,"type":"log_detection","filters":[],"version":1,"id":"bzs-ccd-zoh","blocking":false,"metadata":{"entities":null,"sources":null},"referenceTables":[{"tableName":"table1","columnName":"column1","logFieldPath":"@testattribute","checkPresence":true,"ruleQueryName":"first"}],"creationAuthorId":40426,"creator":{"handle":"guillaume.brizolier@datadoghq.com","name":"Guillaume Brizolier"},"updater":{"handle":"","name":""}}' headers: Content-Type: - application/json status: 200 OK code: 200 - duration: 340.828292ms + duration: 48.703458ms - id: 6 request: proto: HTTP/1.1 @@ -213,23 +213,23 @@ interactions: content_length: 1502 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: | - {"cases":[{"condition":"first \u003e 3 || second \u003e 10","name":"high case","notifications":["@user"],"status":"high"},{"condition":"first \u003e 0 || second \u003e 0","name":"warning case","notifications":[],"status":"medium"},{"condition":"third \u003e 9000","name":"low case","notifications":[],"status":"low"}],"hasExtendedTitle":true,"isEnabled":false,"message":"acceptance rule triggered","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791","options":{"decreaseCriticalityBasedOnEnv":true,"detectionMethod":"threshold","evaluationWindow":300,"keepAlive":600,"maxSignalDuration":900},"queries":[{"aggregation":"count","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first","query":"does not really match much"},{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"second","query":"does not really match much either"},{"aggregation":"sum","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"@network.bytes_read","metrics":["@network.bytes_read"],"name":"third","query":"does not really match much either"}],"referenceTables":[{"checkPresence":true,"columnName":"column1","logFieldPath":"@testattribute","ruleQueryName":"first","tableName":"table1"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} + {"cases":[{"condition":"first \u003e 3 || second \u003e 10","name":"high case","notifications":["@user"],"status":"high"},{"condition":"first \u003e 0 || second \u003e 0","name":"warning case","notifications":[],"status":"medium"},{"condition":"third \u003e 9000","name":"low case","notifications":[],"status":"low"}],"hasExtendedTitle":true,"isEnabled":false,"message":"acceptance rule triggered","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690","options":{"decreaseCriticalityBasedOnEnv":true,"detectionMethod":"threshold","evaluationWindow":300,"keepAlive":600,"maxSignalDuration":900},"queries":[{"aggregation":"count","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first","query":"does not really match much"},{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"second","query":"does not really match much either"},{"aggregation":"sum","dataSource":"logs","distinctFields":[],"groupByFields":["host"],"hasOptionalGroupByFields":false,"metric":"@network.bytes_read","metrics":["@network.bytes_read"],"name":"third","query":"does not really match much either"}],"referenceTables":[{"checkPresence":true,"columnName":"column1","logFieldPath":"@testattribute","ruleQueryName":"first","tableName":"table1"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} form: {} headers: Accept: - '*/*' Content-Type: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/validation + url: https://api.datad0g.com/api/v2/security_monitoring/rules/validation method: POST response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 0 @@ -238,7 +238,7 @@ interactions: headers: {} status: 204 No Content code: 204 - duration: 132.109458ms + duration: 53.127334ms - id: 7 request: proto: HTTP/1.1 @@ -247,7 +247,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -255,23 +255,23 @@ interactions: headers: Accept: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/qvv-t5g-ak7 + url: https://api.datad0g.com/api/v2/security_monitoring/rules/bzs-ccd-zoh method: GET response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: -1 uncompressed: true - body: '{"name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791","createdAt":1757946794010,"isDefault":false,"isPartner":false,"isEnabled":false,"isBeta":false,"isDeleted":false,"isDeprecated":false,"queries":[{"query":"does not really match much","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"aggregation":"count","name":"first","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":["@orgId"],"aggregation":"cardinality","name":"second","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"metric":"@network.bytes_read","metrics":["@network.bytes_read"],"aggregation":"sum","name":"third","dataSource":"logs"}],"options":{"evaluationWindow":300,"detectionMethod":"threshold","maxSignalDuration":900,"keepAlive":600,"decreaseCriticalityBasedOnEnv":true},"cases":[{"name":"high case","status":"high","notifications":["@user"],"condition":"first \u003e 3 || second \u003e 10"},{"name":"warning case","status":"medium","notifications":[],"condition":"first \u003e 0 || second \u003e 0"},{"name":"low case","status":"low","notifications":[],"condition":"third \u003e 9000"}],"message":"acceptance rule triggered","tags":["u:tomato","i:tomato"],"hasExtendedTitle":true,"type":"log_detection","filters":[],"version":1,"id":"qvv-t5g-ak7","blocking":false,"metadata":{"entities":null,"sources":null},"referenceTables":[{"tableName":"table1","columnName":"column1","logFieldPath":"@testattribute","checkPresence":true,"ruleQueryName":"first"}],"creationAuthorId":1445416,"creator":{"handle":"frog@datadoghq.com","name":"frog"},"updater":{"handle":"","name":""}}' + body: '{"name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690","createdAt":1763581693468,"isDefault":false,"isPartner":false,"isEnabled":false,"isBeta":false,"isDeleted":false,"isDeprecated":false,"queries":[{"query":"does not really match much","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"aggregation":"count","name":"first","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":["@orgId"],"aggregation":"cardinality","name":"second","dataSource":"logs"},{"query":"does not really match much either","groupByFields":["host"],"hasOptionalGroupByFields":false,"distinctFields":[],"metric":"@network.bytes_read","metrics":["@network.bytes_read"],"aggregation":"sum","name":"third","dataSource":"logs"}],"options":{"evaluationWindow":300,"detectionMethod":"threshold","maxSignalDuration":900,"keepAlive":600,"decreaseCriticalityBasedOnEnv":true},"cases":[{"name":"high case","status":"high","notifications":["@user"],"condition":"first \u003e 3 || second \u003e 10"},{"name":"warning case","status":"medium","notifications":[],"condition":"first \u003e 0 || second \u003e 0"},{"name":"low case","status":"low","notifications":[],"condition":"third \u003e 9000"}],"message":"acceptance rule triggered","tags":["u:tomato","i:tomato"],"hasExtendedTitle":true,"type":"log_detection","filters":[],"version":1,"id":"bzs-ccd-zoh","blocking":false,"metadata":{"entities":null,"sources":null},"referenceTables":[{"tableName":"table1","columnName":"column1","logFieldPath":"@testattribute","checkPresence":true,"ruleQueryName":"first"}],"creationAuthorId":40426,"creator":{"handle":"guillaume.brizolier@datadoghq.com","name":"Guillaume Brizolier"},"updater":{"handle":"","name":""}}' headers: Content-Type: - application/json status: 200 OK code: 200 - duration: 161.081209ms + duration: 46.868875ms - id: 8 request: proto: HTTP/1.1 @@ -280,23 +280,23 @@ interactions: content_length: 860 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: | - {"cases":[{"condition":"first_updated \u003e 3","name":"high case (updated)","notifications":["@user"],"status":"medium"},{"condition":"first_updated \u003e 0","name":"warning case (updated)","notifications":[],"status":"high"}],"hasExtendedTitle":false,"isEnabled":true,"message":"acceptance rule triggered (updated)","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791 - updated","options":{"decreaseCriticalityBasedOnEnv":false,"detectionMethod":"threshold","evaluationWindow":60,"keepAlive":300,"maxSignalDuration":600},"queries":[{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["service"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first_updated","query":"does not really match much (updated)"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} + {"cases":[{"condition":"first_updated \u003e 3","name":"high case (updated)","notifications":["@user"],"status":"medium"},{"condition":"first_updated \u003e 0","name":"warning case (updated)","notifications":[],"status":"high"}],"hasExtendedTitle":false,"isEnabled":true,"message":"acceptance rule triggered (updated)","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690 - updated","options":{"decreaseCriticalityBasedOnEnv":false,"detectionMethod":"threshold","evaluationWindow":60,"keepAlive":300,"maxSignalDuration":600},"queries":[{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["service"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first_updated","query":"does not really match much (updated)"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} form: {} headers: Accept: - '*/*' Content-Type: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/validation + url: https://api.datad0g.com/api/v2/security_monitoring/rules/validation method: POST response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 0 @@ -305,7 +305,7 @@ interactions: headers: {} status: 204 No Content code: 204 - duration: 181.627625ms + duration: 94.277583ms - id: 9 request: proto: HTTP/1.1 @@ -314,23 +314,23 @@ interactions: content_length: 860 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: | - {"cases":[{"condition":"first_updated \u003e 3","name":"high case (updated)","notifications":["@user"],"status":"medium"},{"condition":"first_updated \u003e 0","name":"warning case (updated)","notifications":[],"status":"high"}],"hasExtendedTitle":false,"isEnabled":true,"message":"acceptance rule triggered (updated)","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791 - updated","options":{"decreaseCriticalityBasedOnEnv":false,"detectionMethod":"threshold","evaluationWindow":60,"keepAlive":300,"maxSignalDuration":600},"queries":[{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["service"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first_updated","query":"does not really match much (updated)"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} + {"cases":[{"condition":"first_updated \u003e 3","name":"high case (updated)","notifications":["@user"],"status":"medium"},{"condition":"first_updated \u003e 0","name":"warning case (updated)","notifications":[],"status":"high"}],"hasExtendedTitle":false,"isEnabled":true,"message":"acceptance rule triggered (updated)","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690 - updated","options":{"decreaseCriticalityBasedOnEnv":false,"detectionMethod":"threshold","evaluationWindow":60,"keepAlive":300,"maxSignalDuration":600},"queries":[{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["service"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first_updated","query":"does not really match much (updated)"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} form: {} headers: Accept: - '*/*' Content-Type: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/validation + url: https://api.datad0g.com/api/v2/security_monitoring/rules/validation method: POST response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 0 @@ -339,7 +339,7 @@ interactions: headers: {} status: 204 No Content code: 204 - duration: 148.46625ms + duration: 49.35825ms - id: 10 request: proto: HTTP/1.1 @@ -348,34 +348,34 @@ interactions: content_length: 918 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: | - {"calculatedFields":[],"cases":[{"condition":"first_updated \u003e 3","name":"high case (updated)","notifications":["@user"],"status":"medium"},{"condition":"first_updated \u003e 0","name":"warning case (updated)","notifications":[],"status":"high"}],"filters":[],"hasExtendedTitle":false,"isEnabled":true,"message":"acceptance rule triggered (updated)","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791 - updated","options":{"decreaseCriticalityBasedOnEnv":false,"detectionMethod":"threshold","evaluationWindow":60,"keepAlive":300,"maxSignalDuration":600},"queries":[{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["service"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first_updated","query":"does not really match much (updated)"}],"referenceTables":[],"schedulingOptions":null,"tags":["u:tomato","i:tomato"]} + {"calculatedFields":[],"cases":[{"condition":"first_updated \u003e 3","name":"high case (updated)","notifications":["@user"],"status":"medium"},{"condition":"first_updated \u003e 0","name":"warning case (updated)","notifications":[],"status":"high"}],"filters":[],"hasExtendedTitle":false,"isEnabled":true,"message":"acceptance rule triggered (updated)","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690 - updated","options":{"decreaseCriticalityBasedOnEnv":false,"detectionMethod":"threshold","evaluationWindow":60,"keepAlive":300,"maxSignalDuration":600},"queries":[{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["service"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first_updated","query":"does not really match much (updated)"}],"referenceTables":[],"schedulingOptions":null,"tags":["u:tomato","i:tomato"]} form: {} headers: Accept: - application/json Content-Type: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/qvv-t5g-ak7 + url: https://api.datad0g.com/api/v2/security_monitoring/rules/bzs-ccd-zoh method: PUT response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: -1 uncompressed: true - body: '{"name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791 - updated","isEnabled":true,"queries":[{"query":"does not really match much (updated)","groupByFields":["service"],"hasOptionalGroupByFields":false,"distinctFields":["@orgId"],"aggregation":"cardinality","name":"first_updated","dataSource":"logs"}],"options":{"evaluationWindow":60,"detectionMethod":"threshold","maxSignalDuration":600,"keepAlive":300,"decreaseCriticalityBasedOnEnv":false},"cases":[{"name":"high case (updated)","status":"medium","notifications":["@user"],"condition":"first_updated \u003e 3"},{"name":"warning case (updated)","status":"high","notifications":[],"condition":"first_updated \u003e 0"}],"message":"acceptance rule triggered (updated)","tags":["u:tomato","i:tomato"],"hasExtendedTitle":false,"type":"log_detection","filters":[],"id":"qvv-t5g-ak7","version":2,"createdAt":1757946794010,"creationAuthorId":1445416,"updateAuthorId":1445416,"updatedAt":1757946796922,"isDefault":false,"blocking":false,"isBeta":false,"isDeleted":false,"isDeprecated":false,"metadata":{"entities":null,"sources":null}}' + body: '{"name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690 - updated","isEnabled":true,"queries":[{"query":"does not really match much (updated)","groupByFields":["service"],"hasOptionalGroupByFields":false,"distinctFields":["@orgId"],"aggregation":"cardinality","name":"first_updated","dataSource":"logs"}],"options":{"evaluationWindow":60,"detectionMethod":"threshold","maxSignalDuration":600,"keepAlive":300,"decreaseCriticalityBasedOnEnv":false},"cases":[{"name":"high case (updated)","status":"medium","notifications":["@user"],"condition":"first_updated \u003e 3"},{"name":"warning case (updated)","status":"high","notifications":[],"condition":"first_updated \u003e 0"}],"message":"acceptance rule triggered (updated)","tags":["u:tomato","i:tomato"],"hasExtendedTitle":false,"type":"log_detection","filters":[],"id":"bzs-ccd-zoh","version":2,"createdAt":1763581693468,"creationAuthorId":40426,"updateAuthorId":40426,"updatedAt":1763581695751,"isDefault":false,"blocking":false,"isBeta":false,"isDeleted":false,"isDeprecated":false,"metadata":{"entities":null,"sources":null}}' headers: Content-Type: - application/json status: 200 OK code: 200 - duration: 168.721709ms + duration: 292.789209ms - id: 11 request: proto: HTTP/1.1 @@ -384,7 +384,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -392,23 +392,23 @@ interactions: headers: Accept: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/qvv-t5g-ak7 + url: https://api.datad0g.com/api/v2/security_monitoring/rules/bzs-ccd-zoh method: GET response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: -1 uncompressed: true - body: '{"name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791 - updated","createdAt":1757946794010,"isDefault":false,"isPartner":false,"isEnabled":true,"isBeta":false,"isDeleted":false,"isDeprecated":false,"queries":[{"query":"does not really match much (updated)","groupByFields":["service"],"hasOptionalGroupByFields":false,"distinctFields":["@orgId"],"aggregation":"cardinality","name":"first_updated","dataSource":"logs"}],"options":{"evaluationWindow":60,"detectionMethod":"threshold","maxSignalDuration":600,"keepAlive":300,"decreaseCriticalityBasedOnEnv":false},"cases":[{"name":"high case (updated)","status":"medium","notifications":["@user"],"condition":"first_updated \u003e 3"},{"name":"warning case (updated)","status":"high","notifications":[],"condition":"first_updated \u003e 0"}],"message":"acceptance rule triggered (updated)","tags":["u:tomato","i:tomato"],"hasExtendedTitle":false,"type":"log_detection","filters":[],"version":2,"id":"qvv-t5g-ak7","updatedAt":1757946796922,"blocking":false,"metadata":{"entities":null,"sources":null},"creationAuthorId":1445416,"updateAuthorId":1445416,"creator":{"handle":"frog@datadoghq.com","name":"frog"},"updater":{"handle":"frog@datadoghq.com","name":"frog"}}' + body: '{"name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690 - updated","createdAt":1763581693468,"isDefault":false,"isPartner":false,"isEnabled":true,"isBeta":false,"isDeleted":false,"isDeprecated":false,"queries":[{"query":"does not really match much (updated)","groupByFields":["service"],"hasOptionalGroupByFields":false,"distinctFields":["@orgId"],"aggregation":"cardinality","name":"first_updated","dataSource":"logs"}],"options":{"evaluationWindow":60,"detectionMethod":"threshold","maxSignalDuration":600,"keepAlive":300,"decreaseCriticalityBasedOnEnv":false},"cases":[{"name":"high case (updated)","status":"medium","notifications":["@user"],"condition":"first_updated \u003e 3"},{"name":"warning case (updated)","status":"high","notifications":[],"condition":"first_updated \u003e 0"}],"message":"acceptance rule triggered (updated)","tags":["u:tomato","i:tomato"],"hasExtendedTitle":false,"type":"log_detection","filters":[],"version":2,"id":"bzs-ccd-zoh","updatedAt":1763581695751,"blocking":false,"metadata":{"entities":null,"sources":null},"creationAuthorId":40426,"updateAuthorId":40426,"creator":{"handle":"guillaume.brizolier@datadoghq.com","name":"Guillaume Brizolier"},"updater":{"handle":"guillaume.brizolier@datadoghq.com","name":"Guillaume Brizolier"}}' headers: Content-Type: - application/json status: 200 OK code: 200 - duration: 164.053ms + duration: 47.99125ms - id: 12 request: proto: HTTP/1.1 @@ -417,23 +417,23 @@ interactions: content_length: 860 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: | - {"cases":[{"condition":"first_updated \u003e 3","name":"high case (updated)","notifications":["@user"],"status":"medium"},{"condition":"first_updated \u003e 0","name":"warning case (updated)","notifications":[],"status":"high"}],"hasExtendedTitle":false,"isEnabled":true,"message":"acceptance rule triggered (updated)","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791 - updated","options":{"decreaseCriticalityBasedOnEnv":false,"detectionMethod":"threshold","evaluationWindow":60,"keepAlive":300,"maxSignalDuration":600},"queries":[{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["service"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first_updated","query":"does not really match much (updated)"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} + {"cases":[{"condition":"first_updated \u003e 3","name":"high case (updated)","notifications":["@user"],"status":"medium"},{"condition":"first_updated \u003e 0","name":"warning case (updated)","notifications":[],"status":"high"}],"hasExtendedTitle":false,"isEnabled":true,"message":"acceptance rule triggered (updated)","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690 - updated","options":{"decreaseCriticalityBasedOnEnv":false,"detectionMethod":"threshold","evaluationWindow":60,"keepAlive":300,"maxSignalDuration":600},"queries":[{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["service"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first_updated","query":"does not really match much (updated)"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} form: {} headers: Accept: - '*/*' Content-Type: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/validation + url: https://api.datad0g.com/api/v2/security_monitoring/rules/validation method: POST response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 0 @@ -442,7 +442,7 @@ interactions: headers: {} status: 204 No Content code: 204 - duration: 157.570834ms + duration: 60.492458ms - id: 13 request: proto: HTTP/1.1 @@ -451,7 +451,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -459,23 +459,23 @@ interactions: headers: Accept: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/qvv-t5g-ak7 + url: https://api.datad0g.com/api/v2/security_monitoring/rules/bzs-ccd-zoh method: GET response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: -1 uncompressed: true - body: '{"name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791 - updated","createdAt":1757946794010,"isDefault":false,"isPartner":false,"isEnabled":true,"isBeta":false,"isDeleted":false,"isDeprecated":false,"queries":[{"query":"does not really match much (updated)","groupByFields":["service"],"hasOptionalGroupByFields":false,"distinctFields":["@orgId"],"aggregation":"cardinality","name":"first_updated","dataSource":"logs"}],"options":{"evaluationWindow":60,"detectionMethod":"threshold","maxSignalDuration":600,"keepAlive":300,"decreaseCriticalityBasedOnEnv":false},"cases":[{"name":"high case (updated)","status":"medium","notifications":["@user"],"condition":"first_updated \u003e 3"},{"name":"warning case (updated)","status":"high","notifications":[],"condition":"first_updated \u003e 0"}],"message":"acceptance rule triggered (updated)","tags":["u:tomato","i:tomato"],"hasExtendedTitle":false,"type":"log_detection","filters":[],"version":2,"id":"qvv-t5g-ak7","updatedAt":1757946796922,"blocking":false,"metadata":{"entities":null,"sources":null},"creationAuthorId":1445416,"updateAuthorId":1445416,"creator":{"handle":"frog@datadoghq.com","name":"frog"},"updater":{"handle":"frog@datadoghq.com","name":"frog"}}' + body: '{"name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690 - updated","createdAt":1763581693468,"isDefault":false,"isPartner":false,"isEnabled":true,"isBeta":false,"isDeleted":false,"isDeprecated":false,"queries":[{"query":"does not really match much (updated)","groupByFields":["service"],"hasOptionalGroupByFields":false,"distinctFields":["@orgId"],"aggregation":"cardinality","name":"first_updated","dataSource":"logs"}],"options":{"evaluationWindow":60,"detectionMethod":"threshold","maxSignalDuration":600,"keepAlive":300,"decreaseCriticalityBasedOnEnv":false},"cases":[{"name":"high case (updated)","status":"medium","notifications":["@user"],"condition":"first_updated \u003e 3"},{"name":"warning case (updated)","status":"high","notifications":[],"condition":"first_updated \u003e 0"}],"message":"acceptance rule triggered (updated)","tags":["u:tomato","i:tomato"],"hasExtendedTitle":false,"type":"log_detection","filters":[],"version":2,"id":"bzs-ccd-zoh","updatedAt":1763581695751,"blocking":false,"metadata":{"entities":null,"sources":null},"creationAuthorId":40426,"updateAuthorId":40426,"creator":{"handle":"guillaume.brizolier@datadoghq.com","name":"Guillaume Brizolier"},"updater":{"handle":"guillaume.brizolier@datadoghq.com","name":"Guillaume Brizolier"}}' headers: Content-Type: - application/json status: 200 OK code: 200 - duration: 153.2725ms + duration: 44.030667ms - id: 14 request: proto: HTTP/1.1 @@ -484,23 +484,23 @@ interactions: content_length: 860 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: | - {"cases":[{"condition":"first_updated \u003e 3","name":"high case (updated)","notifications":["@user"],"status":"medium"},{"condition":"first_updated \u003e 0","name":"warning case (updated)","notifications":[],"status":"high"}],"hasExtendedTitle":false,"isEnabled":true,"message":"acceptance rule triggered (updated)","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1757946791 - updated","options":{"decreaseCriticalityBasedOnEnv":false,"detectionMethod":"threshold","evaluationWindow":60,"keepAlive":300,"maxSignalDuration":600},"queries":[{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["service"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first_updated","query":"does not really match much (updated)"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} + {"cases":[{"condition":"first_updated \u003e 3","name":"high case (updated)","notifications":["@user"],"status":"medium"},{"condition":"first_updated \u003e 0","name":"warning case (updated)","notifications":[],"status":"high"}],"hasExtendedTitle":false,"isEnabled":true,"message":"acceptance rule triggered (updated)","name":"tf-TestAccDatadogSecurityMonitoringRule_RemoveReferenceTables-local-1763581690 - updated","options":{"decreaseCriticalityBasedOnEnv":false,"detectionMethod":"threshold","evaluationWindow":60,"keepAlive":300,"maxSignalDuration":600},"queries":[{"aggregation":"cardinality","dataSource":"logs","distinctFields":["@orgId"],"groupByFields":["service"],"hasOptionalGroupByFields":false,"metric":"","metrics":[],"name":"first_updated","query":"does not really match much (updated)"}],"tags":["u:tomato","i:tomato"],"type":"log_detection"} form: {} headers: Accept: - '*/*' Content-Type: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/validation + url: https://api.datad0g.com/api/v2/security_monitoring/rules/validation method: POST response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 0 @@ -509,7 +509,7 @@ interactions: headers: {} status: 204 No Content code: 204 - duration: 150.849833ms + duration: 43.339958ms - id: 15 request: proto: HTTP/1.1 @@ -518,7 +518,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -526,12 +526,12 @@ interactions: headers: Accept: - '*/*' - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/qvv-t5g-ak7 + url: https://api.datad0g.com/api/v2/security_monitoring/rules/bzs-ccd-zoh method: DELETE response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 0 @@ -540,7 +540,7 @@ interactions: headers: {} status: 204 No Content code: 204 - duration: 165.9155ms + duration: 70.448708ms - id: 16 request: proto: HTTP/1.1 @@ -549,7 +549,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -557,20 +557,20 @@ interactions: headers: Accept: - application/json - url: https://api.datadoghq.com/api/v2/security_monitoring/rules/qvv-t5g-ak7 + url: https://api.datad0g.com/api/v2/security_monitoring/rules/bzs-ccd-zoh method: GET response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 86 uncompressed: false - body: '{"error":{"code":"NotFound","message":"Threat detection rule not found: qvv-t5g-ak7"}}' + body: '{"error":{"code":"NotFound","message":"Threat detection rule not found: bzs-ccd-zoh"}}' headers: Content-Type: - application/json status: 404 Not Found code: 404 - duration: 120.361833ms + duration: 65.982292ms diff --git a/datadog/tests/cassettes/TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule.freeze b/datadog/tests/cassettes/TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule.freeze index a5baab6280..57f4e41525 100644 --- a/datadog/tests/cassettes/TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule.freeze +++ b/datadog/tests/cassettes/TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule.freeze @@ -1 +1 @@ -2025-09-18T08:16:01.76008-04:00 \ No newline at end of file +2025-11-19T14:48:10.363579-05:00 \ No newline at end of file diff --git a/datadog/tests/cassettes/TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule.yaml b/datadog/tests/cassettes/TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule.yaml index 3e243d0494..e2f5c9c8e1 100644 --- a/datadog/tests/cassettes/TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule.yaml +++ b/datadog/tests/cassettes/TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule.yaml @@ -9,34 +9,34 @@ interactions: content_length: 504 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: | - {"data":{"attributes":{"enabled":true,"rules":[{"enabled":true,"mapping":null,"name":"ref-table-rule","query":null,"reference_table":{"case_insensitivity":true,"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"if_not_exists":false,"source_keys":["service"],"table_name":"service_mapping"}}]},"id":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule-local-1758197761","type":"create_ruleset"}} + {"data":{"attributes":{"enabled":true,"rules":[{"enabled":true,"mapping":null,"name":"ref-table-rule","query":null,"reference_table":{"case_insensitivity":true,"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"if_not_exists":false,"source_keys":["service"],"table_name":"service_mapping"}}]},"id":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule-local-1763581690","type":"create_ruleset"}} form: {} headers: Accept: - application/json Content-Type: - application/json - url: https://api.datadoghq.com/api/v2/tags/enrichment + url: https://api.datad0g.com/api/v2/tags/enrichment method: POST response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} - content_length: 757 + content_length: 755 uncompressed: false - body: '{"data":{"id":"cf852924-95d9-42e0-9e26-cab2988bd6de","type":"ruleset","attributes":{"created":{"seconds":1758197763,"nanos":297800000},"enabled":true,"last_modified_user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","modified":{"seconds":1758197763,"nanos":297800000},"name":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule-local-1758197761","position":2,"rules":[{"name":"ref-table-rule","enabled":true,"query":null,"mapping":null,"reference_table":{"table_name":"service_mapping","source_keys":["service"],"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"case_insensitivity":true,"if_not_exists":false},"metadata":null}],"version":3604071}}}' + body: '{"data":{"id":"8ee45e5d-1b51-4d20-9b2f-169e8431376f","type":"ruleset","attributes":{"created":{"seconds":1763581694,"nanos":39423000},"enabled":true,"last_modified_user_uuid":"51bca672-7464-11ea-ad29-6762102f9f58","modified":{"seconds":1763581694,"nanos":39423000},"name":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule-local-1763581690","position":99,"rules":[{"name":"ref-table-rule","enabled":true,"query":null,"mapping":null,"reference_table":{"table_name":"service_mapping","source_keys":["service"],"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"case_insensitivity":true,"if_not_exists":false},"metadata":null}],"version":433826}}}' headers: Content-Type: - application/vnd.api+json status: 200 OK code: 200 - duration: 129.089583ms + duration: 706.437042ms - id: 1 request: proto: HTTP/1.1 @@ -45,7 +45,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -53,23 +53,23 @@ interactions: headers: Accept: - application/json - url: https://api.datadoghq.com/api/v2/tags/enrichment/cf852924-95d9-42e0-9e26-cab2988bd6de + url: https://api.datad0g.com/api/v2/tags/enrichment/8ee45e5d-1b51-4d20-9b2f-169e8431376f method: GET response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} - content_length: 757 + content_length: 788 uncompressed: false - body: '{"data":{"id":"cf852924-95d9-42e0-9e26-cab2988bd6de","type":"ruleset","attributes":{"created":{"seconds":1758197763,"nanos":297800000},"enabled":true,"last_modified_user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","modified":{"seconds":1758197763,"nanos":297800000},"name":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule-local-1758197761","position":2,"rules":[{"name":"ref-table-rule","enabled":true,"query":null,"mapping":null,"reference_table":{"table_name":"service_mapping","source_keys":["service"],"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"case_insensitivity":true,"if_not_exists":false},"metadata":null}],"version":3604071}}}' + body: '{"data":{"id":"8ee45e5d-1b51-4d20-9b2f-169e8431376f","type":"ruleset","attributes":{"created":{"seconds":1763581694,"nanos":39423000},"enabled":true,"last_modified_user_uuid":"51bca672-7464-11ea-ad29-6762102f9f58","modified":{"seconds":1763581694,"nanos":39423000},"name":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule-local-1763581690","position":99,"processing_status":"processing","rules":[{"name":"ref-table-rule","enabled":true,"query":null,"mapping":null,"reference_table":{"table_name":"service_mapping","source_keys":["service"],"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"case_insensitivity":true,"if_not_exists":false},"metadata":null}],"version":433826}}}' headers: Content-Type: - application/vnd.api+json status: 200 OK code: 200 - duration: 59.639791ms + duration: 1.523099792s - id: 2 request: proto: HTTP/1.1 @@ -78,7 +78,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -86,23 +86,23 @@ interactions: headers: Accept: - application/json - url: https://api.datadoghq.com/api/v2/tags/enrichment/cf852924-95d9-42e0-9e26-cab2988bd6de + url: https://api.datad0g.com/api/v2/tags/enrichment/8ee45e5d-1b51-4d20-9b2f-169e8431376f method: GET response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} - content_length: 757 + content_length: 788 uncompressed: false - body: '{"data":{"id":"cf852924-95d9-42e0-9e26-cab2988bd6de","type":"ruleset","attributes":{"created":{"seconds":1758197763,"nanos":297800000},"enabled":true,"last_modified_user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","modified":{"seconds":1758197763,"nanos":297800000},"name":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule-local-1758197761","position":2,"rules":[{"name":"ref-table-rule","enabled":true,"query":null,"mapping":null,"reference_table":{"table_name":"service_mapping","source_keys":["service"],"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"case_insensitivity":true,"if_not_exists":false},"metadata":null}],"version":3604071}}}' + body: '{"data":{"id":"8ee45e5d-1b51-4d20-9b2f-169e8431376f","type":"ruleset","attributes":{"created":{"seconds":1763581694,"nanos":39423000},"enabled":true,"last_modified_user_uuid":"51bca672-7464-11ea-ad29-6762102f9f58","modified":{"seconds":1763581694,"nanos":39423000},"name":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule-local-1763581690","position":99,"processing_status":"processing","rules":[{"name":"ref-table-rule","enabled":true,"query":null,"mapping":null,"reference_table":{"table_name":"service_mapping","source_keys":["service"],"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"case_insensitivity":true,"if_not_exists":false},"metadata":null}],"version":433826}}}' headers: Content-Type: - application/vnd.api+json status: 200 OK code: 200 - duration: 54.353125ms + duration: 1.177853792s - id: 3 request: proto: HTTP/1.1 @@ -111,7 +111,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -119,23 +119,23 @@ interactions: headers: Accept: - application/json - url: https://api.datadoghq.com/api/v2/tags/enrichment/cf852924-95d9-42e0-9e26-cab2988bd6de + url: https://api.datad0g.com/api/v2/tags/enrichment/8ee45e5d-1b51-4d20-9b2f-169e8431376f method: GET response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} - content_length: 757 + content_length: 788 uncompressed: false - body: '{"data":{"id":"cf852924-95d9-42e0-9e26-cab2988bd6de","type":"ruleset","attributes":{"created":{"seconds":1758197763,"nanos":297800000},"enabled":true,"last_modified_user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","modified":{"seconds":1758197763,"nanos":297800000},"name":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule-local-1758197761","position":2,"rules":[{"name":"ref-table-rule","enabled":true,"query":null,"mapping":null,"reference_table":{"table_name":"service_mapping","source_keys":["service"],"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"case_insensitivity":true,"if_not_exists":false},"metadata":null}],"version":3604071}}}' + body: '{"data":{"id":"8ee45e5d-1b51-4d20-9b2f-169e8431376f","type":"ruleset","attributes":{"created":{"seconds":1763581694,"nanos":39423000},"enabled":true,"last_modified_user_uuid":"51bca672-7464-11ea-ad29-6762102f9f58","modified":{"seconds":1763581694,"nanos":39423000},"name":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule-local-1763581690","position":98,"processing_status":"processing","rules":[{"name":"ref-table-rule","enabled":true,"query":null,"mapping":null,"reference_table":{"table_name":"service_mapping","source_keys":["service"],"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"case_insensitivity":true,"if_not_exists":false},"metadata":null}],"version":433826}}}' headers: Content-Type: - application/vnd.api+json status: 200 OK code: 200 - duration: 51.758708ms + duration: 1.712290416s - id: 4 request: proto: HTTP/1.1 @@ -144,7 +144,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -152,23 +152,23 @@ interactions: headers: Accept: - application/json - url: https://api.datadoghq.com/api/v2/tags/enrichment/cf852924-95d9-42e0-9e26-cab2988bd6de + url: https://api.datad0g.com/api/v2/tags/enrichment/8ee45e5d-1b51-4d20-9b2f-169e8431376f method: GET response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} - content_length: 757 + content_length: 788 uncompressed: false - body: '{"data":{"id":"cf852924-95d9-42e0-9e26-cab2988bd6de","type":"ruleset","attributes":{"created":{"seconds":1758197763,"nanos":297800000},"enabled":true,"last_modified_user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","modified":{"seconds":1758197763,"nanos":297800000},"name":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule-local-1758197761","position":2,"rules":[{"name":"ref-table-rule","enabled":true,"query":null,"mapping":null,"reference_table":{"table_name":"service_mapping","source_keys":["service"],"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"case_insensitivity":true,"if_not_exists":false},"metadata":null}],"version":3604071}}}' + body: '{"data":{"id":"8ee45e5d-1b51-4d20-9b2f-169e8431376f","type":"ruleset","attributes":{"created":{"seconds":1763581694,"nanos":39423000},"enabled":true,"last_modified_user_uuid":"51bca672-7464-11ea-ad29-6762102f9f58","modified":{"seconds":1763581694,"nanos":39423000},"name":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRulesetDataSource_ReferenceTableRule-local-1763581690","position":98,"processing_status":"processing","rules":[{"name":"ref-table-rule","enabled":true,"query":null,"mapping":null,"reference_table":{"table_name":"service_mapping","source_keys":["service"],"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"case_insensitivity":true,"if_not_exists":false},"metadata":null}],"version":433826}}}' headers: Content-Type: - application/vnd.api+json status: 200 OK code: 200 - duration: 43.6065ms + duration: 1.264583708s - id: 5 request: proto: HTTP/1.1 @@ -177,7 +177,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -185,12 +185,12 @@ interactions: headers: Accept: - '*/*' - url: https://api.datadoghq.com/api/v2/tags/enrichment/cf852924-95d9-42e0-9e26-cab2988bd6de + url: https://api.datad0g.com/api/v2/tags/enrichment/8ee45e5d-1b51-4d20-9b2f-169e8431376f method: DELETE response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 0 @@ -199,7 +199,7 @@ interactions: headers: {} status: 204 No Content code: 204 - duration: 88.463792ms + duration: 62.364125ms - id: 6 request: proto: HTTP/1.1 @@ -208,7 +208,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -216,23 +216,23 @@ interactions: headers: Accept: - application/json - url: https://api.datadoghq.com/api/v2/tags/enrichment/cf852924-95d9-42e0-9e26-cab2988bd6de + url: https://api.datad0g.com/api/v2/tags/enrichment/8ee45e5d-1b51-4d20-9b2f-169e8431376f method: GET response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 115 uncompressed: false - body: '{"errors":[{"status":"404","title":"Not Found","detail":"ruleset cf852924-95d9-42e0-9e26-cab2988bd6de not found"}]}' + body: '{"errors":[{"status":"404","title":"Not Found","detail":"ruleset 8ee45e5d-1b51-4d20-9b2f-169e8431376f not found"}]}' headers: Content-Type: - application/vnd.api+json status: 404 Not Found code: 404 - duration: 62.5905ms + duration: 37.109459ms - id: 7 request: proto: HTTP/1.1 @@ -241,7 +241,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -249,20 +249,20 @@ interactions: headers: Accept: - application/json - url: https://api.datadoghq.com/api/v2/tags/enrichment/cf852924-95d9-42e0-9e26-cab2988bd6de + url: https://api.datad0g.com/api/v2/tags/enrichment/8ee45e5d-1b51-4d20-9b2f-169e8431376f method: GET response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 115 uncompressed: false - body: '{"errors":[{"status":"404","title":"Not Found","detail":"ruleset cf852924-95d9-42e0-9e26-cab2988bd6de not found"}]}' + body: '{"errors":[{"status":"404","title":"Not Found","detail":"ruleset 8ee45e5d-1b51-4d20-9b2f-169e8431376f not found"}]}' headers: Content-Type: - application/vnd.api+json status: 404 Not Found code: 404 - duration: 81.998666ms + duration: 35.500833ms diff --git a/datadog/tests/cassettes/TestAccDatadogTagPipelineRuleset_ReferenceTableRule.freeze b/datadog/tests/cassettes/TestAccDatadogTagPipelineRuleset_ReferenceTableRule.freeze index 65ed82b77c..09d9ed5b83 100644 --- a/datadog/tests/cassettes/TestAccDatadogTagPipelineRuleset_ReferenceTableRule.freeze +++ b/datadog/tests/cassettes/TestAccDatadogTagPipelineRuleset_ReferenceTableRule.freeze @@ -1 +1 @@ -2025-10-06T10:10:15.688303-04:00 \ No newline at end of file +2025-11-19T14:48:10.363845-05:00 \ No newline at end of file diff --git a/datadog/tests/cassettes/TestAccDatadogTagPipelineRuleset_ReferenceTableRule.yaml b/datadog/tests/cassettes/TestAccDatadogTagPipelineRuleset_ReferenceTableRule.yaml index 0520d7006f..57fee23866 100644 --- a/datadog/tests/cassettes/TestAccDatadogTagPipelineRuleset_ReferenceTableRule.yaml +++ b/datadog/tests/cassettes/TestAccDatadogTagPipelineRuleset_ReferenceTableRule.yaml @@ -9,34 +9,34 @@ interactions: content_length: 494 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: | - {"data":{"attributes":{"enabled":true,"rules":[{"enabled":true,"mapping":null,"name":"ref-table-rule","query":null,"reference_table":{"case_insensitivity":true,"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"if_not_exists":false,"source_keys":["service"],"table_name":"service_mapping"}}]},"id":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRuleset_ReferenceTableRule-local-1759759815","type":"create_ruleset"}} + {"data":{"attributes":{"enabled":true,"rules":[{"enabled":true,"mapping":null,"name":"ref-table-rule","query":null,"reference_table":{"case_insensitivity":true,"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"if_not_exists":false,"source_keys":["service"],"table_name":"service_mapping"}}]},"id":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRuleset_ReferenceTableRule-local-1763581690","type":"create_ruleset"}} form: {} headers: Accept: - application/json Content-Type: - application/json - url: https://api.datadoghq.com/api/v2/tags/enrichment + url: https://api.datad0g.com/api/v2/tags/enrichment method: POST response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 747 uncompressed: false - body: '{"data":{"id":"ae2324b8-0e33-4727-b7a0-b77abc310f8f","type":"ruleset","attributes":{"created":{"seconds":1759759816,"nanos":908089000},"enabled":true,"last_modified_user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","modified":{"seconds":1759759816,"nanos":908089000},"name":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRuleset_ReferenceTableRule-local-1759759815","position":1,"rules":[{"name":"ref-table-rule","enabled":true,"query":null,"mapping":null,"reference_table":{"table_name":"service_mapping","source_keys":["service"],"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"case_insensitivity":true,"if_not_exists":false},"metadata":null}],"version":3610346}}}' + body: '{"data":{"id":"d6ec441e-6ff6-4e48-b6d7-27d434accab4","type":"ruleset","attributes":{"created":{"seconds":1763581693,"nanos":779252000},"enabled":true,"last_modified_user_uuid":"51bca672-7464-11ea-ad29-6762102f9f58","modified":{"seconds":1763581693,"nanos":779252000},"name":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRuleset_ReferenceTableRule-local-1763581690","position":98,"rules":[{"name":"ref-table-rule","enabled":true,"query":null,"mapping":null,"reference_table":{"table_name":"service_mapping","source_keys":["service"],"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"case_insensitivity":true,"if_not_exists":false},"metadata":null}],"version":433825}}}' headers: Content-Type: - application/vnd.api+json status: 200 OK code: 200 - duration: 121.171375ms + duration: 648.813916ms - id: 1 request: proto: HTTP/1.1 @@ -45,7 +45,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -53,23 +53,23 @@ interactions: headers: Accept: - application/json - url: https://api.datadoghq.com/api/v2/tags/enrichment/ae2324b8-0e33-4727-b7a0-b77abc310f8f + url: https://api.datad0g.com/api/v2/tags/enrichment/d6ec441e-6ff6-4e48-b6d7-27d434accab4 method: GET response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} - content_length: 775 + content_length: 780 uncompressed: false - body: '{"data":{"id":"ae2324b8-0e33-4727-b7a0-b77abc310f8f","type":"ruleset","attributes":{"created":{"seconds":1759759816,"nanos":908089000},"enabled":true,"last_modified_user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","modified":{"seconds":1759759816,"nanos":908089000},"name":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRuleset_ReferenceTableRule-local-1759759815","position":1,"processing_status":"error","rules":[{"name":"ref-table-rule","enabled":true,"query":null,"mapping":null,"reference_table":{"table_name":"service_mapping","source_keys":["service"],"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"case_insensitivity":true,"if_not_exists":false},"metadata":null}],"version":3610346}}}' + body: '{"data":{"id":"d6ec441e-6ff6-4e48-b6d7-27d434accab4","type":"ruleset","attributes":{"created":{"seconds":1763581693,"nanos":779252000},"enabled":true,"last_modified_user_uuid":"51bca672-7464-11ea-ad29-6762102f9f58","modified":{"seconds":1763581693,"nanos":779252000},"name":"tf-test-ref-table-ruleset-tf-TestAccDatadogTagPipelineRuleset_ReferenceTableRule-local-1763581690","position":98,"processing_status":"processing","rules":[{"name":"ref-table-rule","enabled":true,"query":null,"mapping":null,"reference_table":{"table_name":"service_mapping","source_keys":["service"],"field_pairs":[{"input_column":"service_name","output_key":"service"},{"input_column":"team_name","output_key":"team"}],"case_insensitivity":true,"if_not_exists":false},"metadata":null}],"version":433825}}}' headers: Content-Type: - application/vnd.api+json status: 200 OK code: 200 - duration: 127.972625ms + duration: 1.077655958s - id: 2 request: proto: HTTP/1.1 @@ -78,7 +78,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -86,12 +86,12 @@ interactions: headers: Accept: - '*/*' - url: https://api.datadoghq.com/api/v2/tags/enrichment/ae2324b8-0e33-4727-b7a0-b77abc310f8f + url: https://api.datad0g.com/api/v2/tags/enrichment/d6ec441e-6ff6-4e48-b6d7-27d434accab4 method: DELETE response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 0 @@ -100,7 +100,7 @@ interactions: headers: {} status: 204 No Content code: 204 - duration: 66.678667ms + duration: 65.520792ms - id: 3 request: proto: HTTP/1.1 @@ -109,7 +109,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: api.datadoghq.com + host: api.datad0g.com remote_addr: "" request_uri: "" body: "" @@ -117,20 +117,20 @@ interactions: headers: Accept: - application/json - url: https://api.datadoghq.com/api/v2/tags/enrichment/ae2324b8-0e33-4727-b7a0-b77abc310f8f + url: https://api.datad0g.com/api/v2/tags/enrichment/d6ec441e-6ff6-4e48-b6d7-27d434accab4 method: GET response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 transfer_encoding: [] trailer: {} content_length: 115 uncompressed: false - body: '{"errors":[{"status":"404","title":"Not Found","detail":"ruleset ae2324b8-0e33-4727-b7a0-b77abc310f8f not found"}]}' + body: '{"errors":[{"status":"404","title":"Not Found","detail":"ruleset d6ec441e-6ff6-4e48-b6d7-27d434accab4 not found"}]}' headers: Content-Type: - application/vnd.api+json status: 404 Not Found code: 404 - duration: 72.825333ms + duration: 38.566ms diff --git a/datadog/tests/cassettes/TestAccReferenceTableS3_Basic.freeze b/datadog/tests/cassettes/TestAccReferenceTableS3_Basic.freeze new file mode 100644 index 0000000000..26d88a5e3f --- /dev/null +++ b/datadog/tests/cassettes/TestAccReferenceTableS3_Basic.freeze @@ -0,0 +1 @@ +2025-11-19T14:48:10.362857-05:00 \ No newline at end of file diff --git a/datadog/tests/cassettes/TestAccReferenceTableS3_Basic.yaml b/datadog/tests/cassettes/TestAccReferenceTableS3_Basic.yaml new file mode 100644 index 0000000000..6c0a874716 --- /dev/null +++ b/datadog/tests/cassettes/TestAccReferenceTableS3_Basic.yaml @@ -0,0 +1,171 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 527 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: | + {"data":{"attributes":{"description":"Test S3 reference table","file_metadata":{"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}},"sync_enabled":true},"schema":{"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}],"primary_keys":["a"]},"source":"S3","table_name":"tf_test_s3_tf_testaccreferencetables3_basic_local_1763581690","tags":["test:terraform","env:test"]},"type":"reference_table"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created + code: 201 + duration: 884.246166ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"data":[{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"72dc199d-6401-4527-b2e5-4cafaca6927c","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test schema evolution","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_evolution_tf_testaccreferencetable_schemaevolution_local_1763581690","tags":["test:terraform"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"8c4be62b-1b6c-4578-89b8-79c5f04b02b6","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test sync_enabled update","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_sync_tf_testaccreferencetable_updatesyncenabled_local_1763581690","tags":["test:terraform"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"134ee13a-0917-40d1-b0c8-6123f05ac568","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetables3_basic_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"e15180ff-b17b-423a-b8cf-4c6fc3f78928","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source for rows","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_rows_tf_testaccdatadogreferencetablerowsdatasource_local_1763581690","tags":["test:datasource-rows"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"5b7451b5-f91a-4547-8e06-7da0664fecff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetable_import_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"42b5c9ca-898a-466c-a54a-0481c9ab696f","type":"reference_table","attributes":{"created_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","description":"","last_updated_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","row_count":2,"schema":{"primary_keys":["name"],"fields":[{"name":"name","type":"STRING"},{"name":"url","type":"STRING"}]},"source":"SERVICENOW","status":"DONE","table_name":"http_bulk_client_e2e","tags":null,"updated_at":"2025-11-19T19:47:18Z"}},{"id":"f8ff12c9-4bdd-49e1-8956-4895cfcddbc3","type":"reference_table","attributes":{"created_by":"","description":"","file_metadata":{"error_row_count":342,"error_message":"","access_details":{}},"last_updated_by":"","row_count":4244780,"schema":{"primary_keys":["org_id"],"fields":[{"name":"account_family_customer_tier","type":"STRING"},{"name":"account_family_mrr","type":"STRING"},{"name":"account_health_status","type":"STRING"},{"name":"account_owner","type":"STRING"},{"name":"account_owner_email","type":"STRING"},{"name":"account_owner_role","type":"STRING"},{"name":"account_owner_territory","type":"STRING"},{"name":"account_sales_engineer","type":"STRING"},{"name":"account_status","type":"STRING"},{"name":"account_status_detail","type":"STRING"},{"name":"churn_reason","type":"STRING"},{"name":"churn_risk_likelihood","type":"STRING"},{"name":"churn_risk_reason","type":"STRING"},{"name":"country","type":"STRING"},{"name":"customer_success_rep","type":"STRING"},{"name":"customer_success_rep_email","type":"STRING"},{"name":"customer_tier","type":"STRING"},{"name":"employee_count","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"is_msp","type":"STRING"},{"name":"is_premier_support_enabled","type":"STRING"},{"name":"master_org_id","type":"STRING"},{"name":"master_org_name","type":"STRING"},{"name":"org_id","type":"STRING"},{"name":"org_name","type":"STRING"},{"name":"owner_sales_department","type":"STRING"},{"name":"owner_sales_team","type":"STRING"},{"name":"partner_tier","type":"STRING"},{"name":"premier_support_mrr","type":"STRING"},{"name":"region","type":"STRING"},{"name":"sales_engineer","type":"STRING"},{"name":"sales_engineer_email","type":"STRING"},{"name":"sales_segment","type":"STRING"},{"name":"technical_product_health_status","type":"STRING"},{"name":"type","type":"STRING"},{"name":"row_created_at","type":"STRING"},{"name":"row_updated_at","type":"STRING"}]},"source":"SNOWFLAKE","status":"DONE_WITH_ERRORS","table_name":"test_product_analytics_write_dest_saas","tags":["product_analytics_beta_enabled:true"],"updated_at":"2025-11-19T19:46:12Z"}},{"id":"f704bb0a-9eaf-4734-bd22-1caaca09d6ca","type":"reference_table","attributes":{"created_by":"972dde90-34e1-11eb-958e-f7f08ce02c26","description":"","file_metadata":{"error_row_count":172,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"727006795293","aws_bucket_name":"dd-logs-threat-intel-staging","file_path":"threat_intel_ip_abuse_ch_threatfox.csv"}}},"last_updated_by":"","row_count":1706,"schema":{"primary_keys":["ip_address"],"fields":[{"name":"ip_address","type":"STRING"},{"name":"intention","type":"STRING"},{"name":"category","type":"STRING"},{"name":"source","type":"STRING"},{"name":"additional_data","type":"STRING"}]},"source":"S3","status":"DONE_WITH_ERRORS","table_name":"threat_intel_ip_abuse_ch_threatfox","tags":null,"updated_at":"2025-11-19T19:45:55Z"}},{"id":"34c341b1-a97a-4893-b821-475f8bbf0561","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":1,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_crud_flow_7730722353299252260","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"cbc703e8-45a7-428d-9a85-079c9b4abcbf","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":2,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_v2_row_crud_flow_3796209879804171102","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"1fd37f6a-75a6-44b7-bb9a-2f8558fd2d6b","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":1,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_row_crud_flow_151529577687372015","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"ae91c101-a2e2-41d2-b99f-0cb5ff87e72a","type":"reference_table","attributes":{"created_by":"","description":"This is NOT an actual Snowflake table - it''s a test table updated by this synthetics: https://ddstaging.datadoghq.com/synthetics/details/ajx-zbt-khs?from_ts=1741296820320\u0026to_ts=1741300420320\u0026live=true.","file_metadata":{"error_row_count":1,"error_message":"","access_details":{}},"last_updated_by":"","row_count":1,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"name","type":"STRING"}]},"source":"SNOWFLAKE","status":"DONE_WITH_ERRORS","table_name":"synthetics_grpc_saas2","tags":null,"updated_at":"2025-11-19T19:43:35Z"}},{"id":"481ded06-c51f-48a3-97a6-aab88fd27b53","type":"reference_table","attributes":{"created_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","description":"","last_updated_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","row_count":29,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"name","type":"STRING"}]},"source":"API","status":"DONE","table_name":"test_sync_nov_18","tags":null,"updated_at":"2025-11-19T19:38:08Z"}},{"id":"4acf614f-6ee4-404b-8c36-4f0c1f9df648","type":"reference_table","attributes":{"created_by":"","description":"","last_updated_by":"","row_count":2,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"createdat","type":"STRING"},{"name":"updatedat","type":"STRING"},{"name":"archived","type":"STRING"},{"name":"url","type":"STRING"},{"name":"address","type":"STRING"},{"name":"address2","type":"STRING"},{"name":"annualrevenue","type":"STRING"},{"name":"city","type":"STRING"},{"name":"country","type":"STRING"},{"name":"days_to_close","type":"STRING"},{"name":"description","type":"STRING"},{"name":"domain","type":"STRING"},{"name":"founded_year","type":"STRING"},{"name":"hs_analytics_first_timestamp","type":"STRING"},{"name":"hs_industry_group","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"lifecyclestage","type":"STRING"},{"name":"name","type":"STRING"},{"name":"numberofemployees","type":"STRING"},{"name":"owneremail","type":"STRING"},{"name":"ownername","type":"STRING"},{"name":"state","type":"STRING"},{"name":"total_revenue","type":"STRING"},{"name":"website","type":"STRING"},{"name":"zip","type":"STRING"}]},"source":"HUBSPOT_CONTENT_HUB","status":"DONE","table_name":"hubspot_companies_212c3bff_146e_4812_982f_2340e6efad58","tags":null,"updated_at":"2025-11-19T19:36:17Z"}}],"meta":{"page":{"type":"offset_limit","offset":0,"limit":15,"total":null,"first_offset":0,"prev_offset":null,"next_offset":15,"last_offset":null}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 254.051292ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/134ee13a-0917-40d1-b0c8-6123f05ac568 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 791 + uncompressed: false + body: '{"data":{"id":"134ee13a-0917-40d1-b0c8-6123f05ac568","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetables3_basic_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 37.911167ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/134ee13a-0917-40d1-b0c8-6123f05ac568 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 791 + uncompressed: false + body: '{"data":{"id":"134ee13a-0917-40d1-b0c8-6123f05ac568","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetables3_basic_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 49.816833ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - '*/*' + url: https://api.datad0g.com/api/v2/reference-tables/tables/134ee13a-0917-40d1-b0c8-6123f05ac568 + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 318.1755ms diff --git a/datadog/tests/cassettes/TestAccReferenceTable_Import.freeze b/datadog/tests/cassettes/TestAccReferenceTable_Import.freeze new file mode 100644 index 0000000000..7d00756125 --- /dev/null +++ b/datadog/tests/cassettes/TestAccReferenceTable_Import.freeze @@ -0,0 +1 @@ +2025-11-19T14:48:10.363662-05:00 \ No newline at end of file diff --git a/datadog/tests/cassettes/TestAccReferenceTable_Import.yaml b/datadog/tests/cassettes/TestAccReferenceTable_Import.yaml new file mode 100644 index 0000000000..2ff6e28bff --- /dev/null +++ b/datadog/tests/cassettes/TestAccReferenceTable_Import.yaml @@ -0,0 +1,204 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 526 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: | + {"data":{"attributes":{"description":"Test S3 reference table","file_metadata":{"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}},"sync_enabled":true},"schema":{"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}],"primary_keys":["a"]},"source":"S3","table_name":"tf_test_s3_tf_testaccreferencetable_import_local_1763581690","tags":["test:terraform","env:test"]},"type":"reference_table"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created + code: 201 + duration: 871.513958ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"data":[{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"72dc199d-6401-4527-b2e5-4cafaca6927c","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test schema evolution","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_evolution_tf_testaccreferencetable_schemaevolution_local_1763581690","tags":["test:terraform"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"8c4be62b-1b6c-4578-89b8-79c5f04b02b6","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test sync_enabled update","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_sync_tf_testaccreferencetable_updatesyncenabled_local_1763581690","tags":["test:terraform"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"134ee13a-0917-40d1-b0c8-6123f05ac568","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetables3_basic_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"e15180ff-b17b-423a-b8cf-4c6fc3f78928","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source for rows","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_rows_tf_testaccdatadogreferencetablerowsdatasource_local_1763581690","tags":["test:datasource-rows"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"5b7451b5-f91a-4547-8e06-7da0664fecff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetable_import_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"42b5c9ca-898a-466c-a54a-0481c9ab696f","type":"reference_table","attributes":{"created_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","description":"","last_updated_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","row_count":2,"schema":{"primary_keys":["name"],"fields":[{"name":"name","type":"STRING"},{"name":"url","type":"STRING"}]},"source":"SERVICENOW","status":"DONE","table_name":"http_bulk_client_e2e","tags":null,"updated_at":"2025-11-19T19:47:18Z"}},{"id":"f8ff12c9-4bdd-49e1-8956-4895cfcddbc3","type":"reference_table","attributes":{"created_by":"","description":"","file_metadata":{"error_row_count":342,"error_message":"","access_details":{}},"last_updated_by":"","row_count":4244780,"schema":{"primary_keys":["org_id"],"fields":[{"name":"account_family_customer_tier","type":"STRING"},{"name":"account_family_mrr","type":"STRING"},{"name":"account_health_status","type":"STRING"},{"name":"account_owner","type":"STRING"},{"name":"account_owner_email","type":"STRING"},{"name":"account_owner_role","type":"STRING"},{"name":"account_owner_territory","type":"STRING"},{"name":"account_sales_engineer","type":"STRING"},{"name":"account_status","type":"STRING"},{"name":"account_status_detail","type":"STRING"},{"name":"churn_reason","type":"STRING"},{"name":"churn_risk_likelihood","type":"STRING"},{"name":"churn_risk_reason","type":"STRING"},{"name":"country","type":"STRING"},{"name":"customer_success_rep","type":"STRING"},{"name":"customer_success_rep_email","type":"STRING"},{"name":"customer_tier","type":"STRING"},{"name":"employee_count","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"is_msp","type":"STRING"},{"name":"is_premier_support_enabled","type":"STRING"},{"name":"master_org_id","type":"STRING"},{"name":"master_org_name","type":"STRING"},{"name":"org_id","type":"STRING"},{"name":"org_name","type":"STRING"},{"name":"owner_sales_department","type":"STRING"},{"name":"owner_sales_team","type":"STRING"},{"name":"partner_tier","type":"STRING"},{"name":"premier_support_mrr","type":"STRING"},{"name":"region","type":"STRING"},{"name":"sales_engineer","type":"STRING"},{"name":"sales_engineer_email","type":"STRING"},{"name":"sales_segment","type":"STRING"},{"name":"technical_product_health_status","type":"STRING"},{"name":"type","type":"STRING"},{"name":"row_created_at","type":"STRING"},{"name":"row_updated_at","type":"STRING"}]},"source":"SNOWFLAKE","status":"DONE_WITH_ERRORS","table_name":"test_product_analytics_write_dest_saas","tags":["product_analytics_beta_enabled:true"],"updated_at":"2025-11-19T19:46:12Z"}},{"id":"f704bb0a-9eaf-4734-bd22-1caaca09d6ca","type":"reference_table","attributes":{"created_by":"972dde90-34e1-11eb-958e-f7f08ce02c26","description":"","file_metadata":{"error_row_count":172,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"727006795293","aws_bucket_name":"dd-logs-threat-intel-staging","file_path":"threat_intel_ip_abuse_ch_threatfox.csv"}}},"last_updated_by":"","row_count":1706,"schema":{"primary_keys":["ip_address"],"fields":[{"name":"ip_address","type":"STRING"},{"name":"intention","type":"STRING"},{"name":"category","type":"STRING"},{"name":"source","type":"STRING"},{"name":"additional_data","type":"STRING"}]},"source":"S3","status":"DONE_WITH_ERRORS","table_name":"threat_intel_ip_abuse_ch_threatfox","tags":null,"updated_at":"2025-11-19T19:45:55Z"}},{"id":"34c341b1-a97a-4893-b821-475f8bbf0561","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":1,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_crud_flow_7730722353299252260","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"cbc703e8-45a7-428d-9a85-079c9b4abcbf","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":2,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_v2_row_crud_flow_3796209879804171102","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"1fd37f6a-75a6-44b7-bb9a-2f8558fd2d6b","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":1,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_row_crud_flow_151529577687372015","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"ae91c101-a2e2-41d2-b99f-0cb5ff87e72a","type":"reference_table","attributes":{"created_by":"","description":"This is NOT an actual Snowflake table - it''s a test table updated by this synthetics: https://ddstaging.datadoghq.com/synthetics/details/ajx-zbt-khs?from_ts=1741296820320\u0026to_ts=1741300420320\u0026live=true.","file_metadata":{"error_row_count":1,"error_message":"","access_details":{}},"last_updated_by":"","row_count":1,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"name","type":"STRING"}]},"source":"SNOWFLAKE","status":"DONE_WITH_ERRORS","table_name":"synthetics_grpc_saas2","tags":null,"updated_at":"2025-11-19T19:43:35Z"}},{"id":"481ded06-c51f-48a3-97a6-aab88fd27b53","type":"reference_table","attributes":{"created_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","description":"","last_updated_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","row_count":29,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"name","type":"STRING"}]},"source":"API","status":"DONE","table_name":"test_sync_nov_18","tags":null,"updated_at":"2025-11-19T19:38:08Z"}},{"id":"4acf614f-6ee4-404b-8c36-4f0c1f9df648","type":"reference_table","attributes":{"created_by":"","description":"","last_updated_by":"","row_count":2,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"createdat","type":"STRING"},{"name":"updatedat","type":"STRING"},{"name":"archived","type":"STRING"},{"name":"url","type":"STRING"},{"name":"address","type":"STRING"},{"name":"address2","type":"STRING"},{"name":"annualrevenue","type":"STRING"},{"name":"city","type":"STRING"},{"name":"country","type":"STRING"},{"name":"days_to_close","type":"STRING"},{"name":"description","type":"STRING"},{"name":"domain","type":"STRING"},{"name":"founded_year","type":"STRING"},{"name":"hs_analytics_first_timestamp","type":"STRING"},{"name":"hs_industry_group","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"lifecyclestage","type":"STRING"},{"name":"name","type":"STRING"},{"name":"numberofemployees","type":"STRING"},{"name":"owneremail","type":"STRING"},{"name":"ownername","type":"STRING"},{"name":"state","type":"STRING"},{"name":"total_revenue","type":"STRING"},{"name":"website","type":"STRING"},{"name":"zip","type":"STRING"}]},"source":"HUBSPOT_CONTENT_HUB","status":"DONE","table_name":"hubspot_companies_212c3bff_146e_4812_982f_2340e6efad58","tags":null,"updated_at":"2025-11-19T19:36:17Z"}}],"meta":{"page":{"type":"offset_limit","offset":0,"limit":15,"total":null,"first_offset":0,"prev_offset":null,"next_offset":15,"last_offset":null}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 256.268666ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/5b7451b5-f91a-4547-8e06-7da0664fecff + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 790 + uncompressed: false + body: '{"data":{"id":"5b7451b5-f91a-4547-8e06-7da0664fecff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetable_import_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 39.129291ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/5b7451b5-f91a-4547-8e06-7da0664fecff + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 790 + uncompressed: false + body: '{"data":{"id":"5b7451b5-f91a-4547-8e06-7da0664fecff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetable_import_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 55.410834ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/5b7451b5-f91a-4547-8e06-7da0664fecff + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 790 + uncompressed: false + body: '{"data":{"id":"5b7451b5-f91a-4547-8e06-7da0664fecff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetable_import_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 44.014917ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - '*/*' + url: https://api.datad0g.com/api/v2/reference-tables/tables/5b7451b5-f91a-4547-8e06-7da0664fecff + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 324.330209ms diff --git a/datadog/tests/cassettes/TestAccReferenceTable_SchemaEvolution.freeze b/datadog/tests/cassettes/TestAccReferenceTable_SchemaEvolution.freeze new file mode 100644 index 0000000000..dcc1d88dd4 --- /dev/null +++ b/datadog/tests/cassettes/TestAccReferenceTable_SchemaEvolution.freeze @@ -0,0 +1 @@ +2025-11-19T14:51:15.198769-05:00 \ No newline at end of file diff --git a/datadog/tests/cassettes/TestAccReferenceTable_SchemaEvolution.yaml b/datadog/tests/cassettes/TestAccReferenceTable_SchemaEvolution.yaml new file mode 100644 index 0000000000..cc0cf44192 --- /dev/null +++ b/datadog/tests/cassettes/TestAccReferenceTable_SchemaEvolution.yaml @@ -0,0 +1,240 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 500 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: | + {"data":{"attributes":{"description":"Test schema evolution","file_metadata":{"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}},"sync_enabled":true},"schema":{"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"}],"primary_keys":["a"]},"source":"S3","table_name":"tf_test_evolution_tf_testaccreferencetable_schemaevolution_local_1763581875","tags":["test:terraform"]},"type":"reference_table"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created + code: 201 + duration: 743.912291ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"data":[{"id":"fd02fef8-d92e-4de5-8e8b-f06ae5e845b4","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test schema evolution","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_evolution_tf_testaccreferencetable_schemaevolution_local_1763581875","tags":["test:terraform"],"updated_at":"2025-11-19T19:51:16Z"}},{"id":"d8980e1b-26bc-4ad1-adaa-d972323e1b82","type":"reference_table","attributes":{"created_by":"14f15184-666c-11eb-9595-da7ad0900001","description":"","last_updated_by":"","row_count":0,"schema":{"primary_keys":["org_id"],"fields":[{"name":"org_id","type":"STRING"},{"name":"org_name","type":"STRING"},{"name":"account_health_status","type":"STRING"},{"name":"account_owner_territory","type":"STRING"},{"name":"is_msp","type":"STRING"},{"name":"owner_sales_department","type":"STRING"},{"name":"partner_tier","type":"STRING"},{"name":"region","type":"STRING"},{"name":"technical_product_health_status","type":"STRING"},{"name":"account_owner_role","type":"STRING"},{"name":"account_status_detail","type":"STRING"},{"name":"customer_success_rep","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"churn_risk_likelihood","type":"STRING"},{"name":"employee_count","type":"STRING"},{"name":"master_org_name","type":"STRING"},{"name":"churn_risk_reason","type":"STRING"},{"name":"owner_sales_team","type":"STRING"},{"name":"sales_segment","type":"STRING"},{"name":"row_created_at","type":"STRING"},{"name":"country","type":"STRING"},{"name":"customer_tier","type":"STRING"},{"name":"type","type":"STRING"},{"name":"account_owner","type":"STRING"},{"name":"customer_success_rep_email","type":"STRING"},{"name":"is_premier_support_enabled","type":"STRING"},{"name":"premier_support_mrr","type":"STRING"},{"name":"sales_engineer","type":"STRING"},{"name":"sales_engineer_email","type":"STRING"},{"name":"row_updated_at","type":"STRING"},{"name":"account_family_customer_tier","type":"STRING"},{"name":"account_sales_engineer","type":"STRING"},{"name":"account_status","type":"STRING"},{"name":"master_org_id","type":"STRING"},{"name":"account_family_mrr","type":"STRING"},{"name":"account_owner_email","type":"STRING"},{"name":"churn_reason","type":"STRING"}]},"source":"LOCAL_FILE","status":"PROCESSING","table_name":"can_i_update_this_as_saas","tags":null,"updated_at":"2025-11-19T19:49:51Z"}},{"id":"b9bbff26-2e57-4774-aaf6-e3200ee9407a","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":1,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_bloom_filter_1763581745709","tags":["synthetics"],"updated_at":"2025-11-19T19:49:06Z"}},{"id":"e2979bba-7161-4148-9fc2-88f1bafd0b61","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":1,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_row_crud_flow_1690623620760260067","tags":["synthetics"],"updated_at":"2025-11-19T19:48:22Z"}},{"id":"42b5c9ca-898a-466c-a54a-0481c9ab696f","type":"reference_table","attributes":{"created_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","description":"","last_updated_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","row_count":2,"schema":{"primary_keys":["name"],"fields":[{"name":"name","type":"STRING"},{"name":"url","type":"STRING"}]},"source":"SERVICENOW","status":"DONE","table_name":"http_bulk_client_e2e","tags":null,"updated_at":"2025-11-19T19:47:18Z"}},{"id":"f8ff12c9-4bdd-49e1-8956-4895cfcddbc3","type":"reference_table","attributes":{"created_by":"","description":"","file_metadata":{"error_row_count":342,"error_message":"","access_details":{}},"last_updated_by":"","row_count":4244780,"schema":{"primary_keys":["org_id"],"fields":[{"name":"account_family_customer_tier","type":"STRING"},{"name":"account_family_mrr","type":"STRING"},{"name":"account_health_status","type":"STRING"},{"name":"account_owner","type":"STRING"},{"name":"account_owner_email","type":"STRING"},{"name":"account_owner_role","type":"STRING"},{"name":"account_owner_territory","type":"STRING"},{"name":"account_sales_engineer","type":"STRING"},{"name":"account_status","type":"STRING"},{"name":"account_status_detail","type":"STRING"},{"name":"churn_reason","type":"STRING"},{"name":"churn_risk_likelihood","type":"STRING"},{"name":"churn_risk_reason","type":"STRING"},{"name":"country","type":"STRING"},{"name":"customer_success_rep","type":"STRING"},{"name":"customer_success_rep_email","type":"STRING"},{"name":"customer_tier","type":"STRING"},{"name":"employee_count","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"is_msp","type":"STRING"},{"name":"is_premier_support_enabled","type":"STRING"},{"name":"master_org_id","type":"STRING"},{"name":"master_org_name","type":"STRING"},{"name":"org_id","type":"STRING"},{"name":"org_name","type":"STRING"},{"name":"owner_sales_department","type":"STRING"},{"name":"owner_sales_team","type":"STRING"},{"name":"partner_tier","type":"STRING"},{"name":"premier_support_mrr","type":"STRING"},{"name":"region","type":"STRING"},{"name":"sales_engineer","type":"STRING"},{"name":"sales_engineer_email","type":"STRING"},{"name":"sales_segment","type":"STRING"},{"name":"technical_product_health_status","type":"STRING"},{"name":"type","type":"STRING"},{"name":"row_created_at","type":"STRING"},{"name":"row_updated_at","type":"STRING"}]},"source":"SNOWFLAKE","status":"DONE_WITH_ERRORS","table_name":"test_product_analytics_write_dest_saas","tags":["product_analytics_beta_enabled:true"],"updated_at":"2025-11-19T19:46:12Z"}},{"id":"f704bb0a-9eaf-4734-bd22-1caaca09d6ca","type":"reference_table","attributes":{"created_by":"972dde90-34e1-11eb-958e-f7f08ce02c26","description":"","file_metadata":{"error_row_count":172,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"727006795293","aws_bucket_name":"dd-logs-threat-intel-staging","file_path":"threat_intel_ip_abuse_ch_threatfox.csv"}}},"last_updated_by":"","row_count":1706,"schema":{"primary_keys":["ip_address"],"fields":[{"name":"ip_address","type":"STRING"},{"name":"intention","type":"STRING"},{"name":"category","type":"STRING"},{"name":"source","type":"STRING"},{"name":"additional_data","type":"STRING"}]},"source":"S3","status":"DONE_WITH_ERRORS","table_name":"threat_intel_ip_abuse_ch_threatfox","tags":null,"updated_at":"2025-11-19T19:45:55Z"}},{"id":"cbc703e8-45a7-428d-9a85-079c9b4abcbf","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":0,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_v2_row_crud_flow_3796209879804171102","tags":["synthetics"],"updated_at":"2025-11-19T19:48:49Z"}},{"id":"ae91c101-a2e2-41d2-b99f-0cb5ff87e72a","type":"reference_table","attributes":{"created_by":"","description":"This is NOT an actual Snowflake table - it''s a test table updated by this synthetics: https://ddstaging.datadoghq.com/synthetics/details/ajx-zbt-khs?from_ts=1741296820320\u0026to_ts=1741300420320\u0026live=true.","file_metadata":{"error_row_count":1,"error_message":"","access_details":{}},"last_updated_by":"","row_count":1,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"name","type":"STRING"}]},"source":"SNOWFLAKE","status":"DONE_WITH_ERRORS","table_name":"synthetics_grpc_saas2","tags":null,"updated_at":"2025-11-19T19:43:35Z"}},{"id":"481ded06-c51f-48a3-97a6-aab88fd27b53","type":"reference_table","attributes":{"created_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","description":"","last_updated_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","row_count":29,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"name","type":"STRING"}]},"source":"API","status":"DONE","table_name":"test_sync_nov_18","tags":null,"updated_at":"2025-11-19T19:38:08Z"}},{"id":"4acf614f-6ee4-404b-8c36-4f0c1f9df648","type":"reference_table","attributes":{"created_by":"","description":"","last_updated_by":"","row_count":2,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"createdat","type":"STRING"},{"name":"updatedat","type":"STRING"},{"name":"archived","type":"STRING"},{"name":"url","type":"STRING"},{"name":"address","type":"STRING"},{"name":"address2","type":"STRING"},{"name":"annualrevenue","type":"STRING"},{"name":"city","type":"STRING"},{"name":"country","type":"STRING"},{"name":"days_to_close","type":"STRING"},{"name":"description","type":"STRING"},{"name":"domain","type":"STRING"},{"name":"founded_year","type":"STRING"},{"name":"hs_analytics_first_timestamp","type":"STRING"},{"name":"hs_industry_group","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"lifecyclestage","type":"STRING"},{"name":"name","type":"STRING"},{"name":"numberofemployees","type":"STRING"},{"name":"owneremail","type":"STRING"},{"name":"ownername","type":"STRING"},{"name":"state","type":"STRING"},{"name":"total_revenue","type":"STRING"},{"name":"website","type":"STRING"},{"name":"zip","type":"STRING"}]},"source":"HUBSPOT_CONTENT_HUB","status":"DONE","table_name":"hubspot_companies_212c3bff_146e_4812_982f_2340e6efad58","tags":null,"updated_at":"2025-11-19T19:36:17Z"}},{"id":"57a3244d-057e-41d1-a4aa-c466c8c52d36","type":"reference_table","attributes":{"created_by":"","description":"","last_updated_by":"","row_count":2,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"createdat","type":"STRING"},{"name":"updatedat","type":"STRING"},{"name":"archived","type":"STRING"},{"name":"url","type":"STRING"},{"name":"address","type":"STRING"},{"name":"address2","type":"STRING"},{"name":"annualrevenue","type":"STRING"},{"name":"city","type":"STRING"},{"name":"country","type":"STRING"},{"name":"days_to_close","type":"STRING"},{"name":"description","type":"STRING"},{"name":"domain","type":"STRING"},{"name":"founded_year","type":"STRING"},{"name":"hs_analytics_first_timestamp","type":"STRING"},{"name":"hs_industry_group","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"lifecyclestage","type":"STRING"},{"name":"name","type":"STRING"},{"name":"numberofemployees","type":"STRING"},{"name":"owneremail","type":"STRING"},{"name":"ownername","type":"STRING"},{"name":"state","type":"STRING"},{"name":"total_revenue","type":"STRING"},{"name":"website","type":"STRING"},{"name":"zip","type":"STRING"}]},"source":"HUBSPOT_CONTENT_HUB","status":"DONE","table_name":"hubspot_companies_4f2b6d02_86dd_496b_b921_323b6a381a9a","tags":null,"updated_at":"2025-11-19T19:36:16Z"}},{"id":"5c7b33b1-5bcb-4d7b-bedf-9e977fdcc226","type":"reference_table","attributes":{"created_by":"","description":"","last_updated_by":"","row_count":2,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"createdat","type":"STRING"},{"name":"updatedat","type":"STRING"},{"name":"archived","type":"STRING"},{"name":"url","type":"STRING"},{"name":"address","type":"STRING"},{"name":"address2","type":"STRING"},{"name":"annualrevenue","type":"STRING"},{"name":"city","type":"STRING"},{"name":"country","type":"STRING"},{"name":"days_to_close","type":"STRING"},{"name":"description","type":"STRING"},{"name":"domain","type":"STRING"},{"name":"founded_year","type":"STRING"},{"name":"hs_analytics_first_timestamp","type":"STRING"},{"name":"hs_industry_group","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"lifecyclestage","type":"STRING"},{"name":"name","type":"STRING"},{"name":"numberofemployees","type":"STRING"},{"name":"owneremail","type":"STRING"},{"name":"ownername","type":"STRING"},{"name":"state","type":"STRING"},{"name":"total_revenue","type":"STRING"},{"name":"website","type":"STRING"},{"name":"zip","type":"STRING"}]},"source":"HUBSPOT_CONTENT_HUB","status":"DONE","table_name":"hubspot_companies_f8030e8d_d876_4219_bb72_2c3a114ab6c1","tags":null,"updated_at":"2025-11-19T19:36:15Z"}},{"id":"2bce7224-90dc-452a-8522-aa8fb9741db9","type":"reference_table","attributes":{"created_by":"","description":"","last_updated_by":"","row_count":2,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"createdat","type":"STRING"},{"name":"updatedat","type":"STRING"},{"name":"archived","type":"STRING"},{"name":"url","type":"STRING"},{"name":"address","type":"STRING"},{"name":"address2","type":"STRING"},{"name":"annualrevenue","type":"STRING"},{"name":"city","type":"STRING"},{"name":"country","type":"STRING"},{"name":"days_to_close","type":"STRING"},{"name":"description","type":"STRING"},{"name":"domain","type":"STRING"},{"name":"founded_year","type":"STRING"},{"name":"hs_analytics_first_timestamp","type":"STRING"},{"name":"hs_industry_group","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"lifecyclestage","type":"STRING"},{"name":"name","type":"STRING"},{"name":"numberofemployees","type":"STRING"},{"name":"owneremail","type":"STRING"},{"name":"ownername","type":"STRING"},{"name":"state","type":"STRING"},{"name":"total_revenue","type":"STRING"},{"name":"website","type":"STRING"},{"name":"zip","type":"STRING"}]},"source":"HUBSPOT_CONTENT_HUB","status":"DONE","table_name":"hubspot_companies_dae61af2_a7c1_44be_be2f_a2502318624e","tags":null,"updated_at":"2025-11-19T19:36:13Z"}},{"id":"5b15c2b9-047c-43f0-8206-b6db3a90d64f","type":"reference_table","attributes":{"created_by":"","description":"","last_updated_by":"","row_count":2,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"createdat","type":"STRING"},{"name":"updatedat","type":"STRING"},{"name":"archived","type":"STRING"},{"name":"url","type":"STRING"},{"name":"address","type":"STRING"},{"name":"address2","type":"STRING"},{"name":"annualrevenue","type":"STRING"},{"name":"city","type":"STRING"},{"name":"country","type":"STRING"},{"name":"days_to_close","type":"STRING"},{"name":"description","type":"STRING"},{"name":"domain","type":"STRING"},{"name":"founded_year","type":"STRING"},{"name":"hs_analytics_first_timestamp","type":"STRING"},{"name":"hs_industry_group","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"lifecyclestage","type":"STRING"},{"name":"name","type":"STRING"},{"name":"numberofemployees","type":"STRING"},{"name":"owneremail","type":"STRING"},{"name":"ownername","type":"STRING"},{"name":"state","type":"STRING"},{"name":"total_revenue","type":"STRING"},{"name":"website","type":"STRING"},{"name":"zip","type":"STRING"}]},"source":"HUBSPOT_CONTENT_HUB","status":"DONE","table_name":"hubspot_companies_ec6c2912_e0a4_4c9e_bea8_3836986c83de","tags":null,"updated_at":"2025-11-19T19:36:12Z"}}],"meta":{"page":{"type":"offset_limit","offset":0,"limit":15,"total":null,"first_offset":0,"prev_offset":null,"next_offset":15,"last_offset":null}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 232.442708ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/fd02fef8-d92e-4de5-8e8b-f06ae5e845b4 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 764 + uncompressed: false + body: '{"data":{"id":"fd02fef8-d92e-4de5-8e8b-f06ae5e845b4","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test schema evolution","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_evolution_tf_testaccreferencetable_schemaevolution_local_1763581875","tags":["test:terraform"],"updated_at":"2025-11-19T19:51:16Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 44.628917ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/fd02fef8-d92e-4de5-8e8b-f06ae5e845b4 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 764 + uncompressed: false + body: '{"data":{"id":"fd02fef8-d92e-4de5-8e8b-f06ae5e845b4","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test schema evolution","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_evolution_tf_testaccreferencetable_schemaevolution_local_1763581875","tags":["test:terraform"],"updated_at":"2025-11-19T19:51:16Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 38.725584ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/fd02fef8-d92e-4de5-8e8b-f06ae5e845b4 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 764 + uncompressed: false + body: '{"data":{"id":"fd02fef8-d92e-4de5-8e8b-f06ae5e845b4","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test schema evolution","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_evolution_tf_testaccreferencetable_schemaevolution_local_1763581875","tags":["test:terraform"],"updated_at":"2025-11-19T19:51:16Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 38.204417ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 424 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: | + {"data":{"attributes":{"description":"Test schema evolution","file_metadata":{"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}},"sync_enabled":true},"schema":{"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}],"primary_keys":["a"]},"tags":["test:terraform"]},"type":"reference_table"}} + form: {} + headers: + Accept: + - '*/*' + Content-Type: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/fd02fef8-d92e-4de5-8e8b-f06ae5e845b4 + method: PATCH + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 143 + uncompressed: false + body: '{"errors":[{"title":"Generic Error","detail":"schema updates require either upload_id (for local files) or access_details (for cloud files)"}]}' + headers: + Content-Type: + - application/vnd.api+json + status: 400 Bad Request + code: 400 + duration: 36.62625ms + - id: 6 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - '*/*' + url: https://api.datad0g.com/api/v2/reference-tables/tables/fd02fef8-d92e-4de5-8e8b-f06ae5e845b4 + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 349.274125ms diff --git a/datadog/tests/cassettes/TestAccReferenceTable_UpdateSyncEnabled.freeze b/datadog/tests/cassettes/TestAccReferenceTable_UpdateSyncEnabled.freeze new file mode 100644 index 0000000000..11da54375d --- /dev/null +++ b/datadog/tests/cassettes/TestAccReferenceTable_UpdateSyncEnabled.freeze @@ -0,0 +1 @@ +2025-11-19T14:48:10.362694-05:00 \ No newline at end of file diff --git a/datadog/tests/cassettes/TestAccReferenceTable_UpdateSyncEnabled.yaml b/datadog/tests/cassettes/TestAccReferenceTable_UpdateSyncEnabled.yaml new file mode 100644 index 0000000000..4d7f19e585 --- /dev/null +++ b/datadog/tests/cassettes/TestAccReferenceTable_UpdateSyncEnabled.yaml @@ -0,0 +1,273 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 529 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: | + {"data":{"attributes":{"description":"Test sync_enabled update","file_metadata":{"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}},"sync_enabled":true},"schema":{"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}],"primary_keys":["a"]},"source":"S3","table_name":"tf_test_sync_tf_testaccreferencetable_updatesyncenabled_local_1763581690","tags":["test:terraform"]},"type":"reference_table"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created + code: 201 + duration: 803.398083ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"data":[{"id":"e7d84519-47cb-4d39-ac2b-c51a64f0f8ff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_tf_testaccdatadogreferencetabledatasource_local_1763581690","tags":["test:datasource"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"72dc199d-6401-4527-b2e5-4cafaca6927c","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test schema evolution","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_evolution_tf_testaccreferencetable_schemaevolution_local_1763581690","tags":["test:terraform"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"8c4be62b-1b6c-4578-89b8-79c5f04b02b6","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test sync_enabled update","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_sync_tf_testaccreferencetable_updatesyncenabled_local_1763581690","tags":["test:terraform"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"134ee13a-0917-40d1-b0c8-6123f05ac568","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetables3_basic_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"e15180ff-b17b-423a-b8cf-4c6fc3f78928","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test data source for rows","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_ds_rows_tf_testaccdatadogreferencetablerowsdatasource_local_1763581690","tags":["test:datasource-rows"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"5b7451b5-f91a-4547-8e06-7da0664fecff","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test S3 reference table","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_s3_tf_testaccreferencetable_import_local_1763581690","tags":["test:terraform","env:test"],"updated_at":"2025-11-19T19:48:13Z"}},{"id":"42b5c9ca-898a-466c-a54a-0481c9ab696f","type":"reference_table","attributes":{"created_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","description":"","last_updated_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","row_count":2,"schema":{"primary_keys":["name"],"fields":[{"name":"name","type":"STRING"},{"name":"url","type":"STRING"}]},"source":"SERVICENOW","status":"DONE","table_name":"http_bulk_client_e2e","tags":null,"updated_at":"2025-11-19T19:47:18Z"}},{"id":"f8ff12c9-4bdd-49e1-8956-4895cfcddbc3","type":"reference_table","attributes":{"created_by":"","description":"","file_metadata":{"error_row_count":342,"error_message":"","access_details":{}},"last_updated_by":"","row_count":4244780,"schema":{"primary_keys":["org_id"],"fields":[{"name":"account_family_customer_tier","type":"STRING"},{"name":"account_family_mrr","type":"STRING"},{"name":"account_health_status","type":"STRING"},{"name":"account_owner","type":"STRING"},{"name":"account_owner_email","type":"STRING"},{"name":"account_owner_role","type":"STRING"},{"name":"account_owner_territory","type":"STRING"},{"name":"account_sales_engineer","type":"STRING"},{"name":"account_status","type":"STRING"},{"name":"account_status_detail","type":"STRING"},{"name":"churn_reason","type":"STRING"},{"name":"churn_risk_likelihood","type":"STRING"},{"name":"churn_risk_reason","type":"STRING"},{"name":"country","type":"STRING"},{"name":"customer_success_rep","type":"STRING"},{"name":"customer_success_rep_email","type":"STRING"},{"name":"customer_tier","type":"STRING"},{"name":"employee_count","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"is_msp","type":"STRING"},{"name":"is_premier_support_enabled","type":"STRING"},{"name":"master_org_id","type":"STRING"},{"name":"master_org_name","type":"STRING"},{"name":"org_id","type":"STRING"},{"name":"org_name","type":"STRING"},{"name":"owner_sales_department","type":"STRING"},{"name":"owner_sales_team","type":"STRING"},{"name":"partner_tier","type":"STRING"},{"name":"premier_support_mrr","type":"STRING"},{"name":"region","type":"STRING"},{"name":"sales_engineer","type":"STRING"},{"name":"sales_engineer_email","type":"STRING"},{"name":"sales_segment","type":"STRING"},{"name":"technical_product_health_status","type":"STRING"},{"name":"type","type":"STRING"},{"name":"row_created_at","type":"STRING"},{"name":"row_updated_at","type":"STRING"}]},"source":"SNOWFLAKE","status":"DONE_WITH_ERRORS","table_name":"test_product_analytics_write_dest_saas","tags":["product_analytics_beta_enabled:true"],"updated_at":"2025-11-19T19:46:12Z"}},{"id":"f704bb0a-9eaf-4734-bd22-1caaca09d6ca","type":"reference_table","attributes":{"created_by":"972dde90-34e1-11eb-958e-f7f08ce02c26","description":"","file_metadata":{"error_row_count":172,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"727006795293","aws_bucket_name":"dd-logs-threat-intel-staging","file_path":"threat_intel_ip_abuse_ch_threatfox.csv"}}},"last_updated_by":"","row_count":1706,"schema":{"primary_keys":["ip_address"],"fields":[{"name":"ip_address","type":"STRING"},{"name":"intention","type":"STRING"},{"name":"category","type":"STRING"},{"name":"source","type":"STRING"},{"name":"additional_data","type":"STRING"}]},"source":"S3","status":"DONE_WITH_ERRORS","table_name":"threat_intel_ip_abuse_ch_threatfox","tags":null,"updated_at":"2025-11-19T19:45:55Z"}},{"id":"34c341b1-a97a-4893-b821-475f8bbf0561","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":1,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_crud_flow_7730722353299252260","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"cbc703e8-45a7-428d-9a85-079c9b4abcbf","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":2,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_v2_row_crud_flow_3796209879804171102","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"1fd37f6a-75a6-44b7-bb9a-2f8558fd2d6b","type":"reference_table","attributes":{"created_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","description":"","last_updated_by":"d8673343-30d4-11f0-b7c9-22644aa72e77","row_count":1,"schema":{"primary_keys":["int32_col"],"fields":[{"name":"int32_col","type":"INT32"},{"name":"str_col","type":"STRING"}]},"source":"LOCAL_FILE","status":"DONE","table_name":"synthetics_test_rt_file_row_crud_flow_151529577687372015","tags":["synthetics"],"updated_at":"2025-11-19T19:45:48Z"}},{"id":"ae91c101-a2e2-41d2-b99f-0cb5ff87e72a","type":"reference_table","attributes":{"created_by":"","description":"This is NOT an actual Snowflake table - it''s a test table updated by this synthetics: https://ddstaging.datadoghq.com/synthetics/details/ajx-zbt-khs?from_ts=1741296820320\u0026to_ts=1741300420320\u0026live=true.","file_metadata":{"error_row_count":1,"error_message":"","access_details":{}},"last_updated_by":"","row_count":1,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"name","type":"STRING"}]},"source":"SNOWFLAKE","status":"DONE_WITH_ERRORS","table_name":"synthetics_grpc_saas2","tags":null,"updated_at":"2025-11-19T19:43:35Z"}},{"id":"481ded06-c51f-48a3-97a6-aab88fd27b53","type":"reference_table","attributes":{"created_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","description":"","last_updated_by":"4ae61496-f55f-11eb-abf7-da7ad0900001","row_count":29,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"name","type":"STRING"}]},"source":"API","status":"DONE","table_name":"test_sync_nov_18","tags":null,"updated_at":"2025-11-19T19:38:08Z"}},{"id":"4acf614f-6ee4-404b-8c36-4f0c1f9df648","type":"reference_table","attributes":{"created_by":"","description":"","last_updated_by":"","row_count":2,"schema":{"primary_keys":["id"],"fields":[{"name":"id","type":"STRING"},{"name":"createdat","type":"STRING"},{"name":"updatedat","type":"STRING"},{"name":"archived","type":"STRING"},{"name":"url","type":"STRING"},{"name":"address","type":"STRING"},{"name":"address2","type":"STRING"},{"name":"annualrevenue","type":"STRING"},{"name":"city","type":"STRING"},{"name":"country","type":"STRING"},{"name":"days_to_close","type":"STRING"},{"name":"description","type":"STRING"},{"name":"domain","type":"STRING"},{"name":"founded_year","type":"STRING"},{"name":"hs_analytics_first_timestamp","type":"STRING"},{"name":"hs_industry_group","type":"STRING"},{"name":"industry","type":"STRING"},{"name":"lifecyclestage","type":"STRING"},{"name":"name","type":"STRING"},{"name":"numberofemployees","type":"STRING"},{"name":"owneremail","type":"STRING"},{"name":"ownername","type":"STRING"},{"name":"state","type":"STRING"},{"name":"total_revenue","type":"STRING"},{"name":"website","type":"STRING"},{"name":"zip","type":"STRING"}]},"source":"HUBSPOT_CONTENT_HUB","status":"DONE","table_name":"hubspot_companies_212c3bff_146e_4812_982f_2340e6efad58","tags":null,"updated_at":"2025-11-19T19:36:17Z"}}],"meta":{"page":{"type":"offset_limit","offset":0,"limit":15,"total":null,"first_offset":0,"prev_offset":null,"next_offset":15,"last_offset":null}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 284.872875ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/8c4be62b-1b6c-4578-89b8-79c5f04b02b6 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 793 + uncompressed: false + body: '{"data":{"id":"8c4be62b-1b6c-4578-89b8-79c5f04b02b6","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test sync_enabled update","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_sync_tf_testaccreferencetable_updatesyncenabled_local_1763581690","tags":["test:terraform"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 46.592084ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/8c4be62b-1b6c-4578-89b8-79c5f04b02b6 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 793 + uncompressed: false + body: '{"data":{"id":"8c4be62b-1b6c-4578-89b8-79c5f04b02b6","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test sync_enabled update","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_sync_tf_testaccreferencetable_updatesyncenabled_local_1763581690","tags":["test:terraform"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 49.127209ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/8c4be62b-1b6c-4578-89b8-79c5f04b02b6 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 793 + uncompressed: false + body: '{"data":{"id":"8c4be62b-1b6c-4578-89b8-79c5f04b02b6","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test sync_enabled update","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_sync_tf_testaccreferencetable_updatesyncenabled_local_1763581690","tags":["test:terraform"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 54.072917ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 428 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: | + {"data":{"attributes":{"description":"Test sync_enabled update","file_metadata":{"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}},"sync_enabled":false},"schema":{"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}],"primary_keys":["a"]},"tags":["test:terraform"]},"type":"reference_table"}} + form: {} + headers: + Accept: + - '*/*' + Content-Type: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/8c4be62b-1b6c-4578-89b8-79c5f04b02b6 + method: PATCH + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 53.716292ms + - id: 6 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datad0g.com/api/v2/reference-tables/tables/8c4be62b-1b6c-4578-89b8-79c5f04b02b6 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 793 + uncompressed: false + body: '{"data":{"id":"8c4be62b-1b6c-4578-89b8-79c5f04b02b6","type":"reference_table","attributes":{"created_by":"51bca672-7464-11ea-ad29-6762102f9f58","description":"Test sync_enabled update","file_metadata":{"error_row_count":0,"error_message":"","sync_enabled":true,"access_details":{"aws_detail":{"aws_account_id":"924305315327","aws_bucket_name":"dd-reference-tables-dev-staging","file_path":"test.csv"}}},"last_updated_by":"51bca672-7464-11ea-ad29-6762102f9f58","row_count":0,"schema":{"primary_keys":["a"],"fields":[{"name":"a","type":"STRING"},{"name":"b","type":"STRING"},{"name":"c","type":"STRING"}]},"source":"S3","status":"INITIALIZED","table_name":"tf_test_sync_tf_testaccreferencetable_updatesyncenabled_local_1763581690","tags":["test:terraform"],"updated_at":"2025-11-19T19:48:13Z"}}}' + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 45.421125ms + - id: 7 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datad0g.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - '*/*' + url: https://api.datad0g.com/api/v2/reference-tables/tables/8c4be62b-1b6c-4578-89b8-79c5f04b02b6 + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK + code: 200 + duration: 322.043166ms diff --git a/datadog/tests/data_source_datadog_reference_table_rows_test.go b/datadog/tests/data_source_datadog_reference_table_rows_test.go new file mode 100644 index 0000000000..9ffe5802f2 --- /dev/null +++ b/datadog/tests/data_source_datadog_reference_table_rows_test.go @@ -0,0 +1,153 @@ +package test + +import ( + "context" + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccDatadogReferenceTableRowsDataSource(t *testing.T) { + t.Parallel() + ctx, _, accProviders := testAccFrameworkMuxProviders(context.Background(), t) + uniq := uniqueEntityName(ctx, t) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: accProviders, + Steps: []resource.TestStep{ + { + // Step 1: Create the table (rows will sync asynchronously) + Config: testAccDataSourceDatadogReferenceTableRowsConfigStep1(uniq), + Check: resource.ComposeTestCheckFunc( + // Verify the table was created + resource.TestCheckResourceAttrSet( + "datadog_reference_table.test", "id"), + // Note: We don't check row_count here because sync is asynchronous + // Step 2 will wait for rows to be available + ), + }, + { + // Step 2: Query rows from the existing synced table + Config: testAccDataSourceDatadogReferenceTableRowsConfigStep2(uniq), + Check: resource.ComposeTestCheckFunc( + // Verify the data source configuration + resource.TestCheckResourceAttrSet( + "data.datadog_reference_table_rows.test", "table_id"), + resource.TestCheckResourceAttr( + "data.datadog_reference_table_rows.test", "row_ids.#", "2"), + // Verify rows were retrieved + resource.TestCheckResourceAttr( + "data.datadog_reference_table_rows.test", "rows.#", "2"), + resource.TestCheckResourceAttrSet( + "data.datadog_reference_table_rows.test", "rows.0.id"), + resource.TestCheckResourceAttrSet( + "data.datadog_reference_table_rows.test", "rows.0.values.%"), + resource.TestCheckResourceAttrSet( + "data.datadog_reference_table_rows.test", "rows.1.id"), + resource.TestCheckResourceAttrSet( + "data.datadog_reference_table_rows.test", "rows.1.values.%"), + ), + }, + }, + }) +} + +func testAccDataSourceDatadogReferenceTableRowsConfigStep1(uniq string) string { + sanitized := strings.ToLower(strings.ReplaceAll(uniq, "-", "_")) + return fmt.Sprintf(` +# Step 1: Create the table and wait for it to sync +resource "datadog_reference_table" "test" { + table_name = "tf_test_ds_rows_%s" + description = "Test data source for rows" + source = "S3" + + file_metadata { + sync_enabled = true + + access_details { + aws_detail { + aws_account_id = "924305315327" + aws_bucket_name = "dd-reference-tables-dev-staging" + file_path = "test.csv" + } + } + } + + schema { + primary_keys = ["a"] + + fields { + name = "a" + type = "STRING" + } + + fields { + name = "b" + type = "STRING" + } + + fields { + name = "c" + type = "STRING" + } + } + + tags = ["test:datasource-rows"] +} +`, sanitized) +} + +func testAccDataSourceDatadogReferenceTableRowsConfigStep2(uniq string) string { + sanitized := strings.ToLower(strings.ReplaceAll(uniq, "-", "_")) + return fmt.Sprintf(` +# Step 1: Create the table and wait for it to sync +resource "datadog_reference_table" "test" { + table_name = "tf_test_ds_rows_%s" + description = "Test data source for rows" + source = "S3" + + file_metadata { + sync_enabled = true + + access_details { + aws_detail { + aws_account_id = "924305315327" + aws_bucket_name = "dd-reference-tables-dev-staging" + file_path = "test.csv" + } + } + } + + schema { + primary_keys = ["a"] + + fields { + name = "a" + type = "STRING" + } + + fields { + name = "b" + type = "STRING" + } + + fields { + name = "c" + type = "STRING" + } + } + + tags = ["test:datasource-rows"] +} + +# Step 2: Query rows from the existing synced table +# test.csv contains rows with primary key values "1" and "2" +data "datadog_reference_table_rows" "test" { + table_id = datadog_reference_table.test.id + row_ids = ["1", "2"] +} +`, sanitized) +} diff --git a/datadog/tests/data_source_datadog_reference_table_test.go b/datadog/tests/data_source_datadog_reference_table_test.go new file mode 100644 index 0000000000..57a243eddc --- /dev/null +++ b/datadog/tests/data_source_datadog_reference_table_test.go @@ -0,0 +1,98 @@ +package test + +import ( + "context" + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccDatadogReferenceTableDataSource(t *testing.T) { + t.Parallel() + ctx, _, accProviders := testAccFrameworkMuxProviders(context.Background(), t) + uniq := uniqueEntityName(ctx, t) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: accProviders, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceDatadogReferenceTableConfig(uniq), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "data.datadog_reference_table.by_id", "table_name", fmt.Sprintf("tf_test_ds_%s", strings.ToLower(strings.ReplaceAll(uniq, "-", "_")))), + resource.TestCheckResourceAttr( + "data.datadog_reference_table.by_id", "source", "S3"), + resource.TestCheckResourceAttr( + "data.datadog_reference_table.by_id", "description", "Test data source"), + resource.TestCheckResourceAttr( + "data.datadog_reference_table.by_id", "file_metadata.sync_enabled", "true"), + resource.TestCheckResourceAttr( + "data.datadog_reference_table.by_id", "schema.primary_keys.0", "a"), + resource.TestCheckResourceAttrSet( + "data.datadog_reference_table.by_id", "id"), + resource.TestCheckResourceAttrSet( + "data.datadog_reference_table.by_id", "created_by"), + // Test querying by table_name + resource.TestCheckResourceAttr( + "data.datadog_reference_table.by_name", "table_name", fmt.Sprintf("tf_test_ds_%s", strings.ToLower(strings.ReplaceAll(uniq, "-", "_")))), + resource.TestCheckResourceAttr( + "data.datadog_reference_table.by_name", "source", "S3"), + ), + }, + }, + }) +} + +func testAccDataSourceDatadogReferenceTableConfig(uniq string) string { + return fmt.Sprintf(` +resource "datadog_reference_table" "test" { + table_name = "tf_test_ds_%s" + description = "Test data source" + source = "S3" + + file_metadata { + sync_enabled = true + + access_details { + aws_detail { + aws_account_id = "924305315327" + aws_bucket_name = "dd-reference-tables-dev-staging" + file_path = "test.csv" + } + } + } + + schema { + primary_keys = ["a"] + + fields { + name = "a" + type = "STRING" + } + + fields { + name = "b" + type = "STRING" + } + + fields { + name = "c" + type = "STRING" + } + } + + tags = ["test:datasource"] +} + +data "datadog_reference_table" "by_id" { + id = datadog_reference_table.test.id +} + +data "datadog_reference_table" "by_name" { + table_name = datadog_reference_table.test.table_name +} +`, strings.ToLower(strings.ReplaceAll(uniq, "-", "_"))) +} diff --git a/datadog/tests/provider_test.go b/datadog/tests/provider_test.go index f94c49a0fe..b753f773cd 100644 --- a/datadog/tests/provider_test.go +++ b/datadog/tests/provider_test.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "crypto/sha256" + "encoding/json" "fmt" "io" "log" @@ -86,6 +87,8 @@ var testFiles2EndpointTags = map[string]string{ "tests/data_source_datadog_monitors_test": "monitors", "tests/data_source_datadog_permissions_test": "permissions", "tests/data_source_datadog_powerpack_test": "powerpacks", + "tests/data_source_datadog_reference_table_test": "reference-tables", + "tests/data_source_datadog_reference_table_rows_test": "reference-tables", "tests/data_source_datadog_restriction_policy_test": "restriction-policy", "tests/data_source_datadog_role_test": "roles", "tests/data_source_datadog_role_users_test": "roles", @@ -248,6 +251,7 @@ var testFiles2EndpointTags = map[string]string{ "tests/resource_datadog_on_call_team_routing_rules_test": "on-call", "tests/resource_datadog_organization_settings_test": "organization", "tests/resource_datadog_org_connection_test": "org_connection", + "tests/resource_datadog_reference_table_test": "reference-tables", "tests/resource_datadog_restriction_policy_test": "restriction-policy", "tests/resource_datadog_role_test": "roles", "tests/resource_datadog_rum_application_test": "rum-application", @@ -380,6 +384,50 @@ func isTestOrg() bool { publicID := ddTestOrg if v := os.Getenv(testOrgEnvName); v != "" { publicID = v + // If DD_TEST_ORG is explicitly set, validate by checking current_user endpoint + // instead of org endpoint (which requires admin permissions) + client := &http.Client{} + req, _ := http.NewRequest("GET", fmt.Sprintf("%s/api/v2/current_user", strings.TrimRight(apiURL, "/")), nil) + req.Header.Add("DD-API-KEY", os.Getenv(testAPIKeyEnvName)) + req.Header.Add("DD-APPLICATION-KEY", os.Getenv(testAPPKeyEnvName)) + resp, err := client.Do(req) + if err != nil || resp.StatusCode != 200 { + r := false + isTestOrgC = &r + return r + } + // Parse response to check if org public_id matches + var result map[string]interface{} + if err := json.NewDecoder(resp.Body).Decode(&result); err == nil { + if data, ok := result["data"].(map[string]interface{}); ok { + if relationships, ok := data["relationships"].(map[string]interface{}); ok { + if org, ok := relationships["org"].(map[string]interface{}); ok { + if _, ok := org["data"].(map[string]interface{}); ok { + // Check included orgs for public_id match + if included, ok := result["included"].([]interface{}); ok { + for _, item := range included { + if itemMap, ok := item.(map[string]interface{}); ok { + if itemType, _ := itemMap["type"].(string); itemType == "orgs" { + if attrs, ok := itemMap["attributes"].(map[string]interface{}); ok { + if publicIDAttr, ok := attrs["public_id"].(string); ok && publicIDAttr == publicID { + r := true + isTestOrgC = &r + return r + } + } + } + } + } + } + } + } + } + } + } + resp.Body.Close() + r := false + isTestOrgC = &r + return r } client := &http.Client{} diff --git a/datadog/tests/resource_datadog_reference_table_test.go b/datadog/tests/resource_datadog_reference_table_test.go new file mode 100644 index 0000000000..e0b21157b8 --- /dev/null +++ b/datadog/tests/resource_datadog_reference_table_test.go @@ -0,0 +1,448 @@ +package test + +import ( + "context" + "fmt" + "strings" + "testing" + "time" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + + "github.com/terraform-providers/terraform-provider-datadog/datadog/fwprovider" + "github.com/terraform-providers/terraform-provider-datadog/datadog/internal/utils" +) + +func TestAccReferenceTableS3_Basic(t *testing.T) { + t.Parallel() + ctx, providers, accProviders := testAccFrameworkMuxProviders(context.Background(), t) + uniq := uniqueEntityName(ctx, t) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: accProviders, + CheckDestroy: testAccCheckDatadogReferenceTableDestroy(providers.frameworkProvider), + Steps: []resource.TestStep{ + { + Config: testAccCheckDatadogReferenceTableS3(uniq), + Check: resource.ComposeTestCheckFunc( + testAccCheckDatadogReferenceTableExists(providers.frameworkProvider), + resource.TestCheckResourceAttr( + "datadog_reference_table.s3_table", "table_name", fmt.Sprintf("tf_test_s3_%s", strings.ToLower(strings.ReplaceAll(uniq, "-", "_")))), + resource.TestCheckResourceAttr( + "datadog_reference_table.s3_table", "source", "S3"), + resource.TestCheckResourceAttr( + "datadog_reference_table.s3_table", "description", "Test S3 reference table"), + resource.TestCheckResourceAttr( + "datadog_reference_table.s3_table", "file_metadata.sync_enabled", "true"), + resource.TestCheckResourceAttr( + "datadog_reference_table.s3_table", "file_metadata.access_details.aws_detail.aws_account_id", "924305315327"), + resource.TestCheckResourceAttr( + "datadog_reference_table.s3_table", "schema.primary_keys.0", "a"), + resource.TestCheckResourceAttr( + "datadog_reference_table.s3_table", "schema.fields.0.name", "a"), + resource.TestCheckResourceAttr( + "datadog_reference_table.s3_table", "schema.fields.0.type", "STRING"), + resource.TestCheckResourceAttrSet( + "datadog_reference_table.s3_table", "id"), + resource.TestCheckResourceAttrSet( + "datadog_reference_table.s3_table", "created_by"), + ), + }, + }, + }) +} + +func TestAccReferenceTable_SchemaEvolution(t *testing.T) { + t.Parallel() + ctx, providers, accProviders := testAccFrameworkMuxProviders(context.Background(), t) + uniq := uniqueEntityName(ctx, t) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: accProviders, + CheckDestroy: testAccCheckDatadogReferenceTableDestroy(providers.frameworkProvider), + Steps: []resource.TestStep{ + { + Config: testAccCheckDatadogReferenceTableSchemaInitial(uniq), + Check: resource.ComposeTestCheckFunc( + testAccCheckDatadogReferenceTableExists(providers.frameworkProvider), + resource.TestCheckResourceAttr( + "datadog_reference_table.evolution", "schema.fields.#", "3"), + resource.TestCheckResourceAttr( + "datadog_reference_table.evolution", "schema.fields.0.name", "a"), + resource.TestCheckResourceAttr( + "datadog_reference_table.evolution", "schema.fields.1.name", "b"), + resource.TestCheckResourceAttr( + "datadog_reference_table.evolution", "schema.fields.2.name", "c"), + ), + }, + { + // Wait step to ensure initial sync is fully complete before schema evolution + // Using the same config should trigger Terraform to refresh state automatically + // The check function waits for DONE status, ensuring the resource is ready + Config: testAccCheckDatadogReferenceTableSchemaInitial(uniq), + Check: resource.ComposeTestCheckFunc( + testAccCheckDatadogReferenceTableExists(providers.frameworkProvider), + testAccCheckDatadogReferenceTableStatusDone(providers.frameworkProvider), + // Verify state attributes match API to ensure state is refreshed + // This helps Terraform understand the current state before Step 3 + resource.TestCheckResourceAttrSet("datadog_reference_table.evolution", "status"), + resource.TestCheckResourceAttrSet("datadog_reference_table.evolution", "row_count"), + ), + }, + { + Config: testAccCheckDatadogReferenceTableSchemaAddFields(uniq), + Check: resource.ComposeTestCheckFunc( + testAccCheckDatadogReferenceTableExists(providers.frameworkProvider), + resource.TestCheckResourceAttr( + "datadog_reference_table.evolution", "schema.fields.#", "4"), + resource.TestCheckResourceAttr( + "datadog_reference_table.evolution", "schema.fields.2.name", "c"), + resource.TestCheckResourceAttr( + "datadog_reference_table.evolution", "schema.fields.3.name", "d"), + ), + }, + }, + }) +} + +func TestAccReferenceTable_UpdateSyncEnabled(t *testing.T) { + t.Parallel() + ctx, providers, accProviders := testAccFrameworkMuxProviders(context.Background(), t) + uniq := uniqueEntityName(ctx, t) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: accProviders, + CheckDestroy: testAccCheckDatadogReferenceTableDestroy(providers.frameworkProvider), + Steps: []resource.TestStep{ + { + Config: testAccCheckDatadogReferenceTableSyncEnabled(uniq, true), + Check: resource.ComposeTestCheckFunc( + testAccCheckDatadogReferenceTableExists(providers.frameworkProvider), + resource.TestCheckResourceAttr( + "datadog_reference_table.sync_test", "file_metadata.sync_enabled", "true"), + ), + }, + { + Config: testAccCheckDatadogReferenceTableSyncEnabled(uniq, false), + Check: resource.ComposeTestCheckFunc( + testAccCheckDatadogReferenceTableExists(providers.frameworkProvider), + resource.TestCheckResourceAttr( + "datadog_reference_table.sync_test", "file_metadata.sync_enabled", "false"), + ), + }, + }, + }) +} + +func TestAccReferenceTable_Import(t *testing.T) { + t.Parallel() + ctx, providers, accProviders := testAccFrameworkMuxProviders(context.Background(), t) + uniq := uniqueEntityName(ctx, t) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: accProviders, + CheckDestroy: testAccCheckDatadogReferenceTableDestroy(providers.frameworkProvider), + Steps: []resource.TestStep{ + { + Config: testAccCheckDatadogReferenceTableS3(uniq), + }, + { + ResourceName: "datadog_reference_table.s3_table", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccCheckDatadogReferenceTableS3(uniq string) string { + // Sanitize: replace dashes with underscores and convert to lowercase + sanitized := strings.ToLower(strings.ReplaceAll(uniq, "-", "_")) + return fmt.Sprintf(` +resource "datadog_reference_table" "s3_table" { + table_name = "tf_test_s3_%s" + description = "Test S3 reference table" + source = "S3" + + file_metadata { + sync_enabled = true + + access_details { + aws_detail { + aws_account_id = "924305315327" + aws_bucket_name = "dd-reference-tables-dev-staging" + file_path = "test.csv" + } + } + } + + schema { + primary_keys = ["a"] + + fields { + name = "a" + type = "STRING" + } + + fields { + name = "b" + type = "STRING" + } + + fields { + name = "c" + type = "STRING" + } + } + + tags = ["test:terraform", "env:test"] +}`, sanitized) +} + +func testAccCheckDatadogReferenceTableSchemaInitial(uniq string) string { + // Sanitize: replace dashes with underscores and convert to lowercase + sanitized := strings.ToLower(strings.ReplaceAll(uniq, "-", "_")) + return fmt.Sprintf(` +resource "datadog_reference_table" "evolution" { + table_name = "tf_test_evolution_%s" + description = "Test schema evolution" + source = "S3" + + file_metadata { + sync_enabled = true + + access_details { + aws_detail { + aws_account_id = "924305315327" + aws_bucket_name = "dd-reference-tables-dev-staging" + file_path = "test.csv" + } + } + } + + schema { + primary_keys = ["a"] + + fields { + name = "a" + type = "STRING" + } + + fields { + name = "b" + type = "STRING" + } + + fields { + name = "c" + type = "STRING" + } + } + + tags = ["test:terraform"] +}`, sanitized) +} + +func testAccCheckDatadogReferenceTableSchemaAddFields(uniq string) string { + // Sanitize: replace dashes with underscores and convert to lowercase + sanitized := strings.ToLower(strings.ReplaceAll(uniq, "-", "_")) + return fmt.Sprintf(` +resource "datadog_reference_table" "evolution" { + table_name = "tf_test_evolution_%s" + description = "Test schema evolution" + source = "S3" + + file_metadata { + sync_enabled = true + + access_details { + aws_detail { + aws_account_id = "924305315327" + aws_bucket_name = "dd-reference-tables-dev-staging" + file_path = "test2.csv" + } + } + } + + schema { + primary_keys = ["a"] + + fields { + name = "a" + type = "STRING" + } + + fields { + name = "b" + type = "STRING" + } + + fields { + name = "c" + type = "STRING" + } + + # New field added (additive change) + fields { + name = "d" + type = "STRING" + } + } + + tags = ["test:terraform"] +}`, sanitized) +} + +func testAccCheckDatadogReferenceTableSyncEnabled(uniq string, syncEnabled bool) string { + // Sanitize: replace dashes with underscores and convert to lowercase + sanitized := strings.ToLower(strings.ReplaceAll(uniq, "-", "_")) + return fmt.Sprintf(` +resource "datadog_reference_table" "sync_test" { + table_name = "tf_test_sync_%s" + description = "Test sync_enabled update" + source = "S3" + + file_metadata { + sync_enabled = %t + + access_details { + aws_detail { + aws_account_id = "924305315327" + aws_bucket_name = "dd-reference-tables-dev-staging" + file_path = "test.csv" + } + } + } + + schema { + primary_keys = ["a"] + + fields { + name = "a" + type = "STRING" + } + + fields { + name = "b" + type = "STRING" + } + + fields { + name = "c" + type = "STRING" + } + } + + tags = ["test:terraform"] +}`, sanitized, syncEnabled) +} + +func testAccCheckDatadogReferenceTableDestroy(accProvider *fwprovider.FrameworkProvider) func(*terraform.State) error { + return func(s *terraform.State) error { + apiInstances := accProvider.DatadogApiInstances + auth := accProvider.Auth + + if err := ReferenceTableDestroyHelper(auth, s, apiInstances); err != nil { + return err + } + return nil + } +} + +func ReferenceTableDestroyHelper(auth context.Context, s *terraform.State, apiInstances *utils.ApiInstances) error { + err := utils.Retry(2, 10, func() error { + for _, r := range s.RootModule().Resources { + if r.Type != "resource_datadog_reference_table" { + continue + } + id := r.Primary.ID + + _, httpResp, err := apiInstances.GetReferenceTablesApiV2().GetTable(auth, id) + if err != nil { + if httpResp != nil && httpResp.StatusCode == 404 { + return nil + } + return &utils.RetryableError{Prob: fmt.Sprintf("received an error retrieving ReferenceTable %s", err)} + } + return &utils.RetryableError{Prob: "ReferenceTable still exists"} + } + return nil + }) + return err +} + +func testAccCheckDatadogReferenceTableExists(accProvider *fwprovider.FrameworkProvider) resource.TestCheckFunc { + return func(s *terraform.State) error { + apiInstances := accProvider.DatadogApiInstances + auth := accProvider.Auth + + if err := referenceTableExistsHelper(auth, s, apiInstances); err != nil { + return err + } + return nil + } +} + +func referenceTableExistsHelper(auth context.Context, s *terraform.State, apiInstances *utils.ApiInstances) error { + for _, r := range s.RootModule().Resources { + if r.Type != "resource_datadog_reference_table" { + continue + } + id := r.Primary.ID + + _, httpResp, err := apiInstances.GetReferenceTablesApiV2().GetTable(auth, id) + if err != nil { + return utils.TranslateClientError(err, httpResp, "error retrieving ReferenceTable") + } + } + return nil +} + +func testAccCheckDatadogReferenceTableStatusDone(accProvider *fwprovider.FrameworkProvider) resource.TestCheckFunc { + return func(s *terraform.State) error { + apiInstances := accProvider.DatadogApiInstances + auth := accProvider.Auth + + for _, r := range s.RootModule().Resources { + if r.Type != "resource_datadog_reference_table" { + continue + } + id := r.Primary.ID + + // Wait for table status to be DONE (or ERROR) before proceeding + maxRetries := 20 + retryInterval := 3 * time.Second + for i := 0; i < maxRetries; i++ { + resp, httpResp, err := apiInstances.GetReferenceTablesApiV2().GetTable(auth, id) + if err != nil { + return utils.TranslateClientError(err, httpResp, "error retrieving ReferenceTable") + } + + if resp.Data != nil { + attrs := resp.Data.GetAttributes() + if status, ok := attrs.GetStatusOk(); ok && status != nil { + statusStr := string(*status) + if statusStr == "DONE" || statusStr == "ERROR" { + return nil // Table is ready + } + if i < maxRetries-1 { + time.Sleep(retryInterval) + continue + } + return fmt.Errorf("table status is %s after %d retries, expected DONE or ERROR", statusStr, maxRetries) + } + } + if i < maxRetries-1 { + time.Sleep(retryInterval) + } + } + return fmt.Errorf("unable to verify table status after %d retries", maxRetries) + } + return nil + } +} diff --git a/docs/data-sources/reference_table.md b/docs/data-sources/reference_table.md new file mode 100644 index 0000000000..9451cb10a2 --- /dev/null +++ b/docs/data-sources/reference_table.md @@ -0,0 +1,124 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "datadog_reference_table Data Source - terraform-provider-datadog" +subcategory: "" +description: |- + Use this data source to retrieve information about an existing Datadog reference table. Query by either table_name or id (mutually exclusive). Supports all source types including cloud storage (S3, GCS, Azure) and external integrations (ServiceNow, Salesforce, Databricks, Snowflake, LOCAL_FILE). +--- + +# datadog_reference_table (Data Source) + +Use this data source to retrieve information about an existing Datadog reference table. Query by either table_name or id (mutually exclusive). Supports all source types including cloud storage (S3, GCS, Azure) and external integrations (ServiceNow, Salesforce, Databricks, Snowflake, LOCAL_FILE). + + + + +## Schema + +### Optional + +- `id` (String) The UUID of the reference table. Either id or table_name must be specified, but not both. +- `table_name` (String) The name of the reference table. Either id or table_name must be specified, but not both. + +### Read-Only + +- `created_by` (String) UUID of the user who created the reference table. +- `description` (String) The description of the reference table. +- `file_metadata` (Block, Read-only) File metadata for the reference table. The structure depends on the source type. (see [below for nested schema](#nestedblock--file_metadata)) +- `last_updated_by` (String) UUID of the user who last updated the reference table. +- `row_count` (Number) The number of successfully processed rows in the reference table. +- `schema` (Block, Read-only) The schema definition for the reference table. (see [below for nested schema](#nestedblock--schema)) +- `source` (String) The source type for the reference table (e.g., S3, GCS, AZURE, SERVICENOW, SALESFORCE, DATABRICKS, SNOWFLAKE, LOCAL_FILE). +- `status` (String) The status of the reference table (e.g., DONE, PROCESSING, ERROR). +- `tags` (List of String) The tags associated with the reference table. +- `updated_at` (String) The timestamp of the last update to the reference table in ISO 8601 format. + + +### Nested Schema for `file_metadata` + +Read-Only: + +- `cloud_storage` (Block, Read-only) Cloud storage metadata (for S3, GCS, or Azure sources). (see [below for nested schema](#nestedblock--file_metadata--cloud_storage)) +- `local_file` (Block, Read-only) Local file metadata (for LOCAL_FILE source). (see [below for nested schema](#nestedblock--file_metadata--local_file)) + + +### Nested Schema for `file_metadata.cloud_storage` + +Read-Only: + +- `access_details` (Block, Read-only) Cloud storage access configuration. (see [below for nested schema](#nestedblock--file_metadata--cloud_storage--access_details)) +- `error_message` (String) Error message from the last sync attempt, if any. +- `error_row_count` (Number) The number of rows that failed to sync. +- `error_type` (String) The type of error that occurred during file processing. +- `sync_enabled` (Boolean) Whether automatic sync is enabled for this table. + + +### Nested Schema for `file_metadata.cloud_storage.access_details` + +Read-Only: + +- `aws_detail` (Block, Read-only) (see [below for nested schema](#nestedblock--file_metadata--cloud_storage--access_details--aws_detail)) +- `azure_detail` (Block, Read-only) (see [below for nested schema](#nestedblock--file_metadata--cloud_storage--access_details--azure_detail)) +- `gcp_detail` (Block, Read-only) (see [below for nested schema](#nestedblock--file_metadata--cloud_storage--access_details--gcp_detail)) + + +### Nested Schema for `file_metadata.cloud_storage.access_details.aws_detail` + +Read-Only: + +- `aws_account_id` (String) The ID of the AWS account. +- `aws_bucket_name` (String) The name of the AWS S3 bucket. +- `file_path` (String) The relative file path from the S3 bucket root. + + + +### Nested Schema for `file_metadata.cloud_storage.access_details.azure_detail` + +Read-Only: + +- `azure_client_id` (String) The Azure client ID. +- `azure_container_name` (String) The name of the Azure container. +- `azure_storage_account_name` (String) The name of the Azure storage account. +- `azure_tenant_id` (String) The ID of the Azure tenant. +- `file_path` (String) The relative file path from the Azure container root. + + + +### Nested Schema for `file_metadata.cloud_storage.access_details.gcp_detail` + +Read-Only: + +- `file_path` (String) The relative file path from the GCS bucket root. +- `gcp_bucket_name` (String) The name of the GCP bucket. +- `gcp_project_id` (String) The ID of the GCP project. +- `gcp_service_account_email` (String) The email of the GCP service account. + + + + + +### Nested Schema for `file_metadata.local_file` + +Read-Only: + +- `error_message` (String) Error message from the last upload, if any. +- `error_row_count` (Number) The number of rows that failed to process. +- `upload_id` (String) The upload ID used to create/update the table. + + + + +### Nested Schema for `schema` + +Read-Only: + +- `fields` (Block List) List of fields in the table schema. (see [below for nested schema](#nestedblock--schema--fields)) +- `primary_keys` (List of String) List of field names that serve as primary keys for the table. + + +### Nested Schema for `schema.fields` + +Read-Only: + +- `name` (String) The name of the field. +- `type` (String) The data type of the field (e.g., STRING, INT32). diff --git a/docs/data-sources/reference_table_rows.md b/docs/data-sources/reference_table_rows.md new file mode 100644 index 0000000000..0eb2bc2d61 --- /dev/null +++ b/docs/data-sources/reference_table_rows.md @@ -0,0 +1,33 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "datadog_reference_table_rows Data Source - terraform-provider-datadog" +subcategory: "" +description: |- + Use this data source to retrieve specific rows from a Datadog reference table by their primary key values. Works with all reference table source types. +--- + +# datadog_reference_table_rows (Data Source) + +Use this data source to retrieve specific rows from a Datadog reference table by their primary key values. Works with all reference table source types. + + + + +## Schema + +### Required + +- `row_ids` (List of String) List of primary key values (row IDs) to retrieve. These are the values of the table's primary key field(s). +- `table_id` (String) The UUID of the reference table to query rows from. + +### Read-Only + +- `rows` (Block List) List of retrieved rows. Each row contains its ID and field values. (see [below for nested schema](#nestedblock--rows)) + + +### Nested Schema for `rows` + +Read-Only: + +- `id` (String) The primary key value of the row. +- `values` (Map of String) Map of field names to values for this row. All values are returned as strings. diff --git a/docs/resources/reference_table.md b/docs/resources/reference_table.md new file mode 100644 index 0000000000..3b4c997f45 --- /dev/null +++ b/docs/resources/reference_table.md @@ -0,0 +1,211 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "datadog_reference_table Resource - terraform-provider-datadog" +subcategory: "" +description: |- + Provides a Datadog Reference Table resource for cloud storage sources (S3, GCS, Azure). This can be used to create and manage Datadog reference tables that sync data from cloud storage. +--- + +# datadog_reference_table (Resource) + +Provides a Datadog Reference Table resource for cloud storage sources (S3, GCS, Azure). This can be used to create and manage Datadog reference tables that sync data from cloud storage. + +## Example Usage + +```terraform +# Create a reference table from an S3 bucket +resource "datadog_reference_table" "s3_table" { + table_name = "products_catalog" + description = "Product catalog synced from S3" + source = "S3" + + file_metadata { + sync_enabled = true + + access_details { + aws_detail { + aws_account_id = "123456789000" + aws_bucket_name = "my-data-bucket" + file_path = "reference-tables/products.csv" + } + } + } + + schema { + primary_keys = ["product_id"] + + fields { + name = "product_id" + type = "STRING" + } + + fields { + name = "product_name" + type = "STRING" + } + + fields { + name = "category" + type = "STRING" + } + + fields { + name = "price_cents" + type = "INT32" + } + } + + tags = [ + "source:s3", + "team:catalog", + "env:production" + ] +} +``` + + +## Schema + +### Required + +- `source` (String) The source type for the reference table. Must be one of: S3, GCS, AZURE. Valid values are `S3`, `GCS`, `AZURE`. +- `table_name` (String) The name of the reference table. This must be unique within your organization. + +### Optional + +- `description` (String) The description of the reference table. +- `file_metadata` (Block, Optional) Configuration for cloud storage file access and sync settings. (see [below for nested schema](#nestedblock--file_metadata)) +- `schema` (Block, Optional) The schema definition for the reference table, including field definitions and primary keys. (see [below for nested schema](#nestedblock--schema)) +- `tags` (List of String) A list of tags to associate with the reference table. + +### Read-Only + +- `created_by` (String) UUID of the user who created the reference table. +- `id` (String) The ID of this resource. +- `last_updated_by` (String) UUID of the user who last updated the reference table. +- `row_count` (Number) The number of successfully processed rows in the reference table. +- `status` (String) The status of the reference table (e.g., DONE, PROCESSING, ERROR). +- `updated_at` (String) The timestamp of the last update to the reference table in ISO 8601 format. + + +### Nested Schema for `file_metadata` + +Required: + +- `sync_enabled` (Boolean) Whether this table should automatically sync with the cloud storage source. + +Optional: + +- `access_details` (Block, Optional) Cloud storage access configuration. Exactly one of aws_detail, gcp_detail, or azure_detail must be specified. (see [below for nested schema](#nestedblock--file_metadata--access_details)) + + +### Nested Schema for `file_metadata.access_details` + +Optional: + +- `aws_detail` (Block, Optional) AWS S3 access configuration. Required when source is S3. (see [below for nested schema](#nestedblock--file_metadata--access_details--aws_detail)) +- `azure_detail` (Block, Optional) Azure Blob Storage access configuration. Required when source is AZURE. (see [below for nested schema](#nestedblock--file_metadata--access_details--azure_detail)) +- `gcp_detail` (Block, Optional) Google Cloud Storage access configuration. Required when source is GCS. (see [below for nested schema](#nestedblock--file_metadata--access_details--gcp_detail)) + + +### Nested Schema for `file_metadata.access_details.aws_detail` + +Optional: + +- `aws_account_id` (String) The ID of the AWS account. +- `aws_bucket_name` (String) The name of the Amazon S3 bucket. +- `file_path` (String) The relative file path from the S3 bucket root to the CSV file. + + + +### Nested Schema for `file_metadata.access_details.azure_detail` + +Optional: + +- `azure_client_id` (String) The Azure client ID (application ID). +- `azure_container_name` (String) The name of the Azure container. +- `azure_storage_account_name` (String) The name of the Azure storage account. +- `azure_tenant_id` (String) The ID of the Azure tenant. +- `file_path` (String) The relative file path from the Azure container root to the CSV file. + + + +### Nested Schema for `file_metadata.access_details.gcp_detail` + +Optional: + +- `file_path` (String) The relative file path from the GCS bucket root to the CSV file. +- `gcp_bucket_name` (String) The name of the GCP bucket. +- `gcp_project_id` (String) The ID of the GCP project. +- `gcp_service_account_email` (String) The email of the GCP service account used to access the bucket. + + + + + +### Nested Schema for `schema` + +Required: + +- `primary_keys` (List of String) List of field names that serve as primary keys for the table. Currently only one primary key is supported. + +Optional: + +- `fields` (Block List) List of fields in the table schema. Must include at least one field. (see [below for nested schema](#nestedblock--schema--fields)) + + +### Nested Schema for `schema.fields` + +Required: + +- `name` (String) The name of the field. +- `type` (String) The data type of the field. Must be one of: STRING, INT32. Valid values are `STRING`, `INT32`. + +## Import + +Import is supported using the following syntax: + +The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: + +```shell +#!/bin/bash +# Import an existing reference table by its UUID + +terraform import datadog_reference_table.imported_table "00000000-0000-0000-0000-000000000000" + +# After importing, add the resource configuration to your .tf file: +# +# resource "datadog_reference_table" "imported_table" { +# table_name = "existing_table" +# description = "Previously created table" +# source = "S3" # or "GCS" or "AZURE" +# +# file_metadata { +# sync_enabled = true +# +# access_details { +# aws_detail { +# aws_account_id = "123456789000" +# aws_bucket_name = "existing-bucket" +# file_path = "data/existing.csv" +# } +# } +# } +# +# schema { +# primary_keys = ["id"] +# +# fields { +# name = "id" +# type = "STRING" +# } +# +# fields { +# name = "value" +# type = "STRING" +# } +# } +# +# tags = ["imported:true"] +# } +``` diff --git a/examples/resources/datadog_reference_table/azure.tf b/examples/resources/datadog_reference_table/azure.tf new file mode 100644 index 0000000000..5b35d3bec5 --- /dev/null +++ b/examples/resources/datadog_reference_table/azure.tf @@ -0,0 +1,47 @@ +# Create a reference table from Azure Blob Storage +resource "datadog_reference_table" "azure_table" { + table_name = "warehouse_inventory" + description = "Inventory data from Azure Blob Storage" + source = "AZURE" + + file_metadata { + sync_enabled = true + + access_details { + azure_detail { + azure_tenant_id = "cccccccc-4444-5555-6666-dddddddddddd" + azure_client_id = "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + azure_storage_account_name = "datadogstorage" + azure_container_name = "reference-tables" + file_path = "inventory/warehouse_stock.csv" + } + } + } + + schema { + primary_keys = ["sku"] + + fields { + name = "sku" + type = "STRING" + } + + fields { + name = "warehouse_id" + type = "STRING" + } + + fields { + name = "stock_quantity" + type = "INT32" + } + + fields { + name = "status" + type = "STRING" + } + } + + tags = ["source:azure", "team:warehouse"] +} + diff --git a/examples/resources/datadog_reference_table/gcs.tf b/examples/resources/datadog_reference_table/gcs.tf new file mode 100644 index 0000000000..974b7d1e9f --- /dev/null +++ b/examples/resources/datadog_reference_table/gcs.tf @@ -0,0 +1,46 @@ +# Create a reference table from Google Cloud Storage +resource "datadog_reference_table" "gcs_table" { + table_name = "store_locations" + description = "Store location data from Google Cloud Storage" + source = "GCS" + + file_metadata { + sync_enabled = true + + access_details { + gcp_detail { + gcp_project_id = "my-gcp-project-12345" + gcp_bucket_name = "datadog-reference-tables" + file_path = "data/store_locations.csv" + gcp_service_account_email = "datadog-sa@my-gcp-project-12345.iam.gserviceaccount.com" + } + } + } + + schema { + primary_keys = ["location_id"] + + fields { + name = "location_id" + type = "STRING" + } + + fields { + name = "store_name" + type = "STRING" + } + + fields { + name = "region" + type = "STRING" + } + + fields { + name = "employee_count" + type = "INT32" + } + } + + tags = ["source:gcs", "team:retail"] +} + diff --git a/examples/resources/datadog_reference_table/import.sh b/examples/resources/datadog_reference_table/import.sh new file mode 100644 index 0000000000..b9c805f6aa --- /dev/null +++ b/examples/resources/datadog_reference_table/import.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Import an existing reference table by its UUID + +terraform import datadog_reference_table.imported_table "00000000-0000-0000-0000-000000000000" + +# After importing, add the resource configuration to your .tf file: +# +# resource "datadog_reference_table" "imported_table" { +# table_name = "existing_table" +# description = "Previously created table" +# source = "S3" # or "GCS" or "AZURE" +# +# file_metadata { +# sync_enabled = true +# +# access_details { +# aws_detail { +# aws_account_id = "123456789000" +# aws_bucket_name = "existing-bucket" +# file_path = "data/existing.csv" +# } +# } +# } +# +# schema { +# primary_keys = ["id"] +# +# fields { +# name = "id" +# type = "STRING" +# } +# +# fields { +# name = "value" +# type = "STRING" +# } +# } +# +# tags = ["imported:true"] +# } diff --git a/examples/resources/datadog_reference_table/resource.tf b/examples/resources/datadog_reference_table/resource.tf new file mode 100644 index 0000000000..2df3668b5a --- /dev/null +++ b/examples/resources/datadog_reference_table/resource.tf @@ -0,0 +1,48 @@ +# Create a reference table from an S3 bucket +resource "datadog_reference_table" "s3_table" { + table_name = "products_catalog" + description = "Product catalog synced from S3" + source = "S3" + + file_metadata { + sync_enabled = true + + access_details { + aws_detail { + aws_account_id = "123456789000" + aws_bucket_name = "my-data-bucket" + file_path = "reference-tables/products.csv" + } + } + } + + schema { + primary_keys = ["product_id"] + + fields { + name = "product_id" + type = "STRING" + } + + fields { + name = "product_name" + type = "STRING" + } + + fields { + name = "category" + type = "STRING" + } + + fields { + name = "price_cents" + type = "INT32" + } + } + + tags = [ + "source:s3", + "team:catalog", + "env:production" + ] +} \ No newline at end of file diff --git a/examples/resources/datadog_reference_table/schema_evolution.tf b/examples/resources/datadog_reference_table/schema_evolution.tf new file mode 100644 index 0000000000..8bba69b212 --- /dev/null +++ b/examples/resources/datadog_reference_table/schema_evolution.tf @@ -0,0 +1,66 @@ +# Example: Schema Evolution - Adding Fields (In-Place Update) +# +# This example demonstrates how to add new fields to an existing reference table. +# Additive schema changes (adding new fields) are supported and will update the table in-place. +# +# IMPORTANT: Destructive schema changes are NOT supported: +# - Removing fields +# - Changing field types +# - Changing primary_keys +# +# For destructive changes, you must manually delete and recreate the table. + +# Initial schema +resource "datadog_reference_table" "customers" { + table_name = "customer_data" + description = "Customer reference data" + source = "S3" + + file_metadata { + sync_enabled = true + + access_details { + aws_detail { + aws_account_id = "123456789000" + aws_bucket_name = "my-data-bucket" + file_path = "customers.csv" + } + } + } + + schema { + primary_keys = ["customer_id"] + + fields { + name = "customer_id" + type = "STRING" + } + + fields { + name = "name" + type = "STRING" + } + + # NEW FIELDS ADDED - This is supported and will update in-place + # Make sure to update the CSV file in S3 with these new columns first! + fields { + name = "email" + type = "STRING" + } + + fields { + name = "signup_year" + type = "INT32" + } + } + + tags = ["team:sales"] +} + +# Note: If you need to make destructive changes (remove fields, change types, or change primary_keys): +# 1. Remove the resource from Terraform state: terraform state rm datadog_reference_table.customers +# 2. Update your configuration with the new schema +# 3. Run terraform apply to recreate the table +# +# Warning: This will cause downtime and any enrichment processors using this table will fail temporarily. + diff --git a/go.mod b/go.mod index 4114e35e50..4f3f2cdbb6 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module github.com/terraform-providers/terraform-provider-datadog require ( - github.com/DataDog/datadog-api-client-go/v2 v2.49.1-0.20251030203800-552aa5c847ff + github.com/DataDog/datadog-api-client-go/v2 v2.49.1-0.20251113205143-35046978b4eb github.com/DataDog/dd-sdk-go-testing v0.0.0-20211116174033-1cd082e322ad github.com/Masterminds/semver/v3 v3.3.1 github.com/google/go-cmp v0.7.0 diff --git a/go.sum b/go.sum index 33543cf909..215fdbbd02 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DataDog/datadog-api-client-go/v2 v2.49.1-0.20251030203800-552aa5c847ff h1:3PolxkmEEehtl4C71m8UjX+BKJfqi+zlXVTsH0FgEGE= -github.com/DataDog/datadog-api-client-go/v2 v2.49.1-0.20251030203800-552aa5c847ff/go.mod h1:d3tOEgUd2kfsr9uuHQdY+nXrWp4uikgTgVCPdKNK30U= +github.com/DataDog/datadog-api-client-go/v2 v2.49.1-0.20251113205143-35046978b4eb h1:hcjwJrlK26dmeqduyN8swiAo5xp8ultwEi26ot6bGHE= +github.com/DataDog/datadog-api-client-go/v2 v2.49.1-0.20251113205143-35046978b4eb/go.mod h1:d3tOEgUd2kfsr9uuHQdY+nXrWp4uikgTgVCPdKNK30U= github.com/DataDog/datadog-go v4.4.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q= github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=