Skip to content

Commit 043e2fc

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 5f4072eb of spec repo
1 parent 4fa3250 commit 043e2fc

File tree

7 files changed

+223
-4
lines changed

7 files changed

+223
-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-05 14:38:20.340456",
8-
"spec_repo_commit": "0c376cca"
7+
"regenerated": "2025-03-05 18:01:21.100831",
8+
"spec_repo_commit": "5f4072eb"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-03-05 14:38:20.356470",
13-
"spec_repo_commit": "0c376cca"
12+
"regenerated": "2025-03-05 18:01:21.116060",
13+
"spec_repo_commit": "5f4072eb"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28747,6 +28747,47 @@ paths:
2874728747
permissions:
2874828748
- logs_modify_indexes
2874928749
/api/v1/logs/config/indexes/{name}:
28750+
delete:
28751+
description: 'Delete an existing index from your organization. Index deletions
28752+
are permanent and cannot be reverted.
28753+
28754+
You cannot recreate an index with the same name as deleted ones.'
28755+
operationId: DeleteLogsIndex
28756+
parameters:
28757+
- description: Name of the log index.
28758+
in: path
28759+
name: name
28760+
required: true
28761+
schema:
28762+
type: string
28763+
responses:
28764+
'200':
28765+
content:
28766+
application/json:
28767+
schema:
28768+
$ref: '#/components/schemas/LogsIndex'
28769+
description: OK
28770+
'403':
28771+
content:
28772+
application/json:
28773+
schema:
28774+
$ref: '#/components/schemas/APIErrorResponse'
28775+
description: Forbidden
28776+
'404':
28777+
content:
28778+
application/json:
28779+
schema:
28780+
$ref: '#/components/schemas/LogsAPIErrorResponse'
28781+
description: Not Found
28782+
'429':
28783+
$ref: '#/components/responses/TooManyRequestsResponse'
28784+
summary: Delete an index
28785+
tags:
28786+
- Logs Indexes
28787+
x-permission:
28788+
operator: OR
28789+
permissions:
28790+
- logs_modify_indexes
2875028791
get:
2875128792
description: Get one log index from your organization. This endpoint takes no
2875228793
JSON arguments.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Delete an index returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV1::api_logs_indexes::LogsIndexesAPI;
4+
5+
#[tokio::main]
6+
async fn main() {
7+
let configuration = datadog::Configuration::new();
8+
let api = LogsIndexesAPI::with_config(configuration);
9+
let resp = api.delete_logs_index("name".to_string()).await;
10+
if let Ok(value) = resp {
11+
println!("{:#?}", value);
12+
} else {
13+
println!("{:#?}", resp.unwrap_err());
14+
}
15+
}

src/datadogV1/api/api_logs_indexes.rs

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ pub enum CreateLogsIndexError {
1919
UnknownValue(serde_json::Value),
2020
}
2121

22+
/// DeleteLogsIndexError is a struct for typed errors of method [`LogsIndexesAPI::delete_logs_index`]
23+
#[derive(Debug, Clone, Serialize, Deserialize)]
24+
#[serde(untagged)]
25+
pub enum DeleteLogsIndexError {
26+
APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
27+
LogsAPIErrorResponse(crate::datadogV1::model::LogsAPIErrorResponse),
28+
UnknownValue(serde_json::Value),
29+
}
30+
2231
/// GetLogsIndexError is a struct for typed errors of method [`LogsIndexesAPI::get_logs_index`]
2332
#[derive(Debug, Clone, Serialize, Deserialize)]
2433
#[serde(untagged)]
@@ -276,6 +285,112 @@ impl LogsIndexesAPI {
276285
}
277286
}
278287

