From b20595c6c9823cf85fba1c6118d841c4e7fd5b49 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 17:36:42 +0000 Subject: [PATCH] Update header for logs search endpoints (#2637) Co-authored-by: ci.datadog-api-spec --- .apigentools-info | 8 +-- .generator/schemas/v2/openapi.yaml | 8 +-- examples/v2/logs/ListLogs.java | 24 ++++++--- examples/v2/logs/ListLogsGet.java | 2 +- examples/v2/logs/ListLogsGet_175182691.java | 25 +++++++++ examples/v2/logs/ListLogs_3400928236.java | 41 ++++++++++++++ examples/v2/logs/ListLogs_534975433.java | 51 ++++++++++++++++++ .../datadog/api/client/v2/api/LogsApi.java | 32 +++++------ .../datadog/api/client/v2/api/logs.feature | 53 +++++++++++++------ 9 files changed, 196 insertions(+), 48 deletions(-) create mode 100644 examples/v2/logs/ListLogsGet_175182691.java create mode 100644 examples/v2/logs/ListLogs_3400928236.java create mode 100644 examples/v2/logs/ListLogs_534975433.java diff --git a/.apigentools-info b/.apigentools-info index 598a316220f..596b303ad8a 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:09.022655", - "spec_repo_commit": "733cf3ea" + "regenerated": "2025-01-03 15:57:07.358573", + "spec_repo_commit": "50c16e5f" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-02 17:32:09.037464", - "spec_repo_commit": "733cf3ea" + "regenerated": "2025-01-03 15:57:07.373454", + "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 76195d0bb3d..5ffff4300a1 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.java b/examples/v2/logs/ListLogs.java index 27e991c33cf..a7c809c0b9d 100644 --- a/examples/v2/logs/ListLogs.java +++ b/examples/v2/logs/ListLogs.java @@ -1,4 +1,4 @@ -// Search logs returns "OK" response +// Search logs (POST) returns "OK" response import com.datadog.api.client.ApiClient; import com.datadog.api.client.ApiException; @@ -8,8 +8,10 @@ import com.datadog.api.client.v2.model.LogsListRequestPage; import com.datadog.api.client.v2.model.LogsListResponse; import com.datadog.api.client.v2.model.LogsQueryFilter; +import com.datadog.api.client.v2.model.LogsQueryOptions; import com.datadog.api.client.v2.model.LogsSort; -import java.util.Collections; +import com.datadog.api.client.v2.model.LogsStorageTier; +import java.util.Arrays; public class Example { public static void main(String[] args) { @@ -20,12 +22,18 @@ public static void main(String[] args) { new LogsListRequest() .filter( new LogsQueryFilter() - .query("datadog-agent") - .indexes(Collections.singletonList("main")) - .from("2020-09-17T11:48:36+01:00") - .to("2020-09-17T12:48:36+01:00")) - .sort(LogsSort.TIMESTAMP_ASCENDING) - .page(new LogsListRequestPage().limit(5)); + .from("now-15m") + .indexes(Arrays.asList("main", "web")) + .query("service:web* AND @http.status_code:[200 TO 299]") + .storageTier(LogsStorageTier.INDEXES) + .to("now")) + .options(new LogsQueryOptions().timezone("GMT")) + .page( + new LogsListRequestPage() + .cursor( + "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==") + .limit(25)) + .sort(LogsSort.TIMESTAMP_ASCENDING); try { LogsListResponse result = apiInstance.listLogs(new ListLogsOptionalParameters().body(body)); diff --git a/examples/v2/logs/ListLogsGet.java b/examples/v2/logs/ListLogsGet.java index ac6adfe2426..707cc9aecdc 100644 --- a/examples/v2/logs/ListLogsGet.java +++ b/examples/v2/logs/ListLogsGet.java @@ -1,4 +1,4 @@ -// Get a list of logs returns "OK" response +// Search logs (GET) returns "OK" response import com.datadog.api.client.ApiClient; import com.datadog.api.client.ApiException; diff --git a/examples/v2/logs/ListLogsGet_175182691.java b/examples/v2/logs/ListLogsGet_175182691.java new file mode 100644 index 00000000000..14a1c80ec11 --- /dev/null +++ b/examples/v2/logs/ListLogsGet_175182691.java @@ -0,0 +1,25 @@ +// Search logs (GET) returns "OK" response with pagination + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.PaginationIterable; +import com.datadog.api.client.v2.api.LogsApi; +import com.datadog.api.client.v2.model.Log; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + LogsApi apiInstance = new LogsApi(defaultClient); + + try { + PaginationIterable iterable = apiInstance.listLogsGetWithPagination(); + + for (Log item : iterable) { + System.out.println(item); + } + } catch (RuntimeException e) { + System.err.println("Exception when calling LogsApi#listLogsGetWithPagination"); + System.err.println("Reason: " + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/logs/ListLogs_3400928236.java b/examples/v2/logs/ListLogs_3400928236.java new file mode 100644 index 00000000000..27e991c33cf --- /dev/null +++ b/examples/v2/logs/ListLogs_3400928236.java @@ -0,0 +1,41 @@ +// Search logs returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.LogsApi; +import com.datadog.api.client.v2.api.LogsApi.ListLogsOptionalParameters; +import com.datadog.api.client.v2.model.LogsListRequest; +import com.datadog.api.client.v2.model.LogsListRequestPage; +import com.datadog.api.client.v2.model.LogsListResponse; +import com.datadog.api.client.v2.model.LogsQueryFilter; +import com.datadog.api.client.v2.model.LogsSort; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + LogsApi apiInstance = new LogsApi(defaultClient); + + LogsListRequest body = + new LogsListRequest() + .filter( + new LogsQueryFilter() + .query("datadog-agent") + .indexes(Collections.singletonList("main")) + .from("2020-09-17T11:48:36+01:00") + .to("2020-09-17T12:48:36+01:00")) + .sort(LogsSort.TIMESTAMP_ASCENDING) + .page(new LogsListRequestPage().limit(5)); + + try { + LogsListResponse result = apiInstance.listLogs(new ListLogsOptionalParameters().body(body)); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling LogsApi#listLogs"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/logs/ListLogs_534975433.java b/examples/v2/logs/ListLogs_534975433.java new file mode 100644 index 00000000000..2bfb8ad9f2c --- /dev/null +++ b/examples/v2/logs/ListLogs_534975433.java @@ -0,0 +1,51 @@ +// Search logs (POST) returns "OK" response with pagination + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.PaginationIterable; +import com.datadog.api.client.v2.api.LogsApi; +import com.datadog.api.client.v2.api.LogsApi.ListLogsOptionalParameters; +import com.datadog.api.client.v2.model.Log; +import com.datadog.api.client.v2.model.LogsListRequest; +import com.datadog.api.client.v2.model.LogsListRequestPage; +import com.datadog.api.client.v2.model.LogsQueryFilter; +import com.datadog.api.client.v2.model.LogsQueryOptions; +import com.datadog.api.client.v2.model.LogsSort; +import com.datadog.api.client.v2.model.LogsStorageTier; +import java.util.Arrays; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + LogsApi apiInstance = new LogsApi(defaultClient); + + LogsListRequest body = + new LogsListRequest() + .filter( + new LogsQueryFilter() + .from("now-15m") + .indexes(Arrays.asList("main", "web")) + .query("service:web* AND @http.status_code:[200 TO 299]") + .storageTier(LogsStorageTier.INDEXES) + .to("now")) + .options(new LogsQueryOptions().timezone("GMT")) + .page( + new LogsListRequestPage() + .cursor( + "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==") + .limit(25)) + .sort(LogsSort.TIMESTAMP_ASCENDING); + + try { + PaginationIterable iterable = + apiInstance.listLogsWithPagination(new ListLogsOptionalParameters().body(body)); + + for (Log item : iterable) { + System.out.println(item); + } + } catch (RuntimeException e) { + System.err.println("Exception when calling LogsApi#listLogsWithPagination"); + System.err.println("Reason: " + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/v2/api/LogsApi.java b/src/main/java/com/datadog/api/client/v2/api/LogsApi.java index c1be6b1c788..da2634ce22c 100644 --- a/src/main/java/com/datadog/api/client/v2/api/LogsApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/LogsApi.java @@ -204,7 +204,7 @@ public ListLogsOptionalParameters body(LogsListRequest body) { } /** - * Search logs. + * Search logs (POST). * *

See {@link #listLogsWithHttpInfo}. * @@ -216,7 +216,7 @@ public LogsListResponse listLogs() throws ApiException { } /** - * Search logs. + * Search logs (POST). * *

See {@link #listLogsWithHttpInfoAsync}. * @@ -231,7 +231,7 @@ public CompletableFuture listLogsAsync() { } /** - * Search logs. + * Search logs (POST). * *

See {@link #listLogsWithHttpInfo}. * @@ -244,7 +244,7 @@ public LogsListResponse listLogs(ListLogsOptionalParameters parameters) throws A } /** - * Search logs. + * Search logs (POST). * *

See {@link #listLogsWithHttpInfoAsync}. * @@ -260,7 +260,7 @@ public CompletableFuture listLogsAsync(ListLogsOptionalParamet } /** - * Search logs. + * Search logs (POST). * *

See {@link #listLogsWithHttpInfo}. * @@ -272,7 +272,7 @@ public PaginationIterable listLogsWithPagination() { } /** - * Search logs. + * Search logs (POST). * *

See {@link #listLogsWithHttpInfo}. * @@ -322,7 +322,7 @@ public PaginationIterable listLogsWithPagination(ListLogsOptionalParameters * 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. See listLogsWithHttpInfo(ListLogsOptionalParame } /** - * Search logs. + * Search logs (POST). * *

See {@link #listLogsWithHttpInfo}. * @@ -517,7 +517,7 @@ public ListLogsGetOptionalParameters pageLimit(Integer pageLimit) { } /** - * Get a list of logs. + * Search logs (GET). * *

See {@link #listLogsGetWithHttpInfo}. * @@ -529,7 +529,7 @@ public LogsListResponse listLogsGet() throws ApiException { } /** - * Get a list of logs. + * Search logs (GET). * *

See {@link #listLogsGetWithHttpInfoAsync}. * @@ -544,7 +544,7 @@ public CompletableFuture listLogsGetAsync() { } /** - * Get a list of logs. + * Search logs (GET). * *

See {@link #listLogsGetWithHttpInfo}. * @@ -558,7 +558,7 @@ public LogsListResponse listLogsGet(ListLogsGetOptionalParameters parameters) } /** - * Get a list of logs. + * Search logs (GET). * *

See {@link #listLogsGetWithHttpInfoAsync}. * @@ -575,7 +575,7 @@ public CompletableFuture listLogsGetAsync( } /** - * Get a list of logs. + * Search logs (GET). * *

See {@link #listLogsGetWithHttpInfo}. * @@ -587,7 +587,7 @@ public PaginationIterable listLogsGetWithPagination() { } /** - * Get a list of logs. + * Search logs (GET). * *

See {@link #listLogsGetWithHttpInfo}. * @@ -630,7 +630,7 @@ public PaginationIterable listLogsGetWithPagination( * 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. See listLogsGetWithHttpInfo( } /** - * Get a list of logs. + * Search logs (GET). * *

See {@link #listLogsGetWithHttpInfo}. * diff --git a/src/test/resources/com/datadog/api/client/v2/api/logs.feature b/src/test/resources/com/datadog/api/client/v2/api/logs.feature index 7763729af5f..b7accd07dd9 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/logs.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/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