Skip to content

Commit d1f0814

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Row Update Endpoints to Reference Tables API spec (#3472)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 6fac1ef commit d1f0814

12 files changed

Lines changed: 1058 additions & 0 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6900,6 +6900,72 @@ components:
69006900
required:
69016901
- data
69026902
type: object
6903+
BatchDeleteRowsRequestArray:
6904+
description: The request body for deleting multiple rows from a reference table.
6905+
properties:
6906+
data:
6907+
items:
6908+
$ref: '#/components/schemas/BatchDeleteRowsRequestData'
6909+
maxItems: 200
6910+
type: array
6911+
required:
6912+
- data
6913+
type: object
6914+
BatchDeleteRowsRequestData:
6915+
description: Row resource containing a single row identifier for deletion.
6916+
properties:
6917+
id:
6918+
example: primary_key_value
6919+
type: string
6920+
type:
6921+
$ref: '#/components/schemas/TableRowResourceDataType'
6922+
required:
6923+
- type
6924+
- id
6925+
type: object
6926+
BatchUpsertRowsRequestArray:
6927+
description: The request body for creating or updating multiple rows into a
6928+
reference table.
6929+
properties:
6930+
data:
6931+
items:
6932+
$ref: '#/components/schemas/BatchUpsertRowsRequestData'
6933+
maxItems: 200
6934+
type: array
6935+
required:
6936+
- data
6937+
type: object
6938+
BatchUpsertRowsRequestData:
6939+
description: Row resource containing a single row identifier and its column
6940+
values.
6941+
properties:
6942+
attributes:
6943+
$ref: '#/components/schemas/BatchUpsertRowsRequestDataAttributes'
6944+
id:
6945+
example: primary_key_value
6946+
type: string
6947+
type:
6948+
$ref: '#/components/schemas/TableRowResourceDataType'
6949+
required:
6950+
- type
6951+
- id
6952+
type: object
6953+
BatchUpsertRowsRequestDataAttributes:
6954+
description: Attributes containing row data values for row creation or update
6955+
operations.
6956+
properties:
6957+
values:
6958+
additionalProperties:
6959+
x-required-field: true
6960+
description: Key-value pairs representing row data, where keys are field
6961+
names from the schema.
6962+
example:
6963+
example_key_value: primary_key_value
6964+
name: row_name
6965+
type: object
6966+
required:
6967+
- values
6968+
type: object
69036969
BillConfig:
69046970
description: Bill config.
69056971
properties:
@@ -76823,6 +76889,47 @@ paths:
7682376889
tags:
7682476890
- Reference Tables
7682576891
/api/v2/reference-tables/tables/{id}/rows:
76892+
delete:
76893+
description: Delete multiple rows from a Reference Table by their primary key
76894+
values.
76895+
operationId: DeleteRows
76896+
parameters:
76897+
- description: Unique identifier of the reference table to delete rows from
76898+
in: path
76899+
name: id
76900+
required: true
76901+
schema:
76902+
type: string
76903+
requestBody:
76904+
content:
76905+
application/json:
76906+
schema:
76907+
$ref: '#/components/schemas/BatchDeleteRowsRequestArray'
76908+
required: true
76909+
responses:
76910+
'200':
76911+
description: Rows deleted successfully
76912+
'400':
76913+
$ref: '#/components/responses/BadRequestResponse'
76914+
'403':
76915+
$ref: '#/components/responses/ForbiddenResponse'
76916+
'404':
76917+
$ref: '#/components/responses/NotFoundResponse'
76918+
'429':
76919+
$ref: '#/components/responses/TooManyRequestsResponse'
76920+
'500':
76921+
content:
76922+
application/json:
76923+
schema:
76924+
$ref: '#/components/schemas/APIErrorResponse'
76925+
description: Internal Server Error
76926+
security:
76927+
- apiKeyAuth: []
76928+
appKeyAuth: []
76929+
- AuthZ: []
76930+
summary: Delete rows
76931+
tags:
76932+
- Reference Tables
7682676933
get:
7682776934
description: Get reference table rows by their primary key values.
7682876935
operationId: GetRowsByID
@@ -76867,6 +76974,48 @@ paths:
7686776974
summary: Get rows by id
7686876975
tags:
7686976976
- Reference Tables
76977+
post:
76978+
description: Create or update rows in a Reference Table by their primary key
76979+
values. If a row with the specified primary key exists, it is updated; otherwise,
76980+
a new row is created.
76981+
operationId: UpsertRows
76982+
parameters:
76983+
- description: Unique identifier of the reference table to upsert rows into
76984+
in: path
76985+
name: id
76986+
required: true
76987+
schema:
76988+
type: string
76989+
requestBody:
76990+
content:
76991+
application/json:
76992+
schema:
76993+
$ref: '#/components/schemas/BatchUpsertRowsRequestArray'
76994+
required: true
76995+
responses:
76996+
'200':
76997+
description: Rows created or updated successfully
76998+
'400':
76999+
$ref: '#/components/responses/BadRequestResponse'
77000+
'403':
77001+
$ref: '#/components/responses/ForbiddenResponse'
77002+
'404':
77003+
$ref: '#/components/responses/NotFoundResponse'
77004+
'429':
77005+
$ref: '#/components/responses/TooManyRequestsResponse'
77006+
'500':
77007+
content:
77008+
application/json:
77009+
schema:
77010+
$ref: '#/components/schemas/APIErrorResponse'
77011+
description: Internal Server Error
77012+
security:
77013+
- apiKeyAuth: []
77014+
appKeyAuth: []
77015+
- AuthZ: []
77016+
summary: Upsert rows
77017+
tags:
77018+
- Reference Tables
7687077019
/api/v2/reference-tables/uploads:
7687177020
post:
7687277021
description: Create a reference table upload for bulk data ingestion

api/datadogV2/api_reference_tables.go

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,77 @@ func (a *ReferenceTablesApi) CreateReferenceTableUpload(ctx _context.Context, bo
180180
return localVarReturnValue, localVarHTTPResponse, nil
181181
}
182182

183+
// DeleteRows Delete rows.
184+
// Delete multiple rows from a Reference Table by their primary key values.
185+
func (a *ReferenceTablesApi) DeleteRows(ctx _context.Context, id string, body BatchDeleteRowsRequestArray) (*_nethttp.Response, error) {
186+
var (
187+
localVarHTTPMethod = _nethttp.MethodDelete
188+
localVarPostBody interface{}
189+
)
190+
191+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ReferenceTablesApi.DeleteRows")
192+
if err != nil {
193+
return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
194+
}
195+
196+
localVarPath := localBasePath + "/api/v2/reference-tables/tables/{id}/rows"
197+
localVarPath = datadog.ReplacePathParameter(localVarPath, "{id}", _neturl.PathEscape(datadog.ParameterToString(id, "")))
198+
199+
localVarHeaderParams := make(map[string]string)
200+
localVarQueryParams := _neturl.Values{}
201+
localVarFormParams := _neturl.Values{}
202+
localVarHeaderParams["Content-Type"] = "application/json"
203+
localVarHeaderParams["Accept"] = "*/*"
204+
205+
// body params
206+
localVarPostBody = &body
207+
if a.Client.Cfg.DelegatedTokenConfig != nil {
208+
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
209+
if err != nil {
210+
return nil, err
211+
}
212+
} else {
213+
datadog.SetAuthKeys(
214+
ctx,
215+
&localVarHeaderParams,
216+
[2]string{"apiKeyAuth", "DD-API-KEY"},
217+
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
218+
)
219+
}
220+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
221+
if err != nil {
222+
return nil, err
223+
}
224+
225+
localVarHTTPResponse, err := a.Client.CallAPI(req)
226+
if err != nil || localVarHTTPResponse == nil {
227+
return localVarHTTPResponse, err
228+
}
229+
230+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
231+
if err != nil {
232+
return localVarHTTPResponse, err
233+
}
234+
235+
if localVarHTTPResponse.StatusCode >= 300 {
236+
newErr := datadog.GenericOpenAPIError{
237+
ErrorBody: localVarBody,
238+
ErrorMessage: localVarHTTPResponse.Status,
239+
}
240+
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 || localVarHTTPResponse.StatusCode == 500 {
241+
var v APIErrorResponse
242+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
243+
if err != nil {
244+
return localVarHTTPResponse, newErr
245+
}
246+
newErr.ErrorModel = v
247+
}
248+
return localVarHTTPResponse, newErr
249+
}
250+
251+
return localVarHTTPResponse, nil
252+
}
253+
183254
// DeleteTable Delete table.
184255
// Delete a reference table by ID
185256
func (a *ReferenceTablesApi) DeleteTable(ctx _context.Context, id string) (*_nethttp.Response, error) {
@@ -639,6 +710,77 @@ func (a *ReferenceTablesApi) UpdateReferenceTable(ctx _context.Context, id strin
639710
return localVarHTTPResponse, nil
640711
}
641712

713+
// UpsertRows Upsert rows.
714+
// Create or update rows in a Reference Table by their primary key values. If a row with the specified primary key exists, it is updated; otherwise, a new row is created.
715+
func (a *ReferenceTablesApi) UpsertRows(ctx _context.Context, id string, body BatchUpsertRowsRequestArray) (*_nethttp.Response, error) {
716+
var (
717+
localVarHTTPMethod = _nethttp.MethodPost
718+
localVarPostBody interface{}
719+
)
720+
721+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ReferenceTablesApi.UpsertRows")
722+
if err != nil {
723+
return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
724+
}
725+
726+
localVarPath := localBasePath + "/api/v2/reference-tables/tables/{id}/rows"
727+
localVarPath = datadog.ReplacePathParameter(localVarPath, "{id}", _neturl.PathEscape(datadog.ParameterToString(id, "")))
728+
729+
localVarHeaderParams := make(map[string]string)
730+
localVarQueryParams := _neturl.Values{}
731+
localVarFormParams := _neturl.Values{}
732+
localVarHeaderParams["Content-Type"] = "application/json"
733+
localVarHeaderParams["Accept"] = "*/*"
734+
735+
// body params
736+
localVarPostBody = &body
737+
if a.Client.Cfg.DelegatedTokenConfig != nil {
738+
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
739+
if err != nil {
740+
return nil, err
741+
}
742+
} else {
743+
datadog.SetAuthKeys(
744+
ctx,
745+
&localVarHeaderParams,
746+
[2]string{"apiKeyAuth", "DD-API-KEY"},
747+
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
748+
)
749+
}
750+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
751+
if err != nil {
752+
return nil, err
753+
}
754+
755+
localVarHTTPResponse, err := a.Client.CallAPI(req)
756+
if err != nil || localVarHTTPResponse == nil {
757+
return localVarHTTPResponse, err
758+
}
759+
760+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
761+
if err != nil {
762+
return localVarHTTPResponse, err
763+
}
764+
765+
if localVarHTTPResponse.StatusCode >= 300 {
766+
newErr := datadog.GenericOpenAPIError{
767+
ErrorBody: localVarBody,
768+
ErrorMessage: localVarHTTPResponse.Status,
769+
}
770+
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 || localVarHTTPResponse.StatusCode == 500 {
771+
var v APIErrorResponse
772+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
773+
if err != nil {
774+
return localVarHTTPResponse, newErr
775+
}
776+
newErr.ErrorModel = v
777+
}
778+
return localVarHTTPResponse, newErr
779+
}
780+
781+
return localVarHTTPResponse, nil
782+
}
783+
642784
// NewReferenceTablesApi Returns NewReferenceTablesApi.
643785
func NewReferenceTablesApi(client *datadog.APIClient) *ReferenceTablesApi {
644786
return &ReferenceTablesApi{

api/datadogV2/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,13 @@
478478
// - [RUMApi.UpdateRUMApplication]
479479
// - [ReferenceTablesApi.CreateReferenceTable]
480480
// - [ReferenceTablesApi.CreateReferenceTableUpload]
481+
// - [ReferenceTablesApi.DeleteRows]
481482
// - [ReferenceTablesApi.DeleteTable]
482483
// - [ReferenceTablesApi.GetRowsByID]
483484
// - [ReferenceTablesApi.GetTable]
484485
// - [ReferenceTablesApi.ListTables]
485486
// - [ReferenceTablesApi.UpdateReferenceTable]
487+
// - [ReferenceTablesApi.UpsertRows]
486488
// - [RestrictionPoliciesApi.DeleteRestrictionPolicy]
487489
// - [RestrictionPoliciesApi.GetRestrictionPolicy]
488490
// - [RestrictionPoliciesApi.UpdateRestrictionPolicy]

0 commit comments

Comments
 (0)