Skip to content

Commit 4428fc3

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add support for querying logs in Online Archives (#1199)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent d06d886 commit 4428fc3

File tree

8 files changed

+105
-7
lines changed

8 files changed

+105
-7
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.4",
7-
"regenerated": "2022-10-24 13:15:53.347203",
8-
"spec_repo_commit": "18dc2450"
7+
"regenerated": "2022-10-25 14:15:26.509580",
8+
"spec_repo_commit": "ecf2f022"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2022-10-24 13:15:53.359570",
13-
"spec_repo_commit": "18dc2450"
12+
"regenerated": "2022-10-25 14:15:26.532267",
13+
"spec_repo_commit": "ecf2f022"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5235,6 +5235,8 @@ components:
52355235
description: The search query - following the log search syntax.
52365236
example: service:web* AND @http.status_code:[200 TO 299]
52375237
type: string
5238+
storage_tier:
5239+
$ref: '#/components/schemas/LogsStorageTier'
52385240
to:
52395241
default: now
52405242
description: The maximum time for the requested logs, supports date math
@@ -5314,6 +5316,17 @@ components:
53145316
x-enum-varnames:
53155317
- ASCENDING
53165318
- DESCENDING
5319+
LogsStorageTier:
5320+
default: indexes
5321+
description: Specifies storage type as indexes or online-archives
5322+
enum:
5323+
- indexes
5324+
- online-archives
5325+
example: indexes
5326+
type: string
5327+
x-enum-varnames:
5328+
- INDEXES
5329+
- ONLINE_ARCHIVES
53175330
LogsWarning:
53185331
description: A warning message indicating something that went wrong with the
53195332
query
@@ -13136,6 +13149,13 @@ paths:
1313613149
schema:
1313713150
format: date-time
1313813151
type: string
13152+
- description: Specifies the storage type to be used
13153+
example: indexes
13154+
in: query
13155+
name: filter[storage_tier]
13156+
required: false
13157+
schema:
13158+
$ref: '#/components/schemas/LogsStorageTier'
1313913159
- description: Order of logs in results.
1314013160
in: query
1314113161
name: sort

docs/datadog_api_client.v2.model.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,6 +2304,13 @@ logs\_sort\_order
23042304
:members:
23052305
:show-inheritance:
23062306

2307+
logs\_storage\_tier
2308+
-------------------
2309+
2310+
.. automodule:: datadog_api_client.v2.model.logs_storage_tier
2311+
:members:
2312+
:show-inheritance:
2313+
23072314
logs\_warning
23082315
-------------
23092316

src/datadog_api_client/v2/api/logs_api.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from datadog_api_client.v2.model.logs_aggregate_response import LogsAggregateResponse
2020
from datadog_api_client.v2.model.logs_aggregate_request import LogsAggregateRequest
2121
from datadog_api_client.v2.model.logs_list_response import LogsListResponse
22+
from datadog_api_client.v2.model.logs_storage_tier import LogsStorageTier
2223
from datadog_api_client.v2.model.logs_sort import LogsSort
2324
from datadog_api_client.v2.model.log import Log
2425
from datadog_api_client.v2.model.logs_list_request import LogsListRequest
@@ -106,6 +107,11 @@ def __init__(self, api_client=None):
106107
"attribute": "filter[to]",
107108
"location": "query",
108109
},
110+
"filter_storage_tier": {
111+
"openapi_types": (LogsStorageTier,),
112+
"attribute": "filter[storage_tier]",
113+
"location": "query",
114+
},
109115
"sort": {
110116
"openapi_types": (LogsSort,),
111117
"attribute": "sort",
@@ -293,6 +299,7 @@ def list_logs_get(
293299
filter_index: Union[str, UnsetType] = unset,
294300
filter_from: Union[datetime, UnsetType] = unset,
295301
filter_to: Union[datetime, UnsetType] = unset,
302+
filter_storage_tier: Union[LogsStorageTier, UnsetType] = unset,
296303
sort: Union[LogsSort, UnsetType] = unset,
297304
page_cursor: Union[str, UnsetType] = unset,
298305
page_limit: Union[int, UnsetType] = unset,
@@ -317,6 +324,8 @@ def list_logs_get(
317324
:type filter_from: datetime, optional
318325
:param filter_to: Maximum timestamp for requested logs.
319326
:type filter_to: datetime, optional
327+
:param filter_storage_tier: Specifies the storage type to be used
328+
:type filter_storage_tier: LogsStorageTier, optional
320329
:param sort: Order of logs in results.
321330
:type sort: LogsSort, optional
322331
:param page_cursor: List following results with a cursor provided in the previous query.
@@ -338,6 +347,9 @@ def list_logs_get(
338347
if filter_to is not unset:
339348
kwargs["filter_to"] = filter_to
340349

350+
if filter_storage_tier is not unset:
351+
kwargs["filter_storage_tier"] = filter_storage_tier
352+
341353
if sort is not unset:
342354
kwargs["sort"] = sort
343355

@@ -356,6 +368,7 @@ def list_logs_get_with_pagination(
356368
filter_index: Union[str, UnsetType] = unset,
357369
filter_from: Union[datetime, UnsetType] = unset,
358370
filter_to: Union[datetime, UnsetType] = unset,
371+
filter_storage_tier: Union[LogsStorageTier, UnsetType] = unset,
359372
sort: Union[LogsSort, UnsetType] = unset,
360373
page_cursor: Union[str, UnsetType] = unset,
361374
page_limit: Union[int, UnsetType] = unset,
@@ -373,6 +386,8 @@ def list_logs_get_with_pagination(
373386
:type filter_from: datetime, optional
374387
:param filter_to: Maximum timestamp for requested logs.
375388
:type filter_to: datetime, optional
389+
:param filter_storage_tier: Specifies the storage type to be used
390+
:type filter_storage_tier: LogsStorageTier, optional
376391
:param sort: Order of logs in results.
377392
:type sort: LogsSort, optional
378393
:param page_cursor: List following results with a cursor provided in the previous query.
@@ -396,6 +411,9 @@ def list_logs_get_with_pagination(
396411
if filter_to is not unset:
397412
kwargs["filter_to"] = filter_to
398413

414+
if filter_storage_tier is not unset:
415+
kwargs["filter_storage_tier"] = filter_storage_tier
416+
399417
if sort is not unset:
400418
kwargs["sort"] = sort
401419

src/datadog_api_client/v2/model/logs_query_filter.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright 2019-Present Datadog, Inc.
44
from __future__ import annotations
55

6-
from typing import List, Union
6+
from typing import List, TYPE_CHECKING, Union
77

88
from datadog_api_client.model_utils import (
99
ModelNormal,
@@ -13,20 +13,28 @@
1313
)
1414

1515

16+
if TYPE_CHECKING:
17+
from datadog_api_client.v2.model.logs_storage_tier import LogsStorageTier
18+
19+
1620
class LogsQueryFilter(ModelNormal):
1721
@cached_property
1822
def openapi_types(_):
23+
from datadog_api_client.v2.model.logs_storage_tier import LogsStorageTier
24+
1925
return {
2026
"_from": (str,),
2127
"indexes": ([str],),
2228
"query": (str,),
29+
"storage_tier": (LogsStorageTier,),
2330
"to": (str,),
2431
}
2532

2633
attribute_map = {
2734
"_from": "from",
2835
"indexes": "indexes",
2936
"query": "query",
37+
"storage_tier": "storage_tier",
3038
"to": "to",
3139
}
3240

@@ -35,6 +43,7 @@ def __init__(
3543
_from: Union[str, UnsetType] = unset,
3644
indexes: Union[List[str], UnsetType] = unset,
3745
query: Union[str, UnsetType] = unset,
46+
storage_tier: Union[LogsStorageTier, UnsetType] = unset,
3847
to: Union[str, UnsetType] = unset,
3948
**kwargs,
4049
):
@@ -50,6 +59,9 @@ def __init__(
5059
:param query: The search query - following the log search syntax.
5160
:type query: str, optional
5261
62+
:param storage_tier: Specifies storage type as indexes or online-archives
63+
:type storage_tier: LogsStorageTier, optional
64+
5365
:param to: The maximum time for the requested logs, supports date math and regular timestamps (milliseconds).
5466
:type to: str, optional
5567
"""
@@ -59,6 +71,8 @@ def __init__(
5971
kwargs["indexes"] = indexes
6072
if query is not unset:
6173
kwargs["query"] = query
74+
if storage_tier is not unset:
75+
kwargs["storage_tier"] = storage_tier
6276
if to is not unset:
6377
kwargs["to"] = to
6478
super().__init__(kwargs)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
7+
from datadog_api_client.model_utils import (
8+
ModelSimple,
9+
cached_property,
10+
)
11+
12+
from typing import ClassVar
13+
14+
15+
class LogsStorageTier(ModelSimple):
16+
"""
17+
Specifies storage type as indexes or online-archives
18+
19+
:param value: If omitted defaults to "indexes". Must be one of ["indexes", "online-archives"].
20+
:type value: str
21+
"""
22+
23+
allowed_values = {
24+
"indexes",
25+
"online-archives",
26+
}
27+
INDEXES: ClassVar["LogsStorageTier"]
28+
ONLINE_ARCHIVES: ClassVar["LogsStorageTier"]
29+
30+
@cached_property
31+
def openapi_types(_):
32+
return {
33+
"value": (str,),
34+
}
35+
36+
37+
LogsStorageTier.INDEXES = LogsStorageTier("indexes")
38+
LogsStorageTier.ONLINE_ARCHIVES = LogsStorageTier("online-archives")

src/datadog_api_client/v2/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@
379379
from datadog_api_client.v2.model.logs_response_metadata_page import LogsResponseMetadataPage
380380
from datadog_api_client.v2.model.logs_sort import LogsSort
381381
from datadog_api_client.v2.model.logs_sort_order import LogsSortOrder
382+
from datadog_api_client.v2.model.logs_storage_tier import LogsStorageTier
382383
from datadog_api_client.v2.model.logs_warning import LogsWarning
383384
from datadog_api_client.v2.model.metric import Metric
384385
from datadog_api_client.v2.model.metric_active_configuration_type import MetricActiveConfigurationType

tests/v2/features/logs.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Feature: Logs
2626
Scenario: Aggregate events returns "Bad Request" response
2727
Given a valid "appKeyAuth" key in the system
2828
And new "AggregateLogs" request
29-
And body with value {"compute": [{"aggregation": "pc90", "interval": "5m", "metric": "@duration", "type": "total"}], "filter": {"from": "now-15m", "indexes": ["main", "web"], "query": "service:web* AND @http.status_code:[200 TO 299]", "to": "now"}, "group_by": [{"facet": "host", "histogram": {"interval": 10, "max": 100, "min": 50}, "limit": 10, "sort": {"aggregation": "count", "order": "asc"}, "total": false}], "options": {"timezone": "GMT"}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ=="}}
29+
And body with value {"compute": [{"aggregation": "pc90", "interval": "5m", "metric": "@duration", "type": "total"}], "filter": {"from": "now-15m", "indexes": ["main", "web"], "query": "service:web* AND @http.status_code:[200 TO 299]", "storage_tier": "indexes", "to": "now"}, "group_by": [{"facet": "host", "histogram": {"interval": 10, "max": 100, "min": 50}, "limit": 10, "sort": {"aggregation": "count", "order": "asc"}, "total": false}], "options": {"timezone": "GMT"}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ=="}}
3030
When the request is sent
3131
Then the response status is 400 Bad Request
3232

@@ -77,7 +77,7 @@ Feature: Logs
7777
Scenario: Search logs returns "Bad Request" response
7878
Given a valid "appKeyAuth" key in the system
7979
And new "ListLogs" request
80-
And body with value {"filter": {"from": "now-15m", "indexes": ["main", "web"], "query": "service:web* AND @http.status_code:[200 TO 299]", "to": "now"}, "options": {"timezone": "GMT"}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "timestamp"}
80+
And body with value {"filter": {"from": "now-15m", "indexes": ["main", "web"], "query": "service:web* AND @http.status_code:[200 TO 299]", "storage_tier": "indexes", "to": "now"}, "options": {"timezone": "GMT"}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "timestamp"}
8181
When the request is sent
8282
Then the response status is 400 Bad Request
8383

0 commit comments

Comments
 (0)