diff --git a/.apigentools-info b/.apigentools-info index 74ae5490daeb..b17c7a4c5da7 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.4.1.dev2", - "regenerated": "2021-01-18 15:23:31.186156", - "spec_repo_commit": "64464cb" + "regenerated": "2021-01-19 08:49:33.978536", + "spec_repo_commit": "8b601c0" }, "v2": { "apigentools_version": "1.4.1.dev2", - "regenerated": "2021-01-18 15:23:43.682621", - "spec_repo_commit": "64464cb" + "regenerated": "2021-01-19 08:49:46.690120", + "spec_repo_commit": "8b601c0" } } } \ No newline at end of file diff --git a/data/v1/openapi.yaml b/data/v1/openapi.yaml index 640aad51cdbe..336e824d48e8 100644 --- a/data/v1/openapi.yaml +++ b/data/v1/openapi.yaml @@ -2910,6 +2910,7 @@ components: daily_limit: description: The number of log events you can send in this index per day before you are rate-limited. + example: 300000000 format: int64 type: integer exclusion_filters: @@ -2930,20 +2931,23 @@ components: logs than the daily limit have been sent. Rate limit is reset every-day at 2pm UTC.' + example: false readOnly: true type: boolean name: description: The name of the index. - readOnly: true + example: main type: string num_retention_days: description: 'The number of days before logs are deleted from this index. Available values depend on retention plans specified in your organization''s contract/subscriptions.' + example: 15 format: int64 type: integer required: + - name - filter type: object LogsIndexListResponse: @@ -12856,6 +12860,47 @@ paths: type: safe x-unstable: '**Note**: This endpoint is in public beta. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Creates a new index. Returns the Index object passed in the request + body when the request is successful. + operationId: CreateLogsIndex + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/LogsIndex' + description: Object containing the new index. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/LogsIndex' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/LogsAPIErrorResponse' + description: Invalid Parameter Error + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + summary: Create an index + tags: + - Logs Indexes + x-codegen-request-body-name: body + x-undo: + operationId: TODO + parameters: [] + type: unsafe + x-unstable: '**Note**: This endpoint is in public beta. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v1/logs/config/indexes/{name}: get: diff --git a/docs/v1/LogsIndex.md b/docs/v1/LogsIndex.md index 7e2ac8cff1bd..33f154ada52c 100644 --- a/docs/v1/LogsIndex.md +++ b/docs/v1/LogsIndex.md @@ -8,7 +8,7 @@ | **exclusion_filters** | [**Array<LogsExclusion>**](LogsExclusion.md) | An array of exclusion objects. The logs are tested against the query of each filter, following the order of the array. Only the first matching active exclusion matters, others (if any) are ignored. | [optional] | | **filter** | [**LogsFilter**](LogsFilter.md) | | | | **is_rate_limited** | **Boolean** | A boolean stating if the index is rate limited, meaning more logs than the daily limit have been sent. Rate limit is reset every-day at 2pm UTC. | [optional][readonly] | -| **name** | **String** | The name of the index. | [optional][readonly] | +| **name** | **String** | The name of the index. | | | **num_retention_days** | **Integer** | The number of days before logs are deleted from this index. Available values depend on retention plans specified in your organization's contract/subscriptions. | [optional] | ## Example @@ -17,12 +17,12 @@ require 'datadog_api_client/v1' instance = DatadogAPIClient::V1::LogsIndex.new( - daily_limit: null, + daily_limit: 300000000, exclusion_filters: null, filter: null, - is_rate_limited: null, - name: null, - num_retention_days: null + is_rate_limited: false, + name: main, + num_retention_days: 15 ) ``` diff --git a/docs/v1/LogsIndexesApi.md b/docs/v1/LogsIndexesApi.md index 65f2a4bbecaf..e7e400bef267 100644 --- a/docs/v1/LogsIndexesApi.md +++ b/docs/v1/LogsIndexesApi.md @@ -4,6 +4,7 @@ All URIs are relative to *https://api.datadoghq.com* | Method | HTTP request | Description | | ------ | ------------ | ----------- | +| [**create_logs_index**](LogsIndexesApi.md#create_logs_index) | **POST** /api/v1/logs/config/indexes | Create an index | | [**get_logs_index**](LogsIndexesApi.md#get_logs_index) | **GET** /api/v1/logs/config/indexes/{name} | Get an index | | [**get_logs_index_order**](LogsIndexesApi.md#get_logs_index_order) | **GET** /api/v1/logs/config/index-order | Get indexes order | | [**list_log_indexes**](LogsIndexesApi.md#list_log_indexes) | **GET** /api/v1/logs/config/indexes | Get all indexes | @@ -11,6 +12,84 @@ All URIs are relative to *https://api.datadoghq.com* | [**update_logs_index_order**](LogsIndexesApi.md#update_logs_index_order) | **PUT** /api/v1/logs/config/index-order | Update indexes order | +## create_logs_index + +> create_logs_index(body) + +Create an index + +Creates a new index. Returns the Index object passed in the request body when the request is successful. + +### Examples + +```ruby +require 'time' +require 'datadog_api_client/v1' +# setup authorization +DatadogAPIClient::V1.configure do |config| + # Configure API key authorization: apiKeyAuth + config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"] + # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) + # config.api_key_prefix['apiKeyAuth'] = 'Bearer' + + # Configure API key authorization: appKeyAuth + config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"] + # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) + # config.api_key_prefix['appKeyAuth'] = 'Bearer' + + config.unstable_operations[:create_logs_index] = true +end + +api_instance = DatadogAPIClient::V1::LogsIndexesApi.new +body = DatadogAPIClient::V1::LogsIndex.new({filter: DatadogAPIClient::V1::LogsFilter.new, name: 'main'}) # LogsIndex | Object containing the new index. + +begin + # Create an index + result = api_instance.create_logs_index(body) + p result +rescue DatadogAPIClient::V1::ApiError => e + puts "Error when calling LogsIndexesApi->create_logs_index: #{e}" +end +``` + +#### Using the create_logs_index_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> create_logs_index_with_http_info(body) + +```ruby +begin + # Create an index + data, status_code, headers = api_instance.create_logs_index_with_http_info(body) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue DatadogAPIClient::V1::ApiError => e + puts "Error when calling LogsIndexesApi->create_logs_index_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **body** | [**LogsIndex**](LogsIndex.md) | Object containing the new index. | | + +### Return type + +[**LogsIndex**](LogsIndex.md) + +### Authorization + +[apiKeyAuth](README.md#apiKeyAuth), [appKeyAuth](README.md#appKeyAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + ## get_logs_index > get_logs_index(name) diff --git a/docs/v1/README.md b/docs/v1/README.md index f93df16bc889..13e7383470cd 100644 --- a/docs/v1/README.md +++ b/docs/v1/README.md @@ -149,6 +149,7 @@ Class | Method | HTTP request | Description *DatadogAPIClient::V1::KeyManagementApi* | [**update_api_key**](KeyManagementApi.md#update_api_key) | **PUT** /api/v1/api_key/{key} | Edit an API key *DatadogAPIClient::V1::KeyManagementApi* | [**update_application_key**](KeyManagementApi.md#update_application_key) | **PUT** /api/v1/application_key/{key} | Edit an application key *DatadogAPIClient::V1::LogsApi* | [**list_logs**](LogsApi.md#list_logs) | **POST** /api/v1/logs-queries/list | Get a list of logs +*DatadogAPIClient::V1::LogsIndexesApi* | [**create_logs_index**](LogsIndexesApi.md#create_logs_index) | **POST** /api/v1/logs/config/indexes | Create an index *DatadogAPIClient::V1::LogsIndexesApi* | [**get_logs_index**](LogsIndexesApi.md#get_logs_index) | **GET** /api/v1/logs/config/indexes/{name} | Get an index *DatadogAPIClient::V1::LogsIndexesApi* | [**get_logs_index_order**](LogsIndexesApi.md#get_logs_index_order) | **GET** /api/v1/logs/config/index-order | Get indexes order *DatadogAPIClient::V1::LogsIndexesApi* | [**list_log_indexes**](LogsIndexesApi.md#list_log_indexes) | **GET** /api/v1/logs/config/indexes | Get all indexes diff --git a/features/v1/logs_indexes.feature b/features/v1/logs_indexes.feature index 943b35a57d19..54ea87bd6db4 100644 --- a/features/v1/logs_indexes.feature +++ b/features/v1/logs_indexes.feature @@ -81,3 +81,19 @@ Feature: Logs Indexes And body {} When the request is sent Then the response status is 429 Too Many Requests + + @generated @skip + Scenario: Create an index returns "OK" response + Given operation "CreateLogsIndex" enabled + And new "CreateLogsIndex" request + And body {} + When the request is sent + Then the response status is 200 OK + + @generated @skip + Scenario: Create an index returns "Invalid Parameter Error" response + Given operation "CreateLogsIndex" enabled + And new "CreateLogsIndex" request + And body {} + When the request is sent + Then the response status is 400 Invalid Parameter Error diff --git a/features/v1/undo.json b/features/v1/undo.json index 073f9a2ed97f..dfcaf2ae837e 100644 --- a/features/v1/undo.json +++ b/features/v1/undo.json @@ -461,6 +461,14 @@ "type": "safe" } }, + "CreateLogsIndex": { + "tag": "Logs Indexes", + "undo": { + "operationId": "TODO", + "parameters": [], + "type": "unsafe" + } + }, "GetLogsIndex": { "tag": "Logs Indexes", "undo": { diff --git a/lib/datadog_api_client/v1/api/logs_indexes_api.rb b/lib/datadog_api_client/v1/api/logs_indexes_api.rb index 0e8fb49ee574..02572bd279ab 100644 --- a/lib/datadog_api_client/v1/api/logs_indexes_api.rb +++ b/lib/datadog_api_client/v1/api/logs_indexes_api.rb @@ -22,6 +22,81 @@ class LogsIndexesApi def initialize(api_client = ApiClient.default) @api_client = api_client end + # Create an index + # Creates a new index. Returns the Index object passed in the request body when the request is successful. + # @param body [LogsIndex] Object containing the new index. + # @param [Hash] opts the optional parameters + # @return [LogsIndex] + def create_logs_index(body, opts = {}) + data, _status_code, _headers = create_logs_index_with_http_info(body, opts) + data + end + + # Create an index + # Creates a new index. Returns the Index object passed in the request body when the request is successful. + # @param body [LogsIndex] Object containing the new index. + # @param [Hash] opts the optional parameters + # @return [Array<(LogsIndex, Integer, Hash)>] LogsIndex data, response status code and response headers + def create_logs_index_with_http_info(body, opts = {}) + + if @api_client.config.unstable_operations.has_key?(:create_logs_index) + unstable_enabled = @api_client.config.unstable_operations[:create_logs_index] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "create_logs_index") + else + raise ApiError.new(message: format("Unstable operation '%s' is disabled", "create_logs_index")) + end + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LogsIndexesApi.create_logs_index ...' + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling LogsIndexesApi.create_logs_index" + end + # resource path + local_var_path = '/api/v1/logs/config/indexes' + + # 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']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(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 => :"LogsIndexesApi.create_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 + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LogsIndexesApi#create_logs_index\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get an index # Get one log index from your organization. This endpoint takes no JSON arguments. # @param name [String] Name of the log index. diff --git a/lib/datadog_api_client/v1/configuration.rb b/lib/datadog_api_client/v1/configuration.rb index 51ca48006098..b5d9f9880442 100644 --- a/lib/datadog_api_client/v1/configuration.rb +++ b/lib/datadog_api_client/v1/configuration.rb @@ -165,6 +165,7 @@ def initialize @force_ending_format = false @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT) @unstable_operations = { + create_logs_index: false, get_logs_index: false, get_logs_index_order: false, list_log_indexes: false, diff --git a/lib/datadog_api_client/v1/models/logs_index.rb b/lib/datadog_api_client/v1/models/logs_index.rb index e8582e8f06a4..b2a517eda46c 100644 --- a/lib/datadog_api_client/v1/models/logs_index.rb +++ b/lib/datadog_api_client/v1/models/logs_index.rb @@ -121,6 +121,10 @@ def list_invalid_properties invalid_properties.push('invalid value for "filter", filter cannot be nil.') end + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + invalid_properties end @@ -128,6 +132,7 @@ def list_invalid_properties # @return true if the model is valid def valid? return false if @filter.nil? + return false if @name.nil? true end