Skip to content

Commit 54d9501

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add BulkDeleteDatastoreItems to Datastore API spec (#3382)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent e786842 commit 54d9501

17 files changed

Lines changed: 999 additions & 2 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6553,6 +6553,46 @@ components:
65536553
description: The type of the object, must be `budget`.
65546554
type: string
65556555
type: object
6556+
BulkDeleteAppsDatastoreItemsRequest:
6557+
description: Request to delete items from a datastore.
6558+
properties:
6559+
data:
6560+
$ref: '#/components/schemas/BulkDeleteAppsDatastoreItemsRequestData'
6561+
type: object
6562+
BulkDeleteAppsDatastoreItemsRequestData:
6563+
description: Data wrapper containing the data needed to delete items from a
6564+
datastore.
6565+
properties:
6566+
attributes:
6567+
$ref: '#/components/schemas/BulkDeleteAppsDatastoreItemsRequestDataAttributes'
6568+
id:
6569+
description: ID for the datastore of the items to delete.
6570+
type: string
6571+
type:
6572+
$ref: '#/components/schemas/BulkDeleteAppsDatastoreItemsRequestDataType'
6573+
required:
6574+
- type
6575+
type: object
6576+
BulkDeleteAppsDatastoreItemsRequestDataAttributes:
6577+
description: Attributes of request data to delete items from a datastore.
6578+
properties:
6579+
item_keys:
6580+
description: List of primary keys identifying items to delete from datastore.
6581+
Up to 100 items can be deleted in a single request.
6582+
items:
6583+
type: string
6584+
maxItems: 100
6585+
type: array
6586+
type: object
6587+
BulkDeleteAppsDatastoreItemsRequestDataType:
6588+
default: items
6589+
description: Items resource type.
6590+
enum:
6591+
- items
6592+
example: items
6593+
type: string
6594+
x-enum-varnames:
6595+
- ITEMS
65566596
BulkMuteFindingsRequest:
65576597
description: The new bulk mute finding request.
65586598
properties:
@@ -14869,6 +14909,17 @@ components:
1486914909
data:
1487014910
$ref: '#/components/schemas/DeleteAppsDatastoreItemResponseData'
1487114911
type: object
14912+
DeleteAppsDatastoreItemResponseArray:
14913+
description: The definition of `DeleteAppsDatastoreItemResponseArray` object.
14914+
properties:
14915+
data:
14916+
description: The `DeleteAppsDatastoreItemResponseArray` `data`.
14917+
items:
14918+
$ref: '#/components/schemas/DeleteAppsDatastoreItemResponseData'
14919+
type: array
14920+
required:
14921+
- data
14922+
type: object
1487214923
DeleteAppsDatastoreItemResponseData:
1487314924
description: Data containing the identifier of the datastore item that was successfully
1487414925
deleted.
@@ -51257,6 +51308,57 @@ paths:
5125751308
permissions:
5125851309
- apps_datastore_write
5125951310
/api/v2/actions-datastores/{datastore_id}/items/bulk:
51311+
delete:
51312+
description: Deletes multiple items from a datastore by their keys in a single
51313+
operation.
51314+
operationId: BulkDeleteDatastoreItems
51315+
parameters:
51316+
- description: The ID of the datastore.
51317+
in: path
51318+
name: datastore_id
51319+
required: true
51320+
schema:
51321+
type: string
51322+
requestBody:
51323+
content:
51324+
application/json:
51325+
schema:
51326+
$ref: '#/components/schemas/BulkDeleteAppsDatastoreItemsRequest'
51327+
required: true
51328+
responses:
51329+
'200':
51330+
content:
51331+
application/json:
51332+
schema:
51333+
$ref: '#/components/schemas/DeleteAppsDatastoreItemResponseArray'
51334+
description: OK
51335+
'400':
51336+
content:
51337+
application/json:
51338+
schema:
51339+
$ref: '#/components/schemas/JSONAPIErrorResponse'
51340+
description: Bad Request
51341+
'404':
51342+
content:
51343+
application/json:
51344+
schema:
51345+
$ref: '#/components/schemas/JSONAPIErrorResponse'
51346+
description: Not Found
51347+
'429':
51348+
$ref: '#/components/responses/TooManyRequestsResponse'
51349+
'500':
51350+
content:
51351+
application/json:
51352+
schema:
51353+
$ref: '#/components/schemas/JSONAPIErrorResponse'
51354+
description: Internal Server Error
51355+
summary: Bulk delete datastore items
51356+
tags:
51357+
- Actions Datastores
51358+
x-permission:
51359+
operator: OR
51360+
permissions:
51361+
- apps_datastore_write
5126051362
post:
5126151363
description: Creates or replaces multiple items in a datastore by their keys
5126251364
in a single operation.

api/datadogV2/api_actions_datastores.go

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,96 @@ import (
1515
// ActionsDatastoresApi service type
1616
type ActionsDatastoresApi datadog.Service
1717

18+
// BulkDeleteDatastoreItems Bulk delete datastore items.
19+
// Deletes multiple items from a datastore by their keys in a single operation.
20+
func (a *ActionsDatastoresApi) BulkDeleteDatastoreItems(ctx _context.Context, datastoreId string, body BulkDeleteAppsDatastoreItemsRequest) (DeleteAppsDatastoreItemResponseArray, *_nethttp.Response, error) {
21+
var (
22+
localVarHTTPMethod = _nethttp.MethodDelete
23+
localVarPostBody interface{}
24+
localVarReturnValue DeleteAppsDatastoreItemResponseArray
25+
)
26+
27+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ActionsDatastoresApi.BulkDeleteDatastoreItems")
28+
if err != nil {
29+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
30+
}
31+
32+
localVarPath := localBasePath + "/api/v2/actions-datastores/{datastore_id}/items/bulk"
33+
localVarPath = datadog.ReplacePathParameter(localVarPath, "{datastore_id}", _neturl.PathEscape(datadog.ParameterToString(datastoreId, "")))
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 == 404 || localVarHTTPResponse.StatusCode == 500 {
77+
var v JSONAPIErrorResponse
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+
return localVarReturnValue, localVarHTTPResponse, newErr
84+
}
85+
if localVarHTTPResponse.StatusCode == 429 {
86+
var v APIErrorResponse
87+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
88+
if err != nil {
89+
return localVarReturnValue, localVarHTTPResponse, newErr
90+
}
91+
newErr.ErrorModel = v
92+
}
93+
return localVarReturnValue, localVarHTTPResponse, newErr
94+
}
95+
96+
err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
97+
if err != nil {
98+
newErr := datadog.GenericOpenAPIError{
99+
ErrorBody: localVarBody,
100+
ErrorMessage: err.Error(),
101+
}
102+
return localVarReturnValue, localVarHTTPResponse, newErr
103+
}
104+
105+
return localVarReturnValue, localVarHTTPResponse, nil
106+
}
107+
18108
// BulkWriteDatastoreItems Bulk write datastore items.
19109
// Creates or replaces multiple items in a datastore by their keys in a single operation.
20110
func (a *ActionsDatastoresApi) BulkWriteDatastoreItems(ctx _context.Context, datastoreId string, body BulkPutAppsDatastoreItemsRequest) (PutAppsDatastoreItemResponseArray, *_nethttp.Response, error) {

api/datadogV2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
// - [ActionConnectionApi.RegisterAppKey]
3434
// - [ActionConnectionApi.UnregisterAppKey]
3535
// - [ActionConnectionApi.UpdateActionConnection]
36+
// - [ActionsDatastoresApi.BulkDeleteDatastoreItems]
3637
// - [ActionsDatastoresApi.BulkWriteDatastoreItems]
3738
// - [ActionsDatastoresApi.CreateDatastore]
3839
// - [ActionsDatastoresApi.DeleteDatastore]
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
9+
)
10+
11+
// BulkDeleteAppsDatastoreItemsRequest Request to delete items from a datastore.
12+
type BulkDeleteAppsDatastoreItemsRequest struct {
13+
// Data wrapper containing the data needed to delete items from a datastore.
14+
Data *BulkDeleteAppsDatastoreItemsRequestData `json:"data,omitempty"`
15+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
16+
UnparsedObject map[string]interface{} `json:"-"`
17+
AdditionalProperties map[string]interface{} `json:"-"`
18+
}
19+
20+
// NewBulkDeleteAppsDatastoreItemsRequest instantiates a new BulkDeleteAppsDatastoreItemsRequest object.
21+
// This constructor will assign default values to properties that have it defined,
22+
// and makes sure properties required by API are set, but the set of arguments
23+
// will change when the set of required properties is changed.
24+
func NewBulkDeleteAppsDatastoreItemsRequest() *BulkDeleteAppsDatastoreItemsRequest {
25+
this := BulkDeleteAppsDatastoreItemsRequest{}
26+
return &this
27+
}
28+
29+
// NewBulkDeleteAppsDatastoreItemsRequestWithDefaults instantiates a new BulkDeleteAppsDatastoreItemsRequest object.
30+
// This constructor will only assign default values to properties that have it defined,
31+
// but it doesn't guarantee that properties required by API are set.
32+
func NewBulkDeleteAppsDatastoreItemsRequestWithDefaults() *BulkDeleteAppsDatastoreItemsRequest {
33+
this := BulkDeleteAppsDatastoreItemsRequest{}
34+
return &this
35+
}
36+
37+
// GetData returns the Data field value if set, zero value otherwise.
38+
func (o *BulkDeleteAppsDatastoreItemsRequest) GetData() BulkDeleteAppsDatastoreItemsRequestData {
39+
if o == nil || o.Data == nil {
40+
var ret BulkDeleteAppsDatastoreItemsRequestData
41+
return ret
42+
}
43+
return *o.Data
44+
}
45+
46+
// GetDataOk returns a tuple with the Data field value if set, nil otherwise
47+
// and a boolean to check if the value has been set.
48+
func (o *BulkDeleteAppsDatastoreItemsRequest) GetDataOk() (*BulkDeleteAppsDatastoreItemsRequestData, bool) {
49+
if o == nil || o.Data == nil {
50+
return nil, false
51+
}
52+
return o.Data, true
53+
}
54+
55+
// HasData returns a boolean if a field has been set.
56+
func (o *BulkDeleteAppsDatastoreItemsRequest) HasData() bool {
57+
return o != nil && o.Data != nil
58+
}
59+
60+
// SetData gets a reference to the given BulkDeleteAppsDatastoreItemsRequestData and assigns it to the Data field.
61+
func (o *BulkDeleteAppsDatastoreItemsRequest) SetData(v BulkDeleteAppsDatastoreItemsRequestData) {
62+
o.Data = &v
63+
}
64+
65+
// MarshalJSON serializes the struct using spec logic.
66+
func (o BulkDeleteAppsDatastoreItemsRequest) MarshalJSON() ([]byte, error) {
67+
toSerialize := map[string]interface{}{}
68+
if o.UnparsedObject != nil {
69+
return datadog.Marshal(o.UnparsedObject)
70+
}
71+
if o.Data != nil {
72+
toSerialize["data"] = o.Data
73+
}
74+
75+
for key, value := range o.AdditionalProperties {
76+
toSerialize[key] = value
77+
}
78+
return datadog.Marshal(toSerialize)
79+
}
80+
81+
// UnmarshalJSON deserializes the given payload.
82+
func (o *BulkDeleteAppsDatastoreItemsRequest) UnmarshalJSON(bytes []byte) (err error) {
83+
all := struct {
84+
Data *BulkDeleteAppsDatastoreItemsRequestData `json:"data,omitempty"`
85+
}{}
86+
if err = datadog.Unmarshal(bytes, &all); err != nil {
87+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
88+
}
89+
additionalProperties := make(map[string]interface{})
90+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
91+
datadog.DeleteKeys(additionalProperties, &[]string{"data"})
92+
} else {
93+
return err
94+
}
95+
96+
hasInvalidField := false
97+
if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil {
98+
hasInvalidField = true
99+
}
100+
o.Data = all.Data
101+
102+
if len(additionalProperties) > 0 {
103+
o.AdditionalProperties = additionalProperties
104+
}
105+
106+
if hasInvalidField {
107+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
108+
}
109+
110+
return nil
111+
}

0 commit comments

Comments
 (0)