-
Notifications
You must be signed in to change notification settings - Fork 21
Add delete log index to public API #2273
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 = {}) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ Code Quality ViolationAvoid 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 |
||
| 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 = {}) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ Code Quality ViolationAvoid 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 |
||
|
|
||
| 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 | ||
|
|
||
There was a problem hiding this comment.
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 }tovalues = { 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.