Skip to content

Commit c7e5afc

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add delete log index to public API (#2084)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 72b2626 commit c7e5afc

File tree

8 files changed

+236
-4
lines changed

8 files changed

+236
-4
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2025-03-06 18:30:09.656601",
8-
"spec_repo_commit": "fb234cde"
7+
"regenerated": "2025-03-06 19:05:44.923367",
8+
"spec_repo_commit": "b892dbfc"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-03-06 18:30:09.671867",
13-
"spec_repo_commit": "fb234cde"
12+
"regenerated": "2025-03-06 19:05:44.939641",
13+
"spec_repo_commit": "b892dbfc"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28758,6 +28758,47 @@ paths:
2875828758
permissions:
2875928759
- logs_modify_indexes
2876028760
/api/v1/logs/config/indexes/{name}:
28761+
delete:
28762+
description: 'Delete an existing index from your organization. Index deletions
28763+
are permanent and cannot be reverted.
28764+
28765+
You cannot recreate an index with the same name as deleted ones.'
28766+
operationId: DeleteLogsIndex
28767+
parameters:
28768+
- description: Name of the log index.
28769+
in: path
28770+
name: name
28771+
required: true
28772+
schema:
28773+
type: string
28774+
responses:
28775+
'200':
28776+
content:
28777+
application/json:
28778+
schema:
28779+
$ref: '#/components/schemas/LogsIndex'
28780+
description: OK
28781+
'403':
28782+
content:
28783+
application/json:
28784+
schema:
28785+
$ref: '#/components/schemas/APIErrorResponse'
28786+
description: Forbidden
28787+
'404':
28788+
content:
28789+
application/json:
28790+
schema:
28791+
$ref: '#/components/schemas/LogsAPIErrorResponse'
28792+
description: Not Found
28793+
'429':
28794+
$ref: '#/components/responses/TooManyRequestsResponse'
28795+
summary: Delete an index
28796+
tags:
28797+
- Logs Indexes
28798+
x-permission:
28799+
operator: OR
28800+
permissions:
28801+
- logs_modify_indexes
2876128802
get:
2876228803
description: Get one log index from your organization. This endpoint takes no
2876328804
JSON arguments.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Delete an index returns "OK" response
3+
*/
4+
5+
import { client, v1 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v1.LogsIndexesApi(configuration);
9+
10+
const params: v1.LogsIndexesApiDeleteLogsIndexRequest = {
11+
name: "name",
12+
};
13+
14+
apiInstance
15+
.deleteLogsIndex(params)
16+
.then((data: v1.LogsIndex) => {
17+
console.log(
18+
"API called successfully. Returned data: " + JSON.stringify(data)
19+
);
20+
})
21+
.catch((error: any) => console.error(error));

features/support/scenarios_model_mapping.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,13 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
13941394
},
13951395
"operationResponseType": "LogsIndex",
13961396
},
1397+
"v1.DeleteLogsIndex": {
1398+
"name": {
1399+
"type": "string",
1400+
"format": "",
1401+
},
1402+
"operationResponseType": "LogsIndex",
1403+
},
13971404
"v1.GetLogsIndex": {
13981405
"name": {
13991406
"type": "string",

features/v1/logs_indexes.feature

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ Feature: Logs Indexes
2222
When the request is sent
2323
Then the response status is 200 OK
2424

25+
@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
26+
Scenario: Delete an index returns "Not Found" response
27+
Given new "DeleteLogsIndex" request
28+
And request contains "name" parameter from "REPLACE.ME"
29+
When the request is sent
30+
Then the response status is 404 Not Found
31+
32+
@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
33+
Scenario: Delete an index returns "OK" response
34+
Given new "DeleteLogsIndex" request
35+
And request contains "name" parameter from "REPLACE.ME"
36+
When the request is sent
37+
Then the response status is 200 OK
38+
2539
@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
2640
Scenario: Get all indexes returns "OK" response
2741
Given new "ListLogIndexes" request

features/v1/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,12 @@
694694
"type": "unsafe"
695695
}
696696
},
697+
"DeleteLogsIndex": {
698+
"tag": "Logs Indexes",
699+
"undo": {
700+
"type": "idempotent"
701+
}
702+
},
697703
"GetLogsIndex": {
698704
"tag": "Logs Indexes",
699705
"undo": {

packages/datadog-api-client-v1/apis/LogsIndexesApi.ts

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,39 @@ export class LogsIndexesApiRequestFactory extends BaseAPIRequestFactory {
6565
return requestContext;
6666
}
6767

68+
public async deleteLogsIndex(
69+
name: string,
70+
_options?: Configuration
71+
): Promise<RequestContext> {
72+
const _config = _options || this.configuration;
73+
74+
// verify required parameter 'name' is not null or undefined
75+
if (name === null || name === undefined) {
76+
throw new RequiredError("name", "deleteLogsIndex");
77+
}
78+
79+
// Path Params
80+
const localVarPath = "/api/v1/logs/config/indexes/{name}".replace(
81+
"{name}",
82+
encodeURIComponent(String(name))
83+
);
84+
85+
// Make Request Context
86+
const requestContext = _config
87+
.getServer("v1.LogsIndexesApi.deleteLogsIndex")
88+
.makeRequestContext(localVarPath, HttpMethod.DELETE);
89+
requestContext.setHeaderParam("Accept", "application/json");
90+
requestContext.setHttpConfig(_config.httpConfig);
91+
92+
// Apply auth methods
93+
applySecurityAuthentication(_config, requestContext, [
94+
"apiKeyAuth",
95+
"appKeyAuth",
96+
]);
97+
98+
return requestContext;
99+
}
100+
68101
public async getLogsIndex(
69102
name: string,
70103
_options?: Configuration
@@ -319,6 +352,85 @@ export class LogsIndexesApiResponseProcessor {
319352
);
320353
}
321354

355+
/**
356+
* Unwraps the actual response sent by the server from the response context and deserializes the response content
357+
* to the expected objects
358+
*
359+
* @params response Response returned by the server for a request to deleteLogsIndex
360+
* @throws ApiException if the response code was not in [200, 299]
361+
*/
362+
public async deleteLogsIndex(response: ResponseContext): Promise<LogsIndex> {
363+
const contentType = ObjectSerializer.normalizeMediaType(
364+
response.headers["content-type"]
365+
);
366+
if (response.httpStatusCode === 200) {
367+
const body: LogsIndex = ObjectSerializer.deserialize(
368+
ObjectSerializer.parse(await response.body.text(), contentType),
369+
"LogsIndex"
370+
) as LogsIndex;
371+
return body;
372+
}
373+
if (response.httpStatusCode === 403 || response.httpStatusCode === 429) {
374+
const bodyText = ObjectSerializer.parse(
375+
await response.body.text(),
376+
contentType
377+
);
378+
let body: APIErrorResponse;
379+
try {
380+
body = ObjectSerializer.deserialize(
381+
bodyText,
382+
"APIErrorResponse"
383+
) as APIErrorResponse;
384+
} catch (error) {
385+
logger.debug(`Got error deserializing error: ${error}`);
386+
throw new ApiException<APIErrorResponse>(
387+
response.httpStatusCode,
388+
bodyText
389+
);
390+
}
391+
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
392+
}
393+
if (response.httpStatusCode === 404) {
394+
const bodyText = ObjectSerializer.parse(
395+
await response.body.text(),
396+
contentType
397+
);
398+
let body: LogsAPIErrorResponse;
399+
try {
400+
body = ObjectSerializer.deserialize(
401+
bodyText,
402+
"LogsAPIErrorResponse"
403+
) as LogsAPIErrorResponse;
404+
} catch (error) {
405+
logger.debug(`Got error deserializing error: ${error}`);
406+
throw new ApiException<LogsAPIErrorResponse>(
407+
response.httpStatusCode,
408+
bodyText
409+
);
410+
}
411+
throw new ApiException<LogsAPIErrorResponse>(
412+
response.httpStatusCode,
413+
body
414+
);
415+
}
416+
417+
// Work around for missing responses in specification, e.g. for petstore.yaml
418+
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
419+
const body: LogsIndex = ObjectSerializer.deserialize(
420+
ObjectSerializer.parse(await response.body.text(), contentType),
421+
"LogsIndex",
422+
""
423+
) as LogsIndex;
424+
return body;
425+
}
426+
427+
const body = (await response.body.text()) || "";
428+
throw new ApiException<string>(
429+
response.httpStatusCode,
430+
'Unknown API Status Code!\nBody: "' + body + '"'
431+
);
432+
}
433+
322434
/**
323435
* Unwraps the actual response sent by the server from the response context and deserializes the response content
324436
* to the expected objects
@@ -683,6 +795,14 @@ export interface LogsIndexesApiCreateLogsIndexRequest {
683795
body: LogsIndex;
684796
}
685797

798+
export interface LogsIndexesApiDeleteLogsIndexRequest {
799+
/**
800+
* Name of the log index.
801+
* @type string
802+
*/
803+
name: string;
804+
}
805+
686806
export interface LogsIndexesApiGetLogsIndexRequest {
687807
/**
688808
* Name of the log index.
@@ -750,6 +870,28 @@ export class LogsIndexesApi {
750870
});
751871
}
752872

873+
/**
874+
* Delete an existing index from your organization. Index deletions are permanent and cannot be reverted.
875+
* You cannot recreate an index with the same name as deleted ones.
876+
* @param param The request object
877+
*/
878+
public deleteLogsIndex(
879+
param: LogsIndexesApiDeleteLogsIndexRequest,
880+
options?: Configuration
881+
): Promise<LogsIndex> {
882+
const requestContextPromise = this.requestFactory.deleteLogsIndex(
883+
param.name,
884+
options
885+
);
886+
return requestContextPromise.then((requestContext) => {
887+
return this.configuration.httpApi
888+
.send(requestContext)
889+
.then((responseContext) => {
890+
return this.responseProcessor.deleteLogsIndex(responseContext);
891+
});
892+
});
893+
}
894+
753895
/**
754896
* Get one log index from your organization. This endpoint takes no JSON arguments.
755897
* @param param The request object

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export {
112112

113113
export {
114114
LogsIndexesApiCreateLogsIndexRequest,
115+
LogsIndexesApiDeleteLogsIndexRequest,
115116
LogsIndexesApiGetLogsIndexRequest,
116117
LogsIndexesApiUpdateLogsIndexRequest,
117118
LogsIndexesApiUpdateLogsIndexOrderRequest,

0 commit comments

Comments
 (0)