diff --git a/.apigentools-info b/.apigentools-info index ac362cd816..016d9ced32 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-02 17:32:10.022066", - "spec_repo_commit": "733cf3ea" + "regenerated": "2025-01-03 15:57:07.457578", + "spec_repo_commit": "50c16e5f" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-02 17:32:10.039540", - "spec_repo_commit": "733cf3ea" + "regenerated": "2025-01-03 15:57:07.474412", + "spec_repo_commit": "50c16e5f" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 76195d0bb3..5ffff4300a 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -38621,7 +38621,7 @@ paths: [Results are paginated][1]. - Use this endpoint to see your latest logs. + Use this endpoint to search and filter your logs. **If you are considering archiving logs for your organization, @@ -38718,7 +38718,7 @@ paths: $ref: '#/components/responses/NotAuthorizedResponse' '429': $ref: '#/components/responses/TooManyRequestsResponse' - summary: Get a list of logs + summary: Search logs (GET) tags: - Logs x-pagination: @@ -38737,7 +38737,7 @@ paths: [Results are paginated][1]. - Use this endpoint to build complex logs filtering and search. + Use this endpoint to search and filter your logs. **If you are considering archiving logs for your organization, @@ -38770,7 +38770,7 @@ paths: $ref: '#/components/responses/NotAuthorizedResponse' '429': $ref: '#/components/responses/TooManyRequestsResponse' - summary: Search logs + summary: Search logs (POST) tags: - Logs x-codegen-request-body-name: body diff --git a/examples/v2/logs/ListLogs.py b/examples/v2/logs/ListLogs.py index ead937f039..1fd0fd7b4f 100644 --- a/examples/v2/logs/ListLogs.py +++ b/examples/v2/logs/ListLogs.py @@ -1,5 +1,5 @@ """ -Search logs returns "OK" response +Search logs (POST) returns "OK" response """ from datadog_api_client import ApiClient, Configuration @@ -7,21 +7,29 @@ from datadog_api_client.v2.model.logs_list_request import LogsListRequest from datadog_api_client.v2.model.logs_list_request_page import LogsListRequestPage from datadog_api_client.v2.model.logs_query_filter import LogsQueryFilter +from datadog_api_client.v2.model.logs_query_options import LogsQueryOptions from datadog_api_client.v2.model.logs_sort import LogsSort +from datadog_api_client.v2.model.logs_storage_tier import LogsStorageTier body = LogsListRequest( filter=LogsQueryFilter( - query="datadog-agent", + _from="now-15m", indexes=[ "main", + "web", ], - _from="2020-09-17T11:48:36+01:00", - to="2020-09-17T12:48:36+01:00", + query="service:web* AND @http.status_code:[200 TO 299]", + storage_tier=LogsStorageTier.INDEXES, + to="now", + ), + options=LogsQueryOptions( + timezone="GMT", ), - sort=LogsSort.TIMESTAMP_ASCENDING, page=LogsListRequestPage( - limit=5, + cursor="eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", + limit=25, ), + sort=LogsSort.TIMESTAMP_ASCENDING, ) configuration = Configuration() diff --git a/examples/v2/logs/ListLogsGet.py b/examples/v2/logs/ListLogsGet.py index 343a60395f..40fe1d4c28 100644 --- a/examples/v2/logs/ListLogsGet.py +++ b/examples/v2/logs/ListLogsGet.py @@ -1,5 +1,5 @@ """ -Get a list of logs returns "OK" response +Search logs (GET) returns "OK" response """ from datadog_api_client import ApiClient, Configuration diff --git a/examples/v2/logs/ListLogsGet_175182691.py b/examples/v2/logs/ListLogsGet_175182691.py new file mode 100644 index 0000000000..2addd7c197 --- /dev/null +++ b/examples/v2/logs/ListLogsGet_175182691.py @@ -0,0 +1,13 @@ +""" +Search logs (GET) returns "OK" response with pagination +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.logs_api import LogsApi + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = LogsApi(api_client) + items = api_instance.list_logs_get_with_pagination() + for item in items: + print(item) diff --git a/examples/v2/logs/ListLogs_3400928236.py b/examples/v2/logs/ListLogs_3400928236.py new file mode 100644 index 0000000000..ead937f039 --- /dev/null +++ b/examples/v2/logs/ListLogs_3400928236.py @@ -0,0 +1,32 @@ +""" +Search logs returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.logs_api import LogsApi +from datadog_api_client.v2.model.logs_list_request import LogsListRequest +from datadog_api_client.v2.model.logs_list_request_page import LogsListRequestPage +from datadog_api_client.v2.model.logs_query_filter import LogsQueryFilter +from datadog_api_client.v2.model.logs_sort import LogsSort + +body = LogsListRequest( + filter=LogsQueryFilter( + query="datadog-agent", + indexes=[ + "main", + ], + _from="2020-09-17T11:48:36+01:00", + to="2020-09-17T12:48:36+01:00", + ), + sort=LogsSort.TIMESTAMP_ASCENDING, + page=LogsListRequestPage( + limit=5, + ), +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = LogsApi(api_client) + response = api_instance.list_logs(body=body) + + print(response) diff --git a/examples/v2/logs/ListLogs_534975433.py b/examples/v2/logs/ListLogs_534975433.py new file mode 100644 index 0000000000..6a4e7c0de9 --- /dev/null +++ b/examples/v2/logs/ListLogs_534975433.py @@ -0,0 +1,40 @@ +""" +Search logs (POST) returns "OK" response with pagination +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.logs_api import LogsApi +from datadog_api_client.v2.model.logs_list_request import LogsListRequest +from datadog_api_client.v2.model.logs_list_request_page import LogsListRequestPage +from datadog_api_client.v2.model.logs_query_filter import LogsQueryFilter +from datadog_api_client.v2.model.logs_query_options import LogsQueryOptions +from datadog_api_client.v2.model.logs_sort import LogsSort +from datadog_api_client.v2.model.logs_storage_tier import LogsStorageTier + +body = LogsListRequest( + filter=LogsQueryFilter( + _from="now-15m", + indexes=[ + "main", + "web", + ], + query="service:web* AND @http.status_code:[200 TO 299]", + storage_tier=LogsStorageTier.INDEXES, + to="now", + ), + options=LogsQueryOptions( + timezone="GMT", + ), + page=LogsListRequestPage( + cursor="eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", + limit=25, + ), + sort=LogsSort.TIMESTAMP_ASCENDING, +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = LogsApi(api_client) + items = api_instance.list_logs_with_pagination(body=body) + for item in items: + print(item) diff --git a/src/datadog_api_client/v2/api/logs_api.py b/src/datadog_api_client/v2/api/logs_api.py index dbc06eed0b..ff5a7f9e0b 100644 --- a/src/datadog_api_client/v2/api/logs_api.py +++ b/src/datadog_api_client/v2/api/logs_api.py @@ -240,12 +240,12 @@ def list_logs( *, body: Union[LogsListRequest, UnsetType] = unset, ) -> LogsListResponse: - """Search logs. + """Search logs (POST). List endpoint returns logs that match a log search query. `Results are paginated `_. - Use this endpoint to build complex logs filtering and search. + Use this endpoint to search and filter your logs. If you are considering archiving logs for your organization, consider use of the Datadog archive capabilities instead of the log list API. @@ -265,7 +265,7 @@ def list_logs_with_pagination( *, body: Union[LogsListRequest, UnsetType] = unset, ) -> collections.abc.Iterable[Log]: - """Search logs. + """Search logs (POST). Provide a paginated version of :meth:`list_logs`, returning all items. @@ -303,12 +303,12 @@ def list_logs_get( page_cursor: Union[str, UnsetType] = unset, page_limit: Union[int, UnsetType] = unset, ) -> LogsListResponse: - """Get a list of logs. + """Search logs (GET). List endpoint returns logs that match a log search query. `Results are paginated `_. - Use this endpoint to see your latest logs. + Use this endpoint to search and filter your logs. If you are considering archiving logs for your organization, consider use of the Datadog archive capabilities instead of the log list API. @@ -372,7 +372,7 @@ def list_logs_get_with_pagination( page_cursor: Union[str, UnsetType] = unset, page_limit: Union[int, UnsetType] = unset, ) -> collections.abc.Iterable[Log]: - """Get a list of logs. + """Search logs (GET). Provide a paginated version of :meth:`list_logs_get`, returning all items. diff --git a/tests/v2/features/logs.feature b/tests/v2/features/logs.feature index 7763729af5..b7accd07dd 100644 --- a/tests/v2/features/logs.feature +++ b/tests/v2/features/logs.feature @@ -43,20 +43,6 @@ Feature: Logs Then the response status is 200 OK And the response "meta.status" is equal to "done" - @generated @skip @team:DataDog/logs-app - Scenario: Get a list of logs returns "Bad Request" response - Given a valid "appKeyAuth" key in the system - And new "ListLogsGet" request - When the request is sent - Then the response status is 400 Bad Request - - @generated @skip @team:DataDog/logs-app - Scenario: Get a list of logs returns "OK" response - Given a valid "appKeyAuth" key in the system - And new "ListLogsGet" request - When the request is sent - Then the response status is 200 OK - @replay-only @skip-validation @team:DataDog/logs-app @with-pagination Scenario: Get a list of logs returns "OK" response with pagination Given a valid "appKeyAuth" key in the system @@ -80,13 +66,50 @@ Feature: Logs And the response "data" has length 0 @generated @skip @team:DataDog/logs-app - Scenario: Search logs returns "Bad Request" response + Scenario: Search logs (GET) returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And new "ListLogsGet" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/logs-app + Scenario: Search logs (GET) returns "OK" response + Given a valid "appKeyAuth" key in the system + And new "ListLogsGet" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/logs-app @with-pagination + Scenario: Search logs (GET) returns "OK" response with pagination + Given a valid "appKeyAuth" key in the system + And new "ListLogsGet" request + When the request with pagination is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/logs-app + Scenario: Search logs (POST) returns "Bad Request" response Given a valid "appKeyAuth" key in the system And new "ListLogs" request 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"} When the request is sent Then the response status is 400 Bad Request + @generated @skip @team:DataDog/logs-app + Scenario: Search logs (POST) returns "OK" response + Given a valid "appKeyAuth" key in the system + And new "ListLogs" request + 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"} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/logs-app @with-pagination + Scenario: Search logs (POST) returns "OK" response with pagination + Given a valid "appKeyAuth" key in the system + And new "ListLogs" request + 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"} + When the request with pagination is sent + Then the response status is 200 OK + @team:DataDog/logs-app Scenario: Search logs returns "OK" response Given a valid "appKeyAuth" key in the system