Skip to content

Commit 8a1e1dc

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Batch Rows Query Endpoint to Reference Tables API spec (#3835)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 281adea commit 8a1e1dc

17 files changed

Lines changed: 1278 additions & 30 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 135 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7475,23 +7475,89 @@ components:
74757475
properties:
74767476
data:
74777477
items:
7478-
$ref: '#/components/schemas/BatchDeleteRowsRequestData'
7478+
$ref: '#/components/schemas/TableRowResourceIdentifier'
74797479
maxItems: 200
74807480
type: array
74817481
required:
74827482
- data
74837483
type: object
7484-
BatchDeleteRowsRequestData:
7485-
description: Row resource containing a single row identifier for deletion.
7484+
BatchRowsQueryDataType:
7485+
default: reference-tables-batch-rows-query
7486+
description: Resource type identifier for batch queries of reference table rows.
7487+
enum:
7488+
- reference-tables-batch-rows-query
7489+
example: reference-tables-batch-rows-query
7490+
type: string
7491+
x-enum-varnames:
7492+
- REFERENCE_TABLES_BATCH_ROWS_QUERY
7493+
BatchRowsQueryRequest:
7494+
properties:
7495+
data:
7496+
$ref: '#/components/schemas/BatchRowsQueryRequestData'
7497+
type: object
7498+
BatchRowsQueryRequestData:
7499+
properties:
7500+
attributes:
7501+
$ref: '#/components/schemas/BatchRowsQueryRequestDataAttributes'
7502+
type:
7503+
$ref: '#/components/schemas/BatchRowsQueryDataType'
7504+
required:
7505+
- type
7506+
type: object
7507+
BatchRowsQueryRequestDataAttributes:
7508+
properties:
7509+
row_ids:
7510+
example:
7511+
- row_id_1
7512+
- row_id_2
7513+
items:
7514+
type: string
7515+
type: array
7516+
table_id:
7517+
example: 00000000-0000-0000-0000-000000000000
7518+
type: string
7519+
required:
7520+
- row_ids
7521+
- table_id
7522+
type: object
7523+
BatchRowsQueryResponse:
7524+
example:
7525+
data:
7526+
id: 00000000-0000-0000-0000-000000000000
7527+
relationships:
7528+
rows:
7529+
data:
7530+
- id: row_id_1
7531+
type: row
7532+
- id: row_id_2
7533+
type: row
7534+
type: reference-tables-batch-rows-query
7535+
properties:
7536+
data:
7537+
$ref: '#/components/schemas/BatchRowsQueryResponseData'
7538+
type: object
7539+
BatchRowsQueryResponseData:
74867540
properties:
74877541
id:
7488-
example: primary_key_value
74897542
type: string
7543+
relationships:
7544+
$ref: '#/components/schemas/BatchRowsQueryResponseDataRelationships'
74907545
type:
7491-
$ref: '#/components/schemas/TableRowResourceDataType'
7546+
$ref: '#/components/schemas/BatchRowsQueryDataType'
74927547
required:
74937548
- type
7494-
- id
7549+
type: object
7550+
BatchRowsQueryResponseDataRelationships:
7551+
properties:
7552+
rows:
7553+
$ref: '#/components/schemas/BatchRowsQueryResponseDataRelationshipsRows'
7554+
type: object
7555+
BatchRowsQueryResponseDataRelationshipsRows:
7556+
properties:
7557+
data:
7558+
items:
7559+
$ref: '#/components/schemas/TableRowResourceIdentifier'
7560+
type: array
74957561
type: object
74967562
BatchUpsertRowsRequestArray:
74977563
description: The request body for creating or updating multiple rows into a
@@ -66953,6 +67019,18 @@ components:
6695367019
type: string
6695467020
x-enum-varnames:
6695567021
- ROW
67022+
TableRowResourceIdentifier:
67023+
description: Row resource containing a single row identifier.
67024+
properties:
67025+
id:
67026+
example: primary_key_value
67027+
type: string
67028+
type:
67029+
$ref: '#/components/schemas/TableRowResourceDataType'
67030+
required:
67031+
- type
67032+
- id
67033+
type: object
6695667034
TagsEventAttribute:
6695767035
description: Array of tags associated with your event.
6695867036
example:
@@ -96388,6 +96466,57 @@ paths:
9638896466
operator: OR
9638996467
permissions:
9639096468
- timeseries_query
96469+
/api/v2/reference-tables/queries/batch-rows:
96470+
post:
96471+
description: Batch query reference table rows by their primary key values. Returns
96472+
only found rows in the included array.
96473+
operationId: BatchRowsQuery
96474+
requestBody:
96475+
content:
96476+
application/json:
96477+
examples:
96478+
happy_path:
96479+
summary: Batch query reference table rows by their primary key values.
96480+
value:
96481+
data:
96482+
attributes:
96483+
row_ids:
96484+
- row_id_1
96485+
- row_id_2
96486+
table_id: 00000000-0000-0000-0000-000000000000
96487+
type: reference-tables-batch-rows-query
96488+
schema:
96489+
$ref: '#/components/schemas/BatchRowsQueryRequest'
96490+
required: true
96491+
responses:
96492+
'200':
96493+
content:
96494+
application/json:
96495+
schema:
96496+
$ref: '#/components/schemas/BatchRowsQueryResponse'
96497+
description: Successfully retrieved rows. Some or all requested rows were
96498+
found. Response includes found rows in the included section.
96499+
'400':
96500+
$ref: '#/components/responses/BadRequestResponse'
96501+
'403':
96502+
$ref: '#/components/responses/ForbiddenResponse'
96503+
'404':
96504+
$ref: '#/components/responses/NotFoundResponse'
96505+
'429':
96506+
$ref: '#/components/responses/TooManyRequestsResponse'
96507+
'500':
96508+
content:
96509+
application/json:
96510+
schema:
96511+
$ref: '#/components/schemas/APIErrorResponse'
96512+
description: Internal Server Error
96513+
security:
96514+
- apiKeyAuth: []
96515+
appKeyAuth: []
96516+
- AuthZ: []
96517+
summary: Batch rows query
96518+
tags:
96519+
- Reference Tables
9639196520
/api/v2/reference-tables/tables:
9639296521
get:
9639396522
description: List all reference tables in this organization.

api/datadogV2/api_reference_tables.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,86 @@ import (
1616
// ReferenceTablesApi service type
1717
type ReferenceTablesApi datadog.Service
1818

19+
// BatchRowsQuery Batch rows query.
20+
// Batch query reference table rows by their primary key values. Returns only found rows in the included array.
21+
func (a *ReferenceTablesApi) BatchRowsQuery(ctx _context.Context, body BatchRowsQueryRequest) (BatchRowsQueryResponse, *_nethttp.Response, error) {
22+
var (
23+
localVarHTTPMethod = _nethttp.MethodPost
24+
localVarPostBody interface{}
25+
localVarReturnValue BatchRowsQueryResponse
26+
)
27+
28+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ReferenceTablesApi.BatchRowsQuery")
29+
if err != nil {
30+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
31+
}
32+
33+
localVarPath := localBasePath + "/api/v2/reference-tables/queries/batch-rows"
34+
35+
localVarHeaderParams := make(map[string]string)
36+
localVarQueryParams := _neturl.Values{}
37+
localVarFormParams := _neturl.Values{}
38+
localVarHeaderParams["Content-Type"] = "application/json"
39+
localVarHeaderParams["Accept"] = "application/json"
40+
41+
// body params
42+
localVarPostBody = &body
43+
if a.Client.Cfg.DelegatedTokenConfig != nil {
44+
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
45+
if err != nil {
46+
return localVarReturnValue, nil, err
47+
}
48+
} else {
49+
datadog.SetAuthKeys(
50+
ctx,
51+
&localVarHeaderParams,
52+
[2]string{"apiKeyAuth", "DD-API-KEY"},
53+
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
54+
)
55+
}
56+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
57+
if err != nil {
58+
return localVarReturnValue, nil, err
59+
}
60+
61+
localVarHTTPResponse, err := a.Client.CallAPI(req)
62+
if err != nil || localVarHTTPResponse == nil {
63+
return localVarReturnValue, localVarHTTPResponse, err
64+
}
65+
66+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
67+
if err != nil {
68+
return localVarReturnValue, localVarHTTPResponse, err
69+
}
70+
71+
if localVarHTTPResponse.StatusCode >= 300 {
72+
newErr := datadog.GenericOpenAPIError{
73+
ErrorBody: localVarBody,
74+
ErrorMessage: localVarHTTPResponse.Status,
75+
}
76+
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 || localVarHTTPResponse.StatusCode == 500 {
77+
var v APIErrorResponse
78+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
79+
if err != nil {
80+
return localVarReturnValue, localVarHTTPResponse, newErr
81+
}
82+
newErr.ErrorModel = v
83+
}
84+
return localVarReturnValue, localVarHTTPResponse, newErr
85+
}
86+
87+
err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
88+
if err != nil {
89+
newErr := datadog.GenericOpenAPIError{
90+
ErrorBody: localVarBody,
91+
ErrorMessage: err.Error(),
92+
}
93+
return localVarReturnValue, localVarHTTPResponse, newErr
94+
}
95+
96+
return localVarReturnValue, localVarHTTPResponse, nil
97+
}
98+
1999
// CreateReferenceTable Create reference table.
20100
// Creates a reference table. You can provide data in two ways:
21101
// 1. Call POST /api/v2/reference-tables/upload to get an upload ID. Then, PUT the CSV data

api/datadogV2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@
578578
// - [RUMApi.ListRUMEvents]
579579
// - [RUMApi.SearchRUMEvents]
580580
// - [RUMApi.UpdateRUMApplication]
581+
// - [ReferenceTablesApi.BatchRowsQuery]
581582
// - [ReferenceTablesApi.CreateReferenceTable]
582583
// - [ReferenceTablesApi.CreateReferenceTableUpload]
583584
// - [ReferenceTablesApi.DeleteRows]

api/datadogV2/model_batch_delete_rows_request_array.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
// BatchDeleteRowsRequestArray The request body for deleting multiple rows from a reference table.
1414
type BatchDeleteRowsRequestArray struct {
1515
//
16-
Data []BatchDeleteRowsRequestData `json:"data"`
16+
Data []TableRowResourceIdentifier `json:"data"`
1717
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
1818
UnparsedObject map[string]interface{} `json:"-"`
1919
AdditionalProperties map[string]interface{} `json:"-"`
@@ -23,7 +23,7 @@ type BatchDeleteRowsRequestArray struct {
2323
// This constructor will assign default values to properties that have it defined,
2424
// and makes sure properties required by API are set, but the set of arguments
2525
// will change when the set of required properties is changed.
26-
func NewBatchDeleteRowsRequestArray(data []BatchDeleteRowsRequestData) *BatchDeleteRowsRequestArray {
26+
func NewBatchDeleteRowsRequestArray(data []TableRowResourceIdentifier) *BatchDeleteRowsRequestArray {
2727
this := BatchDeleteRowsRequestArray{}
2828
this.Data = data
2929
return &this
@@ -38,25 +38,25 @@ func NewBatchDeleteRowsRequestArrayWithDefaults() *BatchDeleteRowsRequestArray {
3838
}
3939

4040
// GetData returns the Data field value.
41-
func (o *BatchDeleteRowsRequestArray) GetData() []BatchDeleteRowsRequestData {
41+
func (o *BatchDeleteRowsRequestArray) GetData() []TableRowResourceIdentifier {
4242
if o == nil {
43-
var ret []BatchDeleteRowsRequestData
43+
var ret []TableRowResourceIdentifier
4444
return ret
4545
}
4646
return o.Data
4747
}
4848

4949
// GetDataOk returns a tuple with the Data field value
5050
// and a boolean to check if the value has been set.
51-
func (o *BatchDeleteRowsRequestArray) GetDataOk() (*[]BatchDeleteRowsRequestData, bool) {
51+
func (o *BatchDeleteRowsRequestArray) GetDataOk() (*[]TableRowResourceIdentifier, bool) {
5252
if o == nil {
5353
return nil, false
5454
}
5555
return &o.Data, true
5656
}
5757

5858
// SetData sets field value.
59-
func (o *BatchDeleteRowsRequestArray) SetData(v []BatchDeleteRowsRequestData) {
59+
func (o *BatchDeleteRowsRequestArray) SetData(v []TableRowResourceIdentifier) {
6060
o.Data = v
6161
}
6262

@@ -77,7 +77,7 @@ func (o BatchDeleteRowsRequestArray) MarshalJSON() ([]byte, error) {
7777
// UnmarshalJSON deserializes the given payload.
7878
func (o *BatchDeleteRowsRequestArray) UnmarshalJSON(bytes []byte) (err error) {
7979
all := struct {
80-
Data *[]BatchDeleteRowsRequestData `json:"data"`
80+
Data *[]TableRowResourceIdentifier `json:"data"`
8181
}{}
8282
if err = datadog.Unmarshal(bytes, &all); err != nil {
8383
return datadog.Unmarshal(bytes, &o.UnparsedObject)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV2
6+
7+
import (
8+
"fmt"
9+
10+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
11+
)
12+
13+
// BatchRowsQueryDataType Resource type identifier for batch queries of reference table rows.
14+
type BatchRowsQueryDataType string
15+
16+
// List of BatchRowsQueryDataType.
17+
const (
18+
BATCHROWSQUERYDATATYPE_REFERENCE_TABLES_BATCH_ROWS_QUERY BatchRowsQueryDataType = "reference-tables-batch-rows-query"
19+
)
20+
21+
var allowedBatchRowsQueryDataTypeEnumValues = []BatchRowsQueryDataType{
22+
BATCHROWSQUERYDATATYPE_REFERENCE_TABLES_BATCH_ROWS_QUERY,
23+
}
24+
25+
// GetAllowedValues reeturns the list of possible values.
26+
func (v *BatchRowsQueryDataType) GetAllowedValues() []BatchRowsQueryDataType {
27+
return allowedBatchRowsQueryDataTypeEnumValues
28+
}
29+
30+
// UnmarshalJSON deserializes the given payload.
31+
func (v *BatchRowsQueryDataType) UnmarshalJSON(src []byte) error {
32+
var value string
33+
err := datadog.Unmarshal(src, &value)
34+
if err != nil {
35+
return err
36+
}
37+
*v = BatchRowsQueryDataType(value)
38+
return nil
39+
}
40+
41+
// NewBatchRowsQueryDataTypeFromValue returns a pointer to a valid BatchRowsQueryDataType
42+
// for the value passed as argument, or an error if the value passed is not allowed by the enum.
43+
func NewBatchRowsQueryDataTypeFromValue(v string) (*BatchRowsQueryDataType, error) {
44+
ev := BatchRowsQueryDataType(v)
45+
if ev.IsValid() {
46+
return &ev, nil
47+
}
48+
return nil, fmt.Errorf("invalid value '%v' for BatchRowsQueryDataType: valid values are %v", v, allowedBatchRowsQueryDataTypeEnumValues)
49+
}
50+
51+
// IsValid return true if the value is valid for the enum, false otherwise.
52+
func (v BatchRowsQueryDataType) IsValid() bool {
53+
for _, existing := range allowedBatchRowsQueryDataTypeEnumValues {
54+
if existing == v {
55+
return true
56+
}
57+
}
58+
return false
59+
}
60+
61+
// Ptr returns reference to BatchRowsQueryDataType value.
62+
func (v BatchRowsQueryDataType) Ptr() *BatchRowsQueryDataType {
63+
return &v
64+
}

0 commit comments

Comments
 (0)