Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for v1 search logs #891

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.2",
"regenerated": "2022-03-16 14:22:15.397892",
"spec_repo_commit": "a7afd4c8"
"regenerated": "2022-03-16 20:24:56.270977",
"spec_repo_commit": "1289c722"
},
"v2": {
"apigentools_version": "1.6.2",
"regenerated": "2022-03-16 14:22:15.412827",
"spec_repo_commit": "a7afd4c8"
"regenerated": "2022-03-16 20:24:56.287201",
"spec_repo_commit": "1289c722"
}
}
}
29 changes: 29 additions & 0 deletions examples/v1/logs/ListLogs_235998668.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
Search test logs returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.logs_api import LogsApi
from datadog_api_client.v1.model.logs_list_request import LogsListRequest
from datadog_api_client.v1.model.logs_list_request_time import LogsListRequestTime
from datadog_api_client.v1.model.logs_sort import LogsSort

body = LogsListRequest(
index="main",
query="service:web*",
sort=LogsSort("asc"),
time=LogsListRequestTime(
_from=(datetime.now() + relativedelta(hours=-1)).isoformat(timespec="seconds"),
timezone="Europe/Paris",
to=datetime.now().isoformat(timespec="seconds"),
),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = LogsApi(api_client)
response = api_instance.list_logs(body=body)

print(response)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2022-03-16T20:19:15.972Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
interactions:
- request:
body: '{"index":"main","query":"service:web*","sort":"asc","time":{"from":"2022-03-16T19:19:15.972Z","timezone":"Europe/Paris","to":"2022-03-16T20:19:15.972Z"}}'
headers:
accept:
- application/json
content-type:
- application/json
method: POST
uri: https://api.datadoghq.com/api/v1/logs-queries/list
response:
body:
string: '{"status":"done","nextLogId":null,"logs":[],"requestId":"pddv1ChY1NmxlTHZVZlFpNnN6WGJLQUg4VGNBIi0KHfuLOnaa0UteA_7Jc4dRCbmb4YhQqyZLVXBRZ-eSEgzkoIm-nmhrtG8HKG0"}'
headers:
content-type:
- application/json
status:
code: 200
message: OK
version: 1
6 changes: 3 additions & 3 deletions tests/v1/features/logs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Feature: Logs
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:DataDog/logs-app
Scenario: Search logs returns "OK" response
@team:DataDog/logs-app
Scenario: Search test logs returns "OK" response
Given a valid "appKeyAuth" key in the system
And new "ListLogs" request
And body with value {"index": "retention-3,retention-15", "limit": null, "query": "service:web* AND @http.status_code:[200 TO 299]", "sort": "asc", "startAt": null, "time": {"from": "2020-02-02T02:02:02Z", "timezone": null, "to": "2020-02-02T20:20:20Z"}}
And body with value {"index": "main", "query": "service:web*", "sort": "asc", "time": {"from": "{{ timeISO("now - 1h") }}", "timezone": "Europe/Paris", "to": "{{ timeISO("now") }}" }}
When the request is sent
Then the response status is 200 OK

Expand Down