Skip to content

Commit

Permalink
[ECT-99] Add app key to post /api/v2/events (#397)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Nov 27, 2024
1 parent 2e0332d commit b073cce
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
1 change: 1 addition & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31492,6 +31492,7 @@ paths:
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
summary: Post an event
tags:
- Events
Expand Down
7 changes: 7 additions & 0 deletions src/datadogV2/api/api_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
22 changes: 8 additions & 14 deletions tests/scenarios/features/v2/events.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -62,25 +59,22 @@ 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
And the response "data" has length 0

@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
Expand Down

0 comments on commit b073cce

Please sign in to comment.