Skip to content
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-03-06 18:30:10.435668",
"spec_repo_commit": "fb234cde"
"regenerated": "2025-03-06 19:05:43.111831",
"spec_repo_commit": "b892dbfc"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-03-06 18:30:10.454101",
"spec_repo_commit": "fb234cde"
"regenerated": "2025-03-06 19:05:43.127161",
"spec_repo_commit": "b892dbfc"
}
}
}
41 changes: 41 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28758,6 +28758,47 @@ paths:
permissions:
- logs_modify_indexes
/api/v1/logs/config/indexes/{name}:
delete:
description: 'Delete an existing index from your organization. Index deletions
are permanent and cannot be reverted.

You cannot recreate an index with the same name as deleted ones.'
operationId: DeleteLogsIndex
parameters:
- description: Name of the log index.
in: path
name: name
required: true
schema:
type: string
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/LogsIndex'
description: OK
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Forbidden
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/LogsAPIErrorResponse'
description: Not Found
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
summary: Delete an index
tags:
- Logs Indexes
x-permission:
operator: OR
permissions:
- logs_modify_indexes
get:
description: Get one log index from your organization. This endpoint takes no
JSON arguments.
Expand Down
5 changes: 5 additions & 0 deletions examples/v1/logs-indexes/DeleteLogsIndex.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Delete an index returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::LogsIndexesAPI.new
p api_instance.delete_logs_index("name")
3 changes: 3 additions & 0 deletions features/scenarios_model_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,9 @@
"v1.CreateLogsIndex" => {
"body" => "LogsIndex",
},
"v1.DeleteLogsIndex" => {
"name" => "String",
},
Comment on lines +503 to +505

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 symbols instead of string hash keys (...read more)

In Ruby, it is a best practice to use symbols instead of strings as hash keys. This rule emphasizes that it's more efficient and idiomatic to use symbols for this purpose. Symbols are immutable and unique, which makes them ideal for identifying things, whereas strings are mutable and can create multiple objects for the same sequence of characters.

The importance of this rule lies in the performance and memory usage of your Ruby application. Using symbols as hash keys reduces memory usage because they are stored in memory only once during a Ruby process. This can make a significant difference in the efficiency of your application, especially when dealing with large data sets.

To ensure you're following good coding practices, always use symbols for hash keys unless there's a specific reason to use a string. A simple refactoring from values = { 'foo' => 42, 'bar' => 99, 'baz' => 123 } to values = { foo: 42, bar: 99, baz: 123 } will make your code compliant with this rule. This not only improves your code's performance but also makes it more readable and consistent with Ruby's conventions.

View in Datadog  Leave us feedback  Documentation

"v1.GetLogsIndex" => {
"name" => "String",
},
Expand Down
14 changes: 14 additions & 0 deletions features/v1/logs_indexes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ Feature: Logs Indexes
When the request is sent
Then the response status is 200 OK

@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
Scenario: Delete an index returns "Not Found" response
Given new "DeleteLogsIndex" request
And request contains "name" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 404 Not Found

@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
Scenario: Delete an index returns "OK" response
Given new "DeleteLogsIndex" request
And request contains "name" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 200 OK

@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
Scenario: Get all indexes returns "OK" response
Given new "ListLogIndexes" request
Expand Down
6 changes: 6 additions & 0 deletions features/v1/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,12 @@
"type": "unsafe"
}
},
"DeleteLogsIndex": {
"tag": "Logs Indexes",
"undo": {
"type": "idempotent"
}
},
"GetLogsIndex": {
"tag": "Logs Indexes",
"undo": {
Expand Down
66 changes: 66 additions & 0 deletions lib/datadog_api_client/v1/api/logs_indexes_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,72 @@ def create_logs_index_with_http_info(body, opts = {})
return data, status_code, headers
end

# Delete an index.
#
# @see #delete_logs_index_with_http_info
def delete_logs_index(name, opts = {})

Choose a reason for hiding this comment

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

Code Quality Violation

Avoid using a hash as an optional parameter (...read more)

The rule "Avoid hash optional parameters" is a guideline that encourages developers to explicitly declare parameters instead of using a hash for optional parameters. This is because using a hash for optional parameters can make the code harder to understand and maintain. It can also lead to unexpected behavior if a developer accidentally includes a key in the hash that the method does not expect.

This rule is important because it promotes code readability and maintainability. It also helps prevent potential bugs that may occur due to unexpected keys in the optional hash. By explicitly declaring each parameter, developers can easily see what parameters a method expects, making the code easier to read and understand.

To adhere to this rule, instead of using a hash for optional parameters, explicitly declare each parameter in the method definition. For example, instead of using options = {} in the method definition, declare each parameter like name, email, age. This way, anyone reading the code can easily understand what parameters the method expects and in what order.

View in Datadog  Leave us feedback  Documentation

data, _status_code, _headers = delete_logs_index_with_http_info(name, opts)
data
end

# Delete an index.
#
# Delete an existing index from your organization. Index deletions are permanent and cannot be reverted.
# You cannot recreate an index with the same name as deleted ones.
#
# @param name [String] Name of the log index.
# @param opts [Hash] the optional parameters
# @return [Array<(LogsIndex, Integer, Hash)>] LogsIndex data, response status code and response headers
def delete_logs_index_with_http_info(name, opts = {})

Choose a reason for hiding this comment

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

Code Quality Violation

Avoid using a hash as an optional parameter (...read more)

The rule "Avoid hash optional parameters" is a guideline that encourages developers to explicitly declare parameters instead of using a hash for optional parameters. This is because using a hash for optional parameters can make the code harder to understand and maintain. It can also lead to unexpected behavior if a developer accidentally includes a key in the hash that the method does not expect.

This rule is important because it promotes code readability and maintainability. It also helps prevent potential bugs that may occur due to unexpected keys in the optional hash. By explicitly declaring each parameter, developers can easily see what parameters a method expects, making the code easier to read and understand.

To adhere to this rule, instead of using a hash for optional parameters, explicitly declare each parameter in the method definition. For example, instead of using options = {} in the method definition, declare each parameter like name, email, age. This way, anyone reading the code can easily understand what parameters the method expects and in what order.

View in Datadog  Leave us feedback  Documentation


if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: LogsIndexesAPI.delete_logs_index ...'
end
# verify the required parameter 'name' is set
if @api_client.config.client_side_validation && name.nil?
fail ArgumentError, "Missing the required parameter 'name' when calling LogsIndexesAPI.delete_logs_index"
end
# resource path
local_var_path = '/api/v1/logs/config/indexes/{name}'.sub('{name}', CGI.escape(name.to_s).gsub('%2F', '/'))

# query parameters
query_params = opts[:query_params] || {}

# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])

# form parameters
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:debug_body]

# return_type
return_type = opts[:debug_return_type] || 'LogsIndex'

# auth_names
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

new_options = opts.merge(
:operation => :delete_logs_index,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type,
:api_version => "V1"
)

data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: LogsIndexesAPI#delete_logs_index\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

# Get an index.
#
# @see #get_logs_index_with_http_info
Expand Down
Loading