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

Update header for logs search endpoints #2173

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.6",
"regenerated": "2025-01-02 17:32:11.649371",
"spec_repo_commit": "733cf3ea"
"regenerated": "2025-01-03 15:57:09.265800",
"spec_repo_commit": "50c16e5f"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-01-02 17:32:11.666424",
"spec_repo_commit": "733cf3ea"
"regenerated": "2025-01-03 15:57:09.282748",
"spec_repo_commit": "50c16e5f"
}
}
}
8 changes: 4 additions & 4 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions examples/v2/logs/ListLogs.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
# Search logs returns "OK" response
# Search logs (POST) returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::LogsAPI.new

body = DatadogAPIClient::V2::LogsListRequest.new({
filter: DatadogAPIClient::V2::LogsQueryFilter.new({
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: DatadogAPIClient::V2::LogsStorageTier::INDEXES,
to: "now",
}),
options: DatadogAPIClient::V2::LogsQueryOptions.new({
timezone: "GMT",
}),
sort: DatadogAPIClient::V2::LogsSort::TIMESTAMP_ASCENDING,
page: DatadogAPIClient::V2::LogsListRequestPage.new({
limit: 5,
cursor: "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
limit: 25,
}),
sort: DatadogAPIClient::V2::LogsSort::TIMESTAMP_ASCENDING,
})
opts = {
body: body,
Expand Down
2 changes: 1 addition & 1 deletion examples/v2/logs/ListLogsGet.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Get a list of logs returns "OK" response
# Search logs (GET) returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::LogsAPI.new
Expand Down
5 changes: 5 additions & 0 deletions examples/v2/logs/ListLogsGet_175182691.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Search logs (GET) returns "OK" response with pagination

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::LogsAPI.new
api_instance.list_logs_get_with_pagination() { |item| puts item }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Suggested change
api_instance.list_logs_get_with_pagination() { |item| puts item }
api_instance.list_logs_get_with_pagination { |item| puts item }
Do not use parentheses with methods that take no arguments (...read more)

The rule "Avoid parentheses when methods take no arguments" is part of the Ruby style guide. It suggests that when a method takes no arguments, you should not use parentheses. This is because the use of parentheses in such a case is redundant and unnecessary, and it can make your code more difficult to read and understand.

This rule is important because it promotes cleaner, more readable code. In Ruby, clean and readable code is highly valued. By following this rule, you can ensure your code is easier to understand and maintain, which is crucial for long-term project success.

To adhere to this rule, remove the parentheses when calling a method that does not require any arguments. For example, instead of writing 'test'.upcase(), you should write 'test'.upcase. Similarly, instead of Kernel.exit!(), write Kernel.exit!. However, note that there is an exception for super - super by itself is different from super(), so in this case, parentheses may be necessary.

View in Datadog  Leave us feedback  Documentation

23 changes: 23 additions & 0 deletions examples/v2/logs/ListLogs_3400928236.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Search logs returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::LogsAPI.new

body = DatadogAPIClient::V2::LogsListRequest.new({
filter: DatadogAPIClient::V2::LogsQueryFilter.new({
query: "datadog-agent",
indexes: [
"main",
],
Comment on lines +9 to +11

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Consider using the %W syntax instead (...read more)

The rule "Prefer %w to the literal array syntax" is a Ruby style guideline that encourages the use of %w notation instead of the traditional array syntax when defining arrays of strings. This rule is part of the Ruby community's efforts to promote readability and simplicity in Ruby code.

This rule is important because it helps to keep the code concise and easy to read. The %w notation allows you to define an array of strings without having to use quotes and commas. This can make the code cleaner and easier to understand, especially when dealing with large arrays.

To follow this rule, replace the traditional array syntax with the %w notation. For example, instead of writing ['foo', 'bar', 'baz'], you should write %w[foo bar baz]. This will create the same array, but in a more readable and concise way. By following this rule, you can help to make your Ruby code cleaner and easier to understand.

View in Datadog  Leave us feedback  Documentation

from: "2020-09-17T11:48:36+01:00",
to: "2020-09-17T12:48:36+01:00",
}),
sort: DatadogAPIClient::V2::LogsSort::TIMESTAMP_ASCENDING,
page: DatadogAPIClient::V2::LogsListRequestPage.new({
limit: 5,
}),
})
opts = {
body: body,
}
p api_instance.list_logs(opts)
29 changes: 29 additions & 0 deletions examples/v2/logs/ListLogs_534975433.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Search logs (POST) returns "OK" response with pagination

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::LogsAPI.new

body = DatadogAPIClient::V2::LogsListRequest.new({
filter: DatadogAPIClient::V2::LogsQueryFilter.new({
from: "now-15m",
indexes: [
"main",
"web",
],
Comment on lines +9 to +12

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Consider using the %W syntax instead (...read more)

The rule "Prefer %w to the literal array syntax" is a Ruby style guideline that encourages the use of %w notation instead of the traditional array syntax when defining arrays of strings. This rule is part of the Ruby community's efforts to promote readability and simplicity in Ruby code.

This rule is important because it helps to keep the code concise and easy to read. The %w notation allows you to define an array of strings without having to use quotes and commas. This can make the code cleaner and easier to understand, especially when dealing with large arrays.

To follow this rule, replace the traditional array syntax with the %w notation. For example, instead of writing ['foo', 'bar', 'baz'], you should write %w[foo bar baz]. This will create the same array, but in a more readable and concise way. By following this rule, you can help to make your Ruby code cleaner and easier to understand.

View in Datadog  Leave us feedback  Documentation

query: "service:web* AND @http.status_code:[200 TO 299]",
storage_tier: DatadogAPIClient::V2::LogsStorageTier::INDEXES,
to: "now",
}),
options: DatadogAPIClient::V2::LogsQueryOptions.new({
timezone: "GMT",
}),
page: DatadogAPIClient::V2::LogsListRequestPage.new({
cursor: "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
limit: 25,
}),
sort: DatadogAPIClient::V2::LogsSort::TIMESTAMP_ASCENDING,
})
opts = {
body: body,
}
api_instance.list_logs_with_pagination(opts) { |item| puts item }
53 changes: 38 additions & 15 deletions features/v2/logs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions lib/datadog_api_client/v2/api/logs_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,20 @@ def aggregate_logs_with_http_info(body, opts = {})
return data, status_code, headers
end

# Search logs.
# Search logs (POST).
#
# @see #list_logs_with_http_info
def list_logs(opts = {})
data, _status_code, _headers = list_logs_with_http_info(opts)
data
end

# Search logs.
# Search logs (POST).
#
# List endpoint returns logs that match a log search query.
# [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,
# consider use of the Datadog archive capabilities instead of the log list API.
Expand Down Expand Up @@ -163,7 +163,7 @@ def list_logs_with_http_info(opts = {})
return data, status_code, headers
end

# Search logs.
# Search logs (POST).
#
# Provide a paginated version of {#list_logs}, returning all items.
#
Expand All @@ -184,20 +184,20 @@ def list_logs_with_pagination(opts = {})
end
end

# Get a list of logs.
# Search logs (GET).
#
# @see #list_logs_get_with_http_info
def list_logs_get(opts = {})
data, _status_code, _headers = list_logs_get_with_http_info(opts)
data
end

# Get a list of logs.
# Search logs (GET).
#
# List endpoint returns logs that match a log search query.
# [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,
# consider use of the Datadog archive capabilities instead of the log list API.
Expand Down Expand Up @@ -281,7 +281,7 @@ def list_logs_get_with_http_info(opts = {})
return data, status_code, headers
end

# Get a list of logs.
# Search logs (GET).
#
# Provide a paginated version of {#list_logs_get}, returning all items.
#
Expand Down
Loading