288+
/// Delete an existing index from your organization. Index deletions are permanent and cannot be reverted.
289+
/// You cannot recreate an index with the same name as deleted ones.
290+
pub async fn delete_logs_index(
291+
&self,
292+
name: String,
293+
) -> Result<crate::datadogV1::model::LogsIndex, datadog::Error<DeleteLogsIndexError>> {
294+
match self.delete_logs_index_with_http_info(name).await {
295+
Ok(response_content) => {
296+
if let Some(e) = response_content.entity {
297+
Ok(e)
298+
} else {
299+
Err(datadog::Error::Serde(serde::de::Error::custom(
300+
"response content was None",
301+
)))
302+
}
303+
}
304+
Err(err) => Err(err),
305+
}
306+
}
307+
308+
/// Delete an existing index from your organization. Index deletions are permanent and cannot be reverted.
309+
/// You cannot recreate an index with the same name as deleted ones.
310+
pub async fn delete_logs_index_with_http_info(
311+
&self,
312+
name: String,
313+
) -> Result<
314+
datadog::ResponseContent<crate::datadogV1::model::LogsIndex>,
315+
datadog::Error<DeleteLogsIndexError>,
316+
> {
317+
let local_configuration = &self.config;
318+
let operation_id = "v1.delete_logs_index";
319+
320+
let local_client = &self.client;
321+
322+
let local_uri_str = format!(
323+
"{}/api/v1/logs/config/indexes/{name}",
324+
local_configuration.get_operation_host(operation_id),
325+
name = datadog::urlencode(name)
326+
);
327+
let mut local_req_builder =
328+
local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());
329+
330+
// build headers
331+
let mut headers = HeaderMap::new();
332+
headers.insert("Accept", HeaderValue::from_static("application/json"));
333+
334+
// build user agent
335+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
336+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
337+
Err(e) => {
338+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
339+
headers.insert(
340+
reqwest::header::USER_AGENT,
341+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
342+
)
343+
}
344+
};
345+
346+
// build auth
347+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
348+
headers.insert(
349+
"DD-API-KEY",
350+
HeaderValue::from_str(local_key.key.as_str())
351+
.expect("failed to parse DD-API-KEY header"),
352+
);
353+
};
354+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
355+
headers.insert(
356+
"DD-APPLICATION-KEY",
357+
HeaderValue::from_str(local_key.key.as_str())
358+
.expect("failed to parse DD-APPLICATION-KEY header"),
359+
);
360+
};
361+
362+
local_req_builder = local_req_builder.headers(headers);
363+
let local_req = local_req_builder.build()?;
364+
log::debug!("request content: {:?}", local_req.body());
365+
let local_resp = local_client.execute(local_req).await?;
366+
367+
let local_status = local_resp.status();
368+
let local_content = local_resp.text().await?;
369+
log::debug!("response content: {}", local_content);
370+
371+
if !local_status.is_client_error() && !local_status.is_server_error() {
372+
match serde_json::from_str::<crate::datadogV1::model::LogsIndex>(&local_content) {
373+
Ok(e) => {
374+
return Ok(datadog::ResponseContent {
375+
status: local_status,
376+
content: local_content,
377+
entity: Some(e),
378+
})
379+
}
380+
Err(e) => return Err(datadog::Error::Serde(e)),
381+
};
382+
} else {
383+
let local_entity: Option<DeleteLogsIndexError> =
384+
serde_json::from_str(&local_content).ok();
385+
let local_error = datadog::ResponseContent {
386+
status: local_status,
387+
content: local_content,
388+
entity: local_entity,
389+
};
390+
Err(datadog::Error::ResponseError(local_error))
391+
}
392+
}
393+
279394
/// Get one log index from your organization. This endpoint takes no JSON arguments.
280395
pub async fn get_logs_index(
281396
&self,

tests/scenarios/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

tests/scenarios/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": {

tests/scenarios/function_mappings.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,9 @@ pub fn collect_function_calls(world: &mut DatadogWorld) {
13301330
world
13311331
.function_mappings
13321332
.insert("v1.CreateLogsIndex".into(), test_v1_create_logs_index);
1333+
world
1334+
.function_mappings
1335+
.insert("v1.DeleteLogsIndex".into(), test_v1_delete_logs_index);
13331336
world
13341337
.function_mappings
13351338
.insert("v1.GetLogsIndex".into(), test_v1_get_logs_index);
@@ -7590,6 +7593,31 @@ fn test_v1_create_logs_index(world: &mut DatadogWorld, _parameters: &HashMap<Str
75907593
world.response.code = response.status.as_u16();
75917594
}
75927595

7596+
fn test_v1_delete_logs_index(world: &mut DatadogWorld, _parameters: &HashMap<String, Value>) {
7597+
let api = world
7598+
.api_instances
7599+
.v1_api_logs_indexes
7600+
.as_ref()
7601+
.expect("api instance not found");
7602+
let name = serde_json::from_value(_parameters.get("name").unwrap().clone()).unwrap();
7603+
let response = match block_on(api.delete_logs_index_with_http_info(name)) {
7604+
Ok(response) => response,
7605+
Err(error) => {
7606+
return match error {
7607+
Error::ResponseError(e) => {
7608+
world.response.code = e.status.as_u16();
7609+
if let Some(entity) = e.entity {
7610+
world.response.object = serde_json::to_value(entity).unwrap();
7611+
}
7612+
}
7613+
_ => panic!("error parsing response: {error}"),
7614+
};
7615+
}
7616+
};
7617+
world.response.object = serde_json::to_value(response.entity).unwrap();
7618+
world.response.code = response.status.as_u16();
7619+
}
7620+
75937621
fn test_v1_get_logs_index(world: &mut DatadogWorld, _parameters: &HashMap<String, Value>) {
75947622
let api = world
75957623
.api_instances

0 commit comments

Comments
 (0)