Skip to content

Commit 25ea3ac

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Flatten file_metadata response schema to avoid OneOf unmarshaling issues (#3018)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent ad31df7 commit 25ea3ac

File tree

9 files changed

+189
-215
lines changed

9 files changed

+189
-215
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 79 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13142,30 +13142,6 @@ components:
1314213142
CreateTableRequest:
1314313143
description: Request body for creating a new reference table from a local file
1314413144
or cloud storage.
13145-
example:
13146-
data:
13147-
attributes:
13148-
description: this is a cloud table generated via a cloud bucket sync
13149-
file_metadata:
13150-
access_details:
13151-
aws_detail:
13152-
aws_account_id: test-account-id
13153-
aws_bucket_name: test-bucket
13154-
file_path: test_rt.csv
13155-
sync_enabled: true
13156-
schema:
13157-
fields:
13158-
- name: name
13159-
type: STRING
13160-
- name: account_id
13161-
type: STRING
13162-
primary_keys:
13163-
- account_id
13164-
source: S3
13165-
table_name: test_reference_table
13166-
tags:
13167-
- test_tag
13168-
type: reference_table
1316913145
properties:
1317013146
data:
1317113147
$ref: '#/components/schemas/CreateTableRequestData'
@@ -13387,6 +13363,17 @@ components:
1338713363
CreateUploadRequest:
1338813364
description: Request to create an upload for a file to be ingested into a reference
1338913365
table.
13366+
example:
13367+
data:
13368+
attributes:
13369+
headers:
13370+
- product_id
13371+
- product_name
13372+
- price
13373+
part_count: 3
13374+
part_size: 10000000
13375+
table_name: my_products_table
13376+
type: upload
1339013377
properties:
1339113378
data:
1339213379
$ref: '#/components/schemas/CreateUploadRequestData'
@@ -51089,32 +51076,35 @@ components:
5108951076
type: string
5109051077
type: object
5109151078
TableResultV2DataAttributesFileMetadata:
51092-
description: Metadata specifying where and how to access the reference table's
51093-
data file.
51094-
oneOf:
51095-
- $ref: '#/components/schemas/TableResultV2DataAttributesFileMetadataCloudStorage'
51096-
- $ref: '#/components/schemas/TableResultV2DataAttributesFileMetadataLocalFile'
51097-
TableResultV2DataAttributesFileMetadataCloudStorage:
5109851079
additionalProperties: false
51099-
description: File metadata for reference tables created by cloud storage.
51080+
description: "Metadata specifying where and how to access the reference table's
51081+
data file.\n\nFor cloud storage tables (S3/GCS/Azure):\n - sync_enabled and
51082+
access_details will always be present\n - error fields (error_message, error_row_count,
51083+
error_type) are present only when errors occur\n\nFor local file tables:\n
51084+
\ - error fields (error_message, error_row_count) are present only when errors
51085+
occur\n - sync_enabled, access_details are never present"
5110051086
properties:
5110151087
access_details:
5110251088
$ref: '#/components/schemas/TableResultV2DataAttributesFileMetadataOneOfAccessDetails'
51089+
description: Cloud storage access configuration. Only present for cloud
51090+
storage sources (S3, GCS, Azure).
5110351091
error_message:
51104-
description: The error message returned from the sync.
51092+
description: The error message returned from the last operation (sync for
51093+
cloud storage, upload for local file).
5110551094
type: string
5110651095
error_row_count:
51107-
description: The number of rows that failed to sync.
51096+
description: The number of rows that failed to process.
5110851097
format: int64
5110951098
type: integer
5111051099
error_type:
5111151100
$ref: '#/components/schemas/TableResultV2DataAttributesFileMetadataCloudStorageErrorType'
51101+
description: The type of error that occurred during file processing. Only
51102+
applicable for cloud storage sources.
5111251103
sync_enabled:
51113-
description: Whether this table is synced automatically.
51104+
description: Whether this table is synced automatically from cloud storage.
51105+
Only applicable for cloud storage sources.
5111451106
type: boolean
51115-
required:
51116-
- access_details
51117-
title: CloudFileMetadataV2
51107+
title: FileMetadataV2
5111851108
type: object
5111951109
TableResultV2DataAttributesFileMetadataCloudStorageErrorType:
5112051110
description: The type of error that occurred during file processing. This field
@@ -51141,21 +51131,6 @@ components:
5114151131
- STATE_ERROR
5114251132
- OPERATION_ERROR
5114351133
- SYSTEM_ERROR
51144-
TableResultV2DataAttributesFileMetadataLocalFile:
51145-
additionalProperties: false
51146-
description: File metadata for reference tables created by upload. Note that
51147-
upload_id is only returned in the immediate create/replace response and is
51148-
not available in subsequent GET requests.
51149-
properties:
51150-
error_message:
51151-
description: The error message returned from the creation/update.
51152-
type: string
51153-
error_row_count:
51154-
description: The number of rows that failed to create/update.
51155-
format: int64
51156-
type: integer
51157-
title: LocalFileMetadataV2
51158-
type: object
5115951134
TableResultV2DataAttributesFileMetadataOneOfAccessDetails:
5116051135
description: Cloud storage access configuration for the reference table data
5116151136
file.
@@ -73511,6 +73486,58 @@ paths:
7351173486
requestBody:
7351273487
content:
7351373488
application/json:
73489+
examples:
73490+
cloud_storage:
73491+
summary: Create table from cloud storage (S3)
73492+
value:
73493+
data:
73494+
attributes:
73495+
description: Customer reference data synced from S3
73496+
file_metadata:
73497+
access_details:
73498+
aws_detail:
73499+
aws_account_id: '924305315327'
73500+
aws_bucket_name: my-data-bucket
73501+
file_path: customers.csv
73502+
sync_enabled: true
73503+
schema:
73504+
fields:
73505+
- name: customer_id
73506+
type: STRING
73507+
- name: customer_name
73508+
type: STRING
73509+
- name: email
73510+
type: STRING
73511+
primary_keys:
73512+
- customer_id
73513+
source: S3
73514+
table_name: customer_reference_data
73515+
tags:
73516+
- team:data-platform
73517+
type: reference_table
73518+
local_file:
73519+
summary: Create table from local file upload
73520+
value:
73521+
data:
73522+
attributes:
73523+
description: Product catalog uploaded via local file
73524+
file_metadata:
73525+
upload_id: 00000000-0000-0000-0000-000000000000
73526+
schema:
73527+
fields:
73528+
- name: product_id
73529+
type: STRING
73530+
- name: product_name
73531+
type: STRING
73532+
- name: price
73533+
type: DOUBLE
73534+
primary_keys:
73535+
- product_id
73536+
source: LOCAL_FILE
73537+
table_name: product_catalog
73538+
tags:
73539+
- team:ecommerce
73540+
type: reference_table
7351473541
schema:
7351573542
$ref: '#/components/schemas/CreateTableRequest'
7351673543
required: true

examples/v2/reference-tables/CreateReferenceTable.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,42 @@ const params: v2.ReferenceTablesApiCreateReferenceTableRequest = {
1111
body: {
1212
data: {
1313
attributes: {
14-
description: "this is a cloud table generated via a cloud bucket sync",
1514
fileMetadata: {
1615
accessDetails: {
1716
awsDetail: {
18-
awsAccountId: "test-account-id",
19-
awsBucketName: "test-bucket",
20-
filePath: "test_rt.csv",
17+
awsAccountId: "123456789000",
18+
awsBucketName: "example-data-bucket",
19+
filePath: "reference-tables/users.csv",
20+
},
21+
azureDetail: {
22+
azureClientId: "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb",
23+
azureContainerName: "reference-data",
24+
azureStorageAccountName: "examplestorageaccount",
25+
azureTenantId: "cccccccc-4444-5555-6666-dddddddddddd",
26+
filePath: "tables/users.csv",
27+
},
28+
gcpDetail: {
29+
filePath: "data/reference_tables/users.csv",
30+
gcpBucketName: "example-data-bucket",
31+
gcpProjectId: "example-gcp-project-12345",
32+
gcpServiceAccountEmail:
33+
"example-service@example-gcp-project-12345.iam.gserviceaccount.com",
2134
},
2235
},
23-
syncEnabled: true,
36+
syncEnabled: false,
2437
},
2538
schema: {
2639
fields: [
2740
{
28-
name: "name",
29-
type: "STRING",
30-
},
31-
{
32-
name: "account_id",
41+
name: "field_1",
3342
type: "STRING",
3443
},
3544
],
36-
primaryKeys: ["account_id"],
45+
primaryKeys: ["field_1"],
3746
},
38-
source: "S3",
39-
tableName: "test_reference_table",
40-
tags: ["test_tag"],
47+
source: "LOCAL_FILE",
48+
tableName: "table_1",
49+
tags: ["tag_1", "tag_2"],
4150
},
4251
type: "reference_table",
4352
},

features/v2/reference_tables.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ Feature: Reference Tables
1010
@generated @skip @team:DataDog/redapl-experiences
1111
Scenario: Create reference table returns "Bad Request" response
1212
Given new "CreateReferenceTable" request
13-
And body with value {"data": {"attributes": {"description": "this is a cloud table generated via a cloud bucket sync", "file_metadata": {"access_details": {"aws_detail": {"aws_account_id": "test-account-id", "aws_bucket_name": "test-bucket", "file_path": "test_rt.csv"}}, "sync_enabled": true}, "schema": {"fields": [{"name": "name", "type": "STRING"}, {"name": "account_id", "type": "STRING"}], "primary_keys": ["account_id"]}, "source": "S3", "table_name": "test_reference_table", "tags": ["test_tag"]}, "type": "reference_table"}}
13+
And body with value {"data": {"attributes": {"file_metadata": {"access_details": {"aws_detail": {"aws_account_id": "123456789000", "aws_bucket_name": "example-data-bucket", "file_path": "reference-tables/users.csv"}, "azure_detail": {"azure_client_id": "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb", "azure_container_name": "reference-data", "azure_storage_account_name": "examplestorageaccount", "azure_tenant_id": "cccccccc-4444-5555-6666-dddddddddddd", "file_path": "tables/users.csv"}, "gcp_detail": {"file_path": "data/reference_tables/users.csv", "gcp_bucket_name": "example-data-bucket", "gcp_project_id": "example-gcp-project-12345", "gcp_service_account_email": "example-service@example-gcp-project-12345.iam.gserviceaccount.com"}}, "sync_enabled": false}, "schema": {"fields": [{"name": "field_1", "type": "STRING"}], "primary_keys": ["field_1"]}, "source": "LOCAL_FILE", "table_name": "table_1", "tags": ["tag_1", "tag_2"]}, "type": "reference_table"}}
1414
When the request is sent
1515
Then the response status is 400 Bad Request
1616

1717
@generated @skip @team:DataDog/redapl-experiences
1818
Scenario: Create reference table returns "Created" response
1919
Given new "CreateReferenceTable" request
20-
And body with value {"data": {"attributes": {"description": "this is a cloud table generated via a cloud bucket sync", "file_metadata": {"access_details": {"aws_detail": {"aws_account_id": "test-account-id", "aws_bucket_name": "test-bucket", "file_path": "test_rt.csv"}}, "sync_enabled": true}, "schema": {"fields": [{"name": "name", "type": "STRING"}, {"name": "account_id", "type": "STRING"}], "primary_keys": ["account_id"]}, "source": "S3", "table_name": "test_reference_table", "tags": ["test_tag"]}, "type": "reference_table"}}
20+
And body with value {"data": {"attributes": {"file_metadata": {"access_details": {"aws_detail": {"aws_account_id": "123456789000", "aws_bucket_name": "example-data-bucket", "file_path": "reference-tables/users.csv"}, "azure_detail": {"azure_client_id": "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb", "azure_container_name": "reference-data", "azure_storage_account_name": "examplestorageaccount", "azure_tenant_id": "cccccccc-4444-5555-6666-dddddddddddd", "file_path": "tables/users.csv"}, "gcp_detail": {"file_path": "data/reference_tables/users.csv", "gcp_bucket_name": "example-data-bucket", "gcp_project_id": "example-gcp-project-12345", "gcp_service_account_email": "example-service@example-gcp-project-12345.iam.gserviceaccount.com"}}, "sync_enabled": false}, "schema": {"fields": [{"name": "field_1", "type": "STRING"}], "primary_keys": ["field_1"]}, "source": "LOCAL_FILE", "table_name": "table_1", "tags": ["tag_1", "tag_2"]}, "type": "reference_table"}}
2121
When the request is sent
2222
Then the response status is 201 Created
2323

2424
@generated @skip @team:DataDog/redapl-experiences
2525
Scenario: Create reference table upload returns "Bad Request" response
2626
Given new "CreateReferenceTableUpload" request
27-
And body with value {"data": {"attributes": {"headers": ["field_1", "field_2"], "part_count": 3, "part_size": 10000000, "table_name": ""}, "type": "upload"}}
27+
And body with value {"data": {"attributes": {"headers": ["product_id", "product_name", "price"], "part_count": 3, "part_size": 10000000, "table_name": "my_products_table"}, "type": "upload"}}
2828
When the request is sent
2929
Then the response status is 400 Bad Request
3030

packages/datadog-api-client-v2/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4129,9 +4129,7 @@ export { TableResultV2Array } from "./models/TableResultV2Array";
41294129
export { TableResultV2Data } from "./models/TableResultV2Data";
41304130
export { TableResultV2DataAttributes } from "./models/TableResultV2DataAttributes";
41314131
export { TableResultV2DataAttributesFileMetadata } from "./models/TableResultV2DataAttributesFileMetadata";
4132-
export { TableResultV2DataAttributesFileMetadataCloudStorage } from "./models/TableResultV2DataAttributesFileMetadataCloudStorage";
41334132
export { TableResultV2DataAttributesFileMetadataCloudStorageErrorType } from "./models/TableResultV2DataAttributesFileMetadataCloudStorageErrorType";
4134-
export { TableResultV2DataAttributesFileMetadataLocalFile } from "./models/TableResultV2DataAttributesFileMetadataLocalFile";
41354133
export { TableResultV2DataAttributesFileMetadataOneOfAccessDetails } from "./models/TableResultV2DataAttributesFileMetadataOneOfAccessDetails";
41364134
export { TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail } from "./models/TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail";
41374135
export { TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail } from "./models/TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail";

packages/datadog-api-client-v2/models/ObjectSerializer.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,8 +2382,7 @@ import { TableResultV2 } from "./TableResultV2";
23822382
import { TableResultV2Array } from "./TableResultV2Array";
23832383
import { TableResultV2Data } from "./TableResultV2Data";
23842384
import { TableResultV2DataAttributes } from "./TableResultV2DataAttributes";
2385-
import { TableResultV2DataAttributesFileMetadataCloudStorage } from "./TableResultV2DataAttributesFileMetadataCloudStorage";
2386-
import { TableResultV2DataAttributesFileMetadataLocalFile } from "./TableResultV2DataAttributesFileMetadataLocalFile";
2385+
import { TableResultV2DataAttributesFileMetadata } from "./TableResultV2DataAttributesFileMetadata";
23872386
import { TableResultV2DataAttributesFileMetadataOneOfAccessDetails } from "./TableResultV2DataAttributesFileMetadataOneOfAccessDetails";
23882387
import { TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail } from "./TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail";
23892388
import { TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail } from "./TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAzureDetail";
@@ -7095,10 +7094,8 @@ const typeMap: { [index: string]: any } = {
70957094
TableResultV2Array: TableResultV2Array,
70967095
TableResultV2Data: TableResultV2Data,
70977096
TableResultV2DataAttributes: TableResultV2DataAttributes,
7098-
TableResultV2DataAttributesFileMetadataCloudStorage:
7099-
TableResultV2DataAttributesFileMetadataCloudStorage,
7100-
TableResultV2DataAttributesFileMetadataLocalFile:
7101-
TableResultV2DataAttributesFileMetadataLocalFile,
7097+
TableResultV2DataAttributesFileMetadata:
7098+
TableResultV2DataAttributesFileMetadata,
71027099
TableResultV2DataAttributesFileMetadataOneOfAccessDetails:
71037100
TableResultV2DataAttributesFileMetadataOneOfAccessDetails,
71047101
TableResultV2DataAttributesFileMetadataOneOfAccessDetailsAwsDetail:
@@ -7832,10 +7829,6 @@ const oneOfMap: { [index: string]: string[] } = {
78327829
SplitCredentialsUpdate: ["SplitAPIKeyUpdate"],
78337830
StatsigCredentials: ["StatsigAPIKey"],
78347831
StatsigCredentialsUpdate: ["StatsigAPIKeyUpdate"],
7835-
TableResultV2DataAttributesFileMetadata: [
7836-
"TableResultV2DataAttributesFileMetadataCloudStorage",
7837-
"TableResultV2DataAttributesFileMetadataLocalFile",
7838-
],
78397832
TeamIncluded: ["User", "TeamLink", "UserTeamPermission"],
78407833
TeamOnCallRespondersIncluded: ["User", "Escalation"],
78417834
TeamRoutingRulesIncluded: ["RoutingRule"],

packages/datadog-api-client-v2/models/TableResultV2DataAttributes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ export class TableResultV2DataAttributes {
2323
"description"?: string;
2424
/**
2525
* Metadata specifying where and how to access the reference table's data file.
26+
*
27+
* For cloud storage tables (S3/GCS/Azure):
28+
* - sync_enabled and access_details will always be present
29+
* - error fields (error_message, error_row_count, error_type) are present only when errors occur
30+
*
31+
* For local file tables:
32+
* - error fields (error_message, error_row_count) are present only when errors occur
33+
* - sync_enabled, access_details are never present
2634
*/
2735
"fileMetadata"?: TableResultV2DataAttributesFileMetadata;
2836
/**

0 commit comments

Comments
 (0)