From b073cce4d477db169b89501d8bf9ad6b0abfdba5 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Wed, 27 Nov 2024 15:18:32 +0000 Subject: [PATCH] [ECT-99] Add app key to post /api/v2/events (#397) Co-authored-by: ci.datadog-api-spec --- .apigentools-info | 8 ++++---- .generator/schemas/v2/openapi.yaml | 1 + src/datadogV2/api/api_events.rs | 7 +++++++ tests/scenarios/features/v2/events.feature | 22 ++++++++-------------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.apigentools-info b/.apigentools-info index 3ec0033c2..de7123937 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-11-26 13:36:05.039203", - "spec_repo_commit": "cf1aa5ea" + "regenerated": "2024-11-27 13:08:57.192714", + "spec_repo_commit": "fd3dd4d0" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-11-26 13:36:05.057607", - "spec_repo_commit": "cf1aa5ea" + "regenerated": "2024-11-27 13:08:57.211533", + "spec_repo_commit": "fd3dd4d0" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 581c73992..dbd569aff 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -31492,6 +31492,7 @@ paths: $ref: '#/components/responses/TooManyRequestsResponse' security: - apiKeyAuth: [] + appKeyAuth: [] summary: Post an event tags: - Events diff --git a/src/datadogV2/api/api_events.rs b/src/datadogV2/api/api_events.rs index a25c571ff..3744a47eb 100644 --- a/src/datadogV2/api/api_events.rs +++ b/src/datadogV2/api/api_events.rs @@ -237,6 +237,13 @@ impl EventsAPI { .expect("failed to parse DD-API-KEY header"), ); }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; // build body parameters let output = Vec::new(); diff --git a/tests/scenarios/features/v2/events.feature b/tests/scenarios/features/v2/events.feature index 2013c242f..eada249fd 100644 --- a/tests/scenarios/features/v2/events.feature +++ b/tests/scenarios/features/v2/events.feature @@ -7,26 +7,24 @@ Feature: Events Background: Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system And an instance of "Events" API @generated @skip @team:DataDog/event-management Scenario: Get a list of events returns "Bad Request" response - Given a valid "appKeyAuth" key in the system - And new "ListEvents" request + Given new "ListEvents" request When the request is sent Then the response status is 400 Bad Request @skip-validation @team:DataDog/event-management Scenario: Get a list of events returns "OK" response - Given a valid "appKeyAuth" key in the system - And new "ListEvents" request + Given new "ListEvents" request When the request is sent Then the response status is 200 OK @replay-only @skip-validation @team:DataDog/event-management @with-pagination Scenario: Get a list of events returns "OK" response with pagination - Given a valid "appKeyAuth" key in the system - And new "ListEvents" request + Given new "ListEvents" request And request contains "filter[from]" parameter with value "now-15m" And request contains "filter[to]" parameter with value "now" And request contains "page[limit]" parameter with value 2 @@ -36,8 +34,7 @@ Feature: Events @team:DataDog/event-management Scenario: Get a quick list of events returns "OK" response - Given a valid "appKeyAuth" key in the system - And new "ListEvents" request + Given new "ListEvents" request And request contains "filter[query]" parameter with value "datadog-agent" And request contains "filter[from]" parameter with value "2020-09-17T11:48:36+01:00" And request contains "filter[to]" parameter with value "2020-09-17T12:48:36+01:00" @@ -62,16 +59,14 @@ Feature: Events @team:DataDog/event-management Scenario: Search events returns "Bad Request" response - Given a valid "appKeyAuth" key in the system - And new "SearchEvents" request + Given new "SearchEvents" request And body with value {"filter": {"from": "now-15m", "query": "service:web* AND @http.status_code:[200 TO 299]", "to": "now"}, "options": {"timezone": "GMT"}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "timestamp"} When the request is sent Then the response status is 400 Bad Request @team:DataDog/event-management Scenario: Search events returns "OK" response - Given a valid "appKeyAuth" key in the system - And new "SearchEvents" request + Given new "SearchEvents" request And body with value {"filter": {"query": "datadog-agent", "from": "2020-09-17T11:48:36+01:00", "to": "2020-09-17T12:48:36+01:00"}, "sort": "timestamp", "page": {"limit": 5}} When the request is sent Then the response status is 200 OK @@ -79,8 +74,7 @@ Feature: Events @replay-only @skip-validation @team:DataDog/event-management @with-pagination Scenario: Search events returns "OK" response with pagination - Given a valid "appKeyAuth" key in the system - And new "SearchEvents" request + Given new "SearchEvents" request And body with value {"filter": {"from": "now-15m", "to": "now"}, "options": {"timezone": "GMT"}, "page": {"limit": 2}, "sort": "timestamp"} When the request with pagination is sent Then the response status is 200 OK