diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index 9d7d6533c..ba804e74b 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: false matrix: - cluster-version: [ "1.0.0", "1.0.1", "1.1.0", "1.2.0", "1.2.1", "1.2.2", "1.2.3", "1.2.4", "1.3.0", "1.3.1", "2.0.0" ] + cluster-version: [ "1.3.3", "2.0.1", "2.18.0" ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -52,7 +52,7 @@ jobs: strategy: fail-fast: false matrix: - cluster-version: [ "1.0.0", "1.0.1", "1.1.0", "1.2.0", "1.2.1", "1.2.2", "1.2.3", "1.2.4", "1.3.0", "1.3.1", "1.3.2", "1.3.3", "2.0.0", "2.0.1" ] + cluster-version: [ "1.3.3", "2.0.1" ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/generate_api.yml b/.github/workflows/generate_api.yml new file mode 100644 index 000000000..5adece204 --- /dev/null +++ b/.github/workflows/generate_api.yml @@ -0,0 +1,63 @@ +name: Generate API from Spec +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * 0" # Every Sunday at midnight GMT +jobs: + generate-api: + if: ${{ github.repository == 'opensearch-project/opensearch-ruby' }} + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./api_generator + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + + - name: Config git to rebase + run: git config --global pull.rebase true + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1 + + - name: Update bundler + run: | + sudo apt-get update + bundle install + + - name: Generate API + run: |- + bundle exec rake download_spec + bundle exec rake generate_api + + - name: Get current date + id: date + run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV + + - name: GitHub App token + id: github_app_token + uses: tibdex/github-app-token@v2.1.0 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + + - name: Create pull request + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ steps.github_app_token.outputs.token }} + commit-message: "Updated opensearch-ruby to reflect the latest OpenSearch API spec (${{ env.date }})" + title: "[AUTOCUT] Update opensearch-ruby to reflect the latest OpenSearch API spec (${{ env.date }})" + body: | + Update `opensearch-ruby` to reflect the latest [OpenSearch API spec](https://github.com/opensearch-project/opensearch-api-specification/releases/download/main-latest/opensearch-openapi.yaml). + Date: ${{ env.date }} + branch: update-api-from-spec-${{ env.date }} + base: main + signoff: true + labels: | + autocut \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8ba6e705f..f69147b29 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [ 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, jruby-9.3 ] + ruby: [ 3.0, 3.3, jruby-9.4 ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -52,7 +52,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [ 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, jruby-9.3 ] + ruby: [ 3.0, 3.3, jruby-9.4 ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -85,7 +85,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [ 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, jruby-9.3 ] + ruby: [ 3.0, 3.3, jruby-9.4 ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/test-unreleased.yml b/.github/workflows/test-unreleased.yml index b7a98e873..036bc2e49 100644 --- a/.github/workflows/test-unreleased.yml +++ b/.github/workflows/test-unreleased.yml @@ -14,6 +14,9 @@ on: jobs: test: + env: + TEST_OPENSEARCH_SERVER: http://localhost:9200 + PORT: 9200 runs-on: ubuntu-latest strategy: fail-fast: false @@ -98,7 +101,7 @@ jobs: bundle install working-directory: ruby-client - - name: opensearch-ruby + - name: Perform Integration Tests working-directory: ruby-client run: rake test:integration diff --git a/.gitignore b/.gitignore index ce18b3186..4a8006a0a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ coverage docs/ rdoc/ tmp -Gemfile.lock +/Gemfile.lock .DS_Store *.log .idea/* @@ -16,5 +16,5 @@ profile/**/data/*.json .byebug_history dist/ gem-private_key.pem -.ruby-version +/.ruby-version */.idea/** \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml index 36aee0a62..8f8c843f7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,7 +5,7 @@ require: - rubocop-rspec AllCops: - TargetRubyVersion: 2.5 + TargetRubyVersion: 3.0 NewCops: enable Exclude: - 'api_generator/**/*' @@ -36,3 +36,6 @@ Layout/FirstArgumentIndentation: Layout/FirstArrayElementIndentation: Enabled: false + +Layout/LineLength: + Enabled: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f5101a9d..07e4229a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,15 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Fixed ### Security +## [4.0.0] +### Added +- Added an API Generator ([#233](https://github.com/opensearch-project/opensearch-ruby/issues/233)) +- Added a workflow to generate API methods from OpenSearch API Spec +### Changed +- Restructured the API methods and modules to be more efficient and intuitive +### Deprecated +- Removed support for Ruby 2.x + ## [3.4.0] ### Added - Added `script_score` to Query DSL ([#254](https://github.com/opensearch-project/opensearch-ruby/pull/254)) diff --git a/Gemfile b/Gemfile index 1edfa3201..f25884b2f 100644 --- a/Gemfile +++ b/Gemfile @@ -28,6 +28,7 @@ source 'https://rubygems.org' gem 'opensearch-ruby', path: __dir__, require: false +gem 'activesupport' gem 'ansi' gem 'bundler' gem 'cane' diff --git a/UPGRADING.md b/UPGRADING.md index 100100134..ba478ab6e 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,6 +1,10 @@ # Upgrading Major versions of OpenSearch introduce breaking changes that require careful upgrades of the client. Check the [Compatibility](COMPATIBILITY.md) doc to see which version of the client should be used against your OpenSearch cluster. +### Upgrade to OpenSearch Ruby 4 +OpenSearch Ruby 4 drops support for Ruby 2.x. If you are using Ruby 2.x, you should upgrade to Ruby 3.x before upgrading to OpenSearch Ruby 4. + + ### Upgrade to OpenSearch Ruby 3 In Version 3 of the OpenSearch Ruby client, we have added the `api` and `transport` modules as the core components of the gem, instead of treating them as separate gems that are required by the `opensearch-ruby` gem. This removes the confusions around compatibility between the ruby client, its legacy dependencies, and the OpenSearch cluster. diff --git a/api_generator/.gitignore b/api_generator/.gitignore new file mode 100644 index 000000000..b130e6080 --- /dev/null +++ b/api_generator/.gitignore @@ -0,0 +1 @@ +opensearch-openapi.yaml diff --git a/api_generator/.rubocop.yml b/api_generator/.rubocop.yml new file mode 100644 index 000000000..183c5273d --- /dev/null +++ b/api_generator/.rubocop.yml @@ -0,0 +1,19 @@ +require: rubocop-rake +AllCops: + Include: + - 'lib/**/*.rb' + - 'Rakefile' + NewCops: enable + +Metrics/CyclomaticComplexity: + Enabled: false +Metrics/MethodLength: + Enabled: false +Metrics/AbcSize: + Enabled: false +Metrics/PerceivedComplexity: + Enabled: false +Layout/EmptyLineAfterGuardClause: + Enabled: false +Style/MultilineBlockChain: + Enabled: false \ No newline at end of file diff --git a/api_generator/.ruby-version b/api_generator/.ruby-version new file mode 100644 index 000000000..a0cd9f0cc --- /dev/null +++ b/api_generator/.ruby-version @@ -0,0 +1 @@ +3.1.0 \ No newline at end of file diff --git a/api_generator/Rakefile b/api_generator/Rakefile new file mode 100644 index 000000000..4c8552338 --- /dev/null +++ b/api_generator/Rakefile @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +require 'rake' +require 'active_support/all' + +task :download_spec do + sh 'curl -L -X GET "https://github.com/opensearch-project/opensearch-api-specification/releases/download/main-latest/opensearch-openapi.yaml" -o opensearch-openapi.yaml' +end + + +task :generate_api do + require './lib/generator' + generator = Generator.new('./opensearch-openapi.yaml', '../') + generator.generate +end diff --git a/api_generator/gemfile b/api_generator/gemfile new file mode 100644 index 000000000..1dad3d35f --- /dev/null +++ b/api_generator/gemfile @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +source 'https://rubygems.org' + +gem 'rake' +gem 'rubocop', '~> 1.44', require: false +gem 'rubocop-rspec', require: false +gem 'rubocop-rake', require: false +gem 'mustache', '~> 1' +gem 'activesupport', '~> 7' diff --git a/api_generator/gemfile.lock b/api_generator/gemfile.lock new file mode 100644 index 000000000..c9cbd6029 --- /dev/null +++ b/api_generator/gemfile.lock @@ -0,0 +1,71 @@ +GEM + remote: https://rubygems.org/ + specs: + activesupport (7.2.1) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + logger (>= 1.4.2) + minitest (>= 5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + ast (2.4.2) + base64 (0.2.0) + bigdecimal (3.1.8) + concurrent-ruby (1.3.4) + connection_pool (2.4.1) + drb (2.2.1) + i18n (1.14.6) + concurrent-ruby (~> 1.0) + json (2.7.2) + language_server-protocol (3.17.0.3) + logger (1.6.1) + minitest (5.25.1) + mustache (1.1.1) + parallel (1.26.3) + parser (3.3.5.0) + ast (~> 2.4.1) + racc + racc (1.8.1) + rainbow (3.1.1) + rake (13.2.1) + regexp_parser (2.9.2) + rubocop (1.66.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.32.3) + parser (>= 3.3.1.0) + rubocop-rake (0.6.0) + rubocop (~> 1.0) + rubocop-rspec (2.11.1) + rubocop (~> 1.19) + ruby-progressbar (1.13.0) + securerandom (0.3.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.6.0) + +PLATFORMS + ruby + x86_64-darwin-22 + +DEPENDENCIES + activesupport (~> 7) + mustache (~> 1) + rake + rubocop (~> 1.44) + rubocop-rake + rubocop-rspec + +BUNDLED WITH + 2.5.3 diff --git a/api_generator/lib/_generated_code_warning.txt b/api_generator/lib/_generated_code_warning.txt new file mode 100644 index 000000000..d817119a6 --- /dev/null +++ b/api_generator/lib/_generated_code_warning.txt @@ -0,0 +1,2 @@ +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. \ No newline at end of file diff --git a/api_generator/lib/_license_header.txt b/api_generator/lib/_license_header.txt new file mode 100644 index 000000000..ff4fd04d1 --- /dev/null +++ b/api_generator/lib/_license_header.txt @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. diff --git a/api_generator/lib/components/action.rb b/api_generator/lib/components/action.rb new file mode 100644 index 000000000..64f6b97e8 --- /dev/null +++ b/api_generator/lib/components/action.rb @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +require_relative 'argument' + +# A collection of operations that comprise a single API Action +# AKA operation-group +class Action + # @return [Array] Operations in the action + attr_reader :operations + + # @param [Array] operations + def initialize(operations) + @operations = operations + @operation = operations.first + @spec = @operation&.spec + end + + # @return [Array] Input arguments. + def arguments; @arguments ||= Argument.from_operations(@operations.map(&:spec)); end + + # @return [Argument, NilClass] Request Body argument + def body; @body ||= arguments.find { |arg| arg.name == 'body' }; end + + # @return [Array] Path Param arguments + def path_params; @path_params ||= arguments.select { |arg| arg.location == 'path' }; end + + # @return [Array] Query Param arguments + def query_params; @query_params ||= arguments.select { |arg| arg.location == 'query' }; end + + # @return [String] Full name of the action (i.e. x-operation-group) + def full_name; @operation&.group; end + + # return [String] Name of the action + def name; @operation&.action; end + + # @return [String] Namespace of the action + def namespace; @operation&.namespace; end + + # @return [Array] Sorted unique HTTP verbs + def http_verbs; @operations.map(&:http_verb).uniq.sort; end + + # @return [Array] Unique URLs + def urls; @operations.map(&:url).uniq; end + + # @return [String] Description of the action + def description; @spec&.description || ''; end + + # @return [Boolean] Whether the action is deprecated + def deprecated; @spec&.deprecated || false; end + + # @return [String] Deprecation message + def deprecation_message; @spec['x-deprecation-message']; end + + # @return [String, NilClass] API reference + def api_reference; @operation&.spec&.external_docs&.url; end +end diff --git a/api_generator/lib/components/api_path.rb b/api_generator/lib/components/api_path.rb new file mode 100644 index 000000000..5876bd86f --- /dev/null +++ b/api_generator/lib/components/api_path.rb @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +class ApiPath + # @param [String] url + def initialize(url) + @url = url + end + + def build + return "'/'" if components.empty? + return components.join('/') if components.none? { |comp| comp.start_with?('_') } + "[#{components.join(', ')}].filter(&:present?).join('/').squeeze('/')" + end + + def components + @components ||= @url.split('{').flat_map { |part| part.split('}') }.map do |comp| + next "_#{comp}" unless comp.include?('/') # path param + comp = comp.sub(%r{^/}, '').sub(%r{/$}, '') # remove leading/trailing slashes + "'#{comp}'" if comp.present? + end.compact + end + + private +end \ No newline at end of file diff --git a/api_generator/lib/components/argument.rb b/api_generator/lib/components/argument.rb new file mode 100644 index 000000000..468d52cee --- /dev/null +++ b/api_generator/lib/components/argument.rb @@ -0,0 +1,108 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +# Represents an argument to an API action +class Argument + # @return [String] The name of the argument + attr_reader :name + # @return [String] The description of the argument + attr_reader :description + # @return [Boolean] Whether the argument is required + attr_reader :required + # @return [SpecHash] The JSON schema of the argument + attr_reader :schema + # @return [String] Argument type in Ruby + attr_reader :type + # @return [String] The default value of the argument + attr_reader :default + # @return [Boolean] Whether the argument is deprecated + attr_reader :deprecated + # @return [String] The deprecation message + attr_reader :deprecation_message + # @return [ArgLocation] The location of the argument + attr_reader :location + + def initialize(name:, description:, required:, schema:, default:, deprecated:, deprecation_message:, location:) + @name = name + @description = description + @required = required + @schema = schema + @type = get_ruby_type(schema) + @default = default + @deprecated = deprecated + @deprecation_message = deprecation_message + @location = location + end + + # @param [SpecHash | nil] schema + # @return [String | nil] Ruby type + def get_ruby_type(schema) + return nil if schema.nil? + union = schema.anyOf || schema.oneOf + return union.map { |sch| get_ruby_type(sch) }.uniq.sort.join(', ') unless union.nil? + return 'Integer' if schema.type == 'integer' + return 'Float' if schema.type == 'number' + return 'Boolean' if schema.type == 'boolean' + return 'String' if schema.type == 'string' + return 'NilClass' if schema.type == 'null' + return "Enumerable<#{get_ruby_type(schema.items)}>" if schema.type == 'array' + "Hash" + end + + # @param [SpecHash] Full OpenAPI spec + def self.set_global(spec) + @global = spec.components.parameters.filter { |_, p| p['x-global'] }.map { |_, p| from_parameters([p], 1) } + end + + # @return [Array] Global arguments + def self.global + raise 'Global arguments not set' unless @global + @global + end + + # @param [Array] operations + # @return [Array] + def self.from_operations(operations) + parameters = operations.flat_map(&:parameters).filter { |param| !param['x-global'] } + .group_by(&:name).values.map { |params| from_parameters(params, operations.size) } + body = from_request_bodies(operations.map(&:requestBody)) + (parameters + [body]).compact + end + + # @param [Array] params + # @param [Integer] opts_count + # @return [Argument] + def self.from_parameters(params, opts_count) + param = params.first || SpecHash.new + schema = param&.schema || SpecHash.new + Argument.new(name: param.name, + description: param.description || schema.description, + required: params.filter(&:required).size >= opts_count, + schema: schema, + default: param.default || schema.default, + deprecated: param.deprecated || schema.deprecated, + deprecation_message: param['x-deprecation-message'] || schema['x-deprecation-message'], + location: params.any? { |p| p.in == 'path' } ? 'path' : 'query') + end + + # @param [Array] bodies + # @return [Argument | nil] + def self.from_request_bodies(bodies) + body = bodies.compact.find { |body| !body.nil? } + return if body.nil? + schema = body.content['application/json']&.schema || body.content['application/x-ndjson']&.schema || SpecHash.new + Argument.new(name: 'body', + description: body.description || schema.description, + required: bodies.all?(&:required), + schema: schema, + default: nil, + deprecated: body.deprecated || schema.deprecated, + deprecation_message: body['x-deprecation-message'] || schema&.[]('x-deprecation-message'), + location: 'body') + end +end diff --git a/api_generator/lib/components/namespace.rb b/api_generator/lib/components/namespace.rb new file mode 100644 index 000000000..d058e9b03 --- /dev/null +++ b/api_generator/lib/components/namespace.rb @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +require_relative 'action' +require_relative 'operation' + +# A collection of API actions that comprise a single API Namespace +class Namespace + # @return [String] Namespace name + attr_reader :name + # @return [Array] Actions in the namespace + attr_reader :actions + # @return [Boolean] whether this is the root namespace + attr_reader :root + + # @param [Array] actions + def initialize(actions) + @name = actions.first&.namespace || '' + @actions = actions + @root = name == '' + end + + # @param [SpecHash] Parsed OpenAPI spec + def self.set_namespaces(spec) + operations = spec.paths.flat_map do |url, ops| + ops.filter_map { |verb, op| Operation.new(op, url, verb) unless op['x-ignorable'] } + end + actions = operations.group_by(&:group).values.map { |ops| Action.new(ops) } + @namespaces = actions.group_by(&:namespace).values.map { |acts| Namespace.new(acts) } + end + + + # @return [Array] Namespaces + def self.namespaces + raise 'Namespaces not set' unless @namespaces + @namespaces + end +end diff --git a/api_generator/lib/components/operation.rb b/api_generator/lib/components/operation.rb new file mode 100644 index 000000000..6f9fb44cc --- /dev/null +++ b/api_generator/lib/components/operation.rb @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +# An API Operation +class Operation + # @return [Openapi3Parser::Node::Operation] Operation Spec + attr_reader :spec + # @return [String] URL + attr_reader :url + # @return [String] HTTP Verb + attr_reader :http_verb + # @return [String] Operation Group + attr_reader :group + # @return [String] API Action + attr_reader :action + # @return [String] API Namespace + attr_reader :namespace + + # @param [Openapi3Parser::Node::Operation] spec Operation Spec + # @param [String] url + # @param [String] http_verb + def initialize(spec, url, http_verb) + @spec = spec + @url = url + @http_verb = http_verb.upcase + @group = spec['x-operation-group'] + @action, @namespace = @group.split('.').reverse + end +end diff --git a/api_generator/lib/generator.rb b/api_generator/lib/generator.rb new file mode 100644 index 000000000..48b75c951 --- /dev/null +++ b/api_generator/lib/generator.rb @@ -0,0 +1,56 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +require_relative 'spec_hash' +require_relative './components/namespace' +require_relative './generators/action_generator' +require_relative './generators/api_generator' +require_relative './generators/client_generator' + +# Generate API endpoints for OpenSearch Ruby client +class Generator + # @return [Pathname] API Folder where the generated API files will be stored + attr :api_folder + + # @param [String] spec_path location of the OpenSearch API spec file + # @param [String] gem_folder location of the root folder of the OpenSearch Ruby Gem + def initialize(spec_path, gem_folder = '../') + @gem_folder = Pathname(gem_folder) + SpecHash.load_file(spec_path) + end + + def generate + make_folders + generate_apis + end + + def make_folders + action_folder = @gem_folder.join('lib', 'opensearch', 'api', 'actions') + recreate_folder action_folder + Namespace.namespaces.filter { |ns| !ns.root }.each do |namespace| + recreate_folder action_folder.join(namespace.name) + end + end + + def generate_apis + Namespace.namespaces.each do |namespace| + namespace.actions.each do |action| + ActionRenderer.new(@gem_folder, namespace, action).generate + end + end + ApiGenerator.new(@gem_folder).generate + ClientGenerator.new(@gem_folder, Namespace.namespaces).generate + end + + private + + def recreate_folder(pathname) + pathname.rmtree if pathname.exist? + pathname.mkpath + end +end diff --git a/api_generator/lib/generators/action_generator.rb b/api_generator/lib/generators/action_generator.rb new file mode 100644 index 000000000..b3edb521d --- /dev/null +++ b/api_generator/lib/generators/action_generator.rb @@ -0,0 +1,95 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +require_relative 'base_generator' +require_relative '../components/action' +require_relative '../components/api_path' + +# Render an API Action via Mustache +class ActionRenderer < BaseGenerator + self.template_file = './lib/templates/action.mustache' + attr_reader :module_name, :method_name, :valid_params_constant_name, + :method_description, :argument_descriptions, :api_reference + + # @param [Pathname] gem_folder + # @param [Namespace] namespace + # @param [Action] action + def initialize(gem_folder, namespace, action) + output_file = gem_folder.join('lib', 'opensearch', 'api', 'actions', namespace.name, "#{action.name.underscore}.rb") + super(output_file) + @action = action + @api_reference = action.api_reference + @module_name = namespace.root ? 'Root' : namespace.name.camelize + @method_name = action.name.underscore + @valid_params_constant_name = "#{action.name.upcase}_QUERY_PARAMS" + @method_description = action.description.squeeze("\n").gsub("\n", "\n # ") + end + + def argument_descriptions + @action.arguments.map do |arg| + { data_type: arg.type, + name: arg.name, + required: arg.required, + description: arg.description&.gsub("\n", ' ')&.strip, + default: arg.default, + deprecated: arg.deprecated } + end + end + + def url + api_path = ApiPath.new(@action.urls.max_by(&:length)) + api_path.build + end + + def has_query + @action.query_params.any? + end + + def http_verb + case @action.http_verbs.sort + when %w[GET POST] + "body ? 'POST' : 'GET'" + when %w[POST PUT] + optional = @action.path_params.find { |arg| arg.required == false } + return "'POST'" unless optional + "_#{optional.name}.present? ? 'PUT' : 'POST'" + else + "'#{@action.http_verbs.first}'" + end + end + + def required_args + @action.arguments.filter(&:required).map { |arg| { arg: arg.name } } + .tap { |args| args.last&.[]=('_blank_line', true) } + end + + def bulk_body + @action.arguments.find { |arg| arg.name == 'body' }&.schema&.type == 'array' + end + + def support_ignore + @action.http_verbs == %w[DELETE] + end + + def path_params + @action.path_params.map { |arg| { name: arg.name } } + .tap { |args| args.last&.[]=('_blank_line', true) } + end + + def query_params + @action.query_params.map { |arg| { name: arg.name } } + end + + def perform_request + args = 'method, url, args, body, headers' + return "transport.perform_ping_request #{args}" if @action.full_name == 'ping' + return "transport.perform_head_request #{args}" if @action.http_verbs == %w[HEAD] + return "transport.perform_delete_request #{args}, ignore.include?(404)" if @action.http_verbs == %w[DELETE] + "transport.perform_request(#{args}).body" + end +end diff --git a/api_generator/lib/generators/api_generator.rb b/api_generator/lib/generators/api_generator.rb new file mode 100644 index 000000000..507fce982 --- /dev/null +++ b/api_generator/lib/generators/api_generator.rb @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +require_relative 'base_generator' +require_relative '../components/argument' + +# Generate the API index file +class ApiGenerator < BaseGenerator + self.template_file = './lib/templates/api.mustache' + + # @param [Pathname] gem_folder + def initialize(gem_folder) + super(gem_folder.join('lib', 'opensearch', 'api.rb')) + end + + def global_query_params + max_length = Argument.global.map { |arg| arg.name.length }.max + Argument.global.map do |arg| + { name: arg.name, + description: arg.description, + space: ' ' * (max_length - arg.name.length + 4), + comma: ',' } + end.tap { |args| args.last[:comma] = ' ' } + end +end diff --git a/api_generator/lib/generators/base_generator.rb b/api_generator/lib/generators/base_generator.rb new file mode 100644 index 000000000..537c52e4c --- /dev/null +++ b/api_generator/lib/generators/base_generator.rb @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +require 'mustache' +require 'active_support/all' + +# Base Mustache Renderer +class BaseGenerator < Mustache + self.template_path = './lib/templates' + + def initialize(output_file) + @output_file = output_file + super + end + + def license_header + Pathname('./lib/_license_header.txt').read + end + + def generated_code_warning + Pathname('./lib/_generated_code_warning.txt').read + end + + def generate + @output_file.write(render) + end +end diff --git a/api_generator/lib/generators/client_generator.rb b/api_generator/lib/generators/client_generator.rb new file mode 100644 index 000000000..1f46cf0b8 --- /dev/null +++ b/api_generator/lib/generators/client_generator.rb @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +require_relative 'base_generator' +require_relative '../components/argument' + +# Generate the index file via Mustache +class ClientGenerator < BaseGenerator + self.template_file = './lib/templates/client.mustache' + attr_reader :namespaces + + # @param [Pathname] gem_folder + # @param [Array] namespaces + def initialize(gem_folder, namespaces) + super(gem_folder.join('lib', 'opensearch.rb')) + @namespaces = namespaces.filter { |ns| !ns.root } + .map(&:name) + .sort + .map { |name| { name: name, module: name.camelcase } } + @namespaces.push(name: 'http', module: 'Http') + end +end diff --git a/api_generator/lib/spec_hash.rb b/api_generator/lib/spec_hash.rb new file mode 100644 index 000000000..4b8e1c544 --- /dev/null +++ b/api_generator/lib/spec_hash.rb @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +require 'yaml' +require_relative 'components/namespace' +require_relative 'components/argument' + +class SpecHash + def self.load_file(file_path) + @raw = YAML.load_file(file_path) + @parsed = SpecHash.new(@raw, parsed: false) + Namespace.set_namespaces(@parsed) + Argument.set_global(@parsed) + end + + # @return [Hash] Raw OpenAPI Spec + class << self; attr_reader :raw; end + + # @return [Spec] Parsed OpenAPI Spec + class << self; attr_reader :parsed; end + + attr_reader :hash + + # @param [Hash] hash + def initialize(hash = {}, parsed: true) + @hash = parsed ? hash : parse(hash) + end + + def [](key) + parse(@hash[key]) + end + + def respond_to_missing?(name, include_private = false) + @hash.key?(name.to_s) || @hash.respond_to?(name) || super + end + + def method_missing(name, ...) + return @hash.send(name, ...) if @hash.respond_to?(name) + parse(@hash[name.to_s]) + end + + private + + def parse(value) + return value.map { |v| parse(v) } if value.is_a?(Array) + return value unless value.is_a?(Hash) + ref = value.delete('$ref') + value.transform_values! { |v| parse(v) } + return SpecHash.new(value) unless ref + SpecHash.new(parse(resolve(ref)).merge(value)) + end + + def resolve(ref) + parts = ref.split('/') + parts.shift + self.class.raw.dig(*parts) + end +end diff --git a/api_generator/lib/templates/action.mustache b/api_generator/lib/templates/action.mustache new file mode 100644 index 000000000..d590c7c42 --- /dev/null +++ b/api_generator/lib/templates/action.mustache @@ -0,0 +1,64 @@ +{{{license_header}}} +{{{generated_code_warning}}} + +# frozen_string_literal: true + +module OpenSearch + module API + module {{module_name}} + module Actions + # {{{method_description}}} + # + {{#argument_descriptions}} + # @option args [{{{data_type}}}] :{{{name}}}{{#required}} *Required*{{/required}}{{#deprecated}} DEPRECATED{{/deprecated}}{{#default}} (default: {{{default}}}){{/default}}{{#description}} {{{description}}}{{/description}} + {{/argument_descriptions}} + {{#support_ignore}} + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + {{/support_ignore}} + {{#api_reference}} + # + # {API Reference}[{{{api_reference}}}] + {{/api_reference}} + def {{method_name}}(args = {}) + args = Utils.normalize_arguments(args) + {{#required_args}} + raise ArgumentError, "Required argument '{{arg}}' missing" unless args['{{arg}}'] + {{#_blank_line}} + + {{/_blank_line}} + {{/required_args}} + {{#path_params}} + _{{{name}}} = args.delete('{{name}}') + {{#_blank_line}} + + {{/_blank_line}} + {{/path_params}} + {{#support_ignore}} + ignore = args.delete('ignore') || [] + {{/support_ignore}} + {{#bulk_body}} + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + {{/bulk_body}} + {{^bulk_body}} + headers = args.delete('headers') || {} + body = args.delete('body') + {{/bulk_body}} + method = {{{http_verb}}} + url = {{{url}}} + + Utils.validate_query_params args{{#has_query}}, {{valid_params_constant_name}}{{/has_query}} + {{{perform_request}}} + end + {{#has_query}} + + {{{valid_params_constant_name}}} = Set.new(%w[ + {{#query_params}} + {{{name}}} + {{/query_params}} + ]).freeze + {{/has_query}} + end + end + end +end diff --git a/api_generator/lib/templates/api.mustache b/api_generator/lib/templates/api.mustache new file mode 100644 index 000000000..7e7c815f3 --- /dev/null +++ b/api_generator/lib/templates/api.mustache @@ -0,0 +1,24 @@ +{{{license_header}}} +{{{generated_code_warning}}} + +# frozen_string_literal: true + +module OpenSearch + module API + GLOBAL_QUERY_PARAMS = Set.new([ + {{#global_query_params}} + '{{name}}'{{comma}}{{space}}# {{{description}}} + {{/global_query_params}} + ]).freeze + + DEFAULT_SERIALIZER = MultiJson + + def self.serializer + settings[:serializer] || DEFAULT_SERIALIZER + end + + def self.settings + @settings ||= {} + end + end +end diff --git a/api_generator/lib/templates/client.mustache b/api_generator/lib/templates/client.mustache new file mode 100644 index 000000000..b3ba74aa4 --- /dev/null +++ b/api_generator/lib/templates/client.mustache @@ -0,0 +1,24 @@ +{{{license_header}}} +{{{generated_code_warning}}} + +require 'active_support/all' +require 'opensearch/transport' +require 'opensearch/api' +Dir[File.expand_path('opensearch/api/**/*.rb', __dir__)].each { |f| require f } + +module OpenSearch + class Client + include OpenSearch::API::Root::Actions + attr_accessor :transport + + def initialize(arguments = {}, &block) + @transport = OpenSearch::Transport::Client.new(arguments, &block) + end + {{#namespaces}} + + def {{name}} + @{{{name}}} ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::{{module}}::Actions) + end + {{/namespaces}} + end +end diff --git a/lib/opensearch.rb b/lib/opensearch.rb index 3ea553b16..b499d4d52 100644 --- a/lib/opensearch.rb +++ b/lib/opensearch.rb @@ -3,99 +3,138 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require 'opensearch/version' + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +require 'active_support/all' require 'opensearch/transport' require 'opensearch/api' +Dir[File.expand_path('opensearch/api/**/*.rb', __dir__)].each { |f| require f } module OpenSearch - SECURITY_PRIVILEGES_VALIDATION_WARNING = 'The client is unable to verify distribution due to security privileges on the server side. Some functionality may not be compatible if the server is running an unsupported product.'.freeze - NOT_SUPPORTED_WARNING = 'The client is not supported for the provided version and distribution combination.'.freeze - class Client - include OpenSearch::API + include OpenSearch::API::Root::Actions attr_accessor :transport - # See OpenSearch::Transport::Client for initializer parameters def initialize(arguments = {}, &block) - @verified = false @transport = OpenSearch::Transport::Client.new(arguments, &block) end - def method_missing(name, *args, &block) - return super unless name == :perform_request - verify_open_search unless @verified - @transport.perform_request(*args, &block) + def asynchronous_search + @asynchronous_search ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::AsynchronousSearch::Actions) end - def respond_to_missing?(method_name, include_private = false) - method_name == :perform_request || super + def cat + @cat ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Cat::Actions) end - private + def cluster + @cluster ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Cluster::Actions) + end - def verify_open_search - begin - response = open_search_validation_request - rescue OpenSearch::Transport::Transport::Errors::Unauthorized, - OpenSearch::Transport::Transport::Errors::Forbidden - @verified = true - warn(SECURITY_PRIVILEGES_VALIDATION_WARNING) - return - end + def dangling_indices + @dangling_indices ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::DanglingIndices::Actions) + end - body = if response.headers['content-type'] == 'application/yaml' - require 'yaml' - YAML.safe_load(response.body) - else - response.body - end - version = body.dig('version', 'number') - distribution = body.dig('version', 'distribution') - verify_version_and_distribution(version, distribution) + def flow_framework + @flow_framework ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::FlowFramework::Actions) end - def verify_version_and_distribution(version, distribution) - raise OpenSearch::UnsupportedProductError if version.nil? + def indices + @indices ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Indices::Actions) + end - # The client supports all the versions of OpenSearch - if distribution != 'opensearch' && - (Gem::Version.new(version) < Gem::Version.new('6.0.0') || - Gem::Version.new(version) >= Gem::Version.new('8.0.0')) - raise OpenSearch::UnsupportedProductError - end + def ingest + @ingest ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Ingest::Actions) + end - @verified = true + def insights + @insights ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Insights::Actions) end - def open_search_validation_request - @transport.perform_request('GET', '/') + def ism + @ism ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Ism::Actions) + end + + def knn + @knn ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Knn::Actions) + end + + def list + @list ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::List::Actions) + end + + def ml + @ml ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Ml::Actions) + end + + def nodes + @nodes ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Nodes::Actions) + end + + def notifications + @notifications ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Notifications::Actions) + end + + def observability + @observability ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Observability::Actions) + end + + def ppl + @ppl ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Ppl::Actions) + end + + def query + @query ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Query::Actions) + end + + def remote_store + @remote_store ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::RemoteStore::Actions) + end + + def replication + @replication ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Replication::Actions) + end + + def rollups + @rollups ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Rollups::Actions) + end + + def search_pipeline + @search_pipeline ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::SearchPipeline::Actions) + end + + def security + @security ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Security::Actions) + end + + def sm + @sm ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Sm::Actions) + end + + def snapshot + @snapshot ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Snapshot::Actions) + end + + def sql + @sql ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Sql::Actions) + end + + def tasks + @tasks ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Tasks::Actions) + end + + def transforms + @transforms ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Transforms::Actions) + end + + def wlm + @wlm ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Wlm::Actions) end - end - class UnsupportedProductError < StandardError - def initialize(message = NOT_SUPPORTED_WARNING) - super(message) + def http + @http ||= OpenSearch::API::Namespace.new(transport, OpenSearch::API::Http::Actions) end end end diff --git a/lib/opensearch/api.rb b/lib/opensearch/api.rb index fcd9c8826..5f55ec102 100644 --- a/lib/opensearch/api.rb +++ b/lib/opensearch/api.rb @@ -3,100 +3,28 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true -require 'opensearch/api/namespace/common' -require 'opensearch/api/utils' -require 'opensearch/api/actions/params_registry' - -Dir[File.expand_path('api/actions/**/params_registry.rb', __dir__)].sort.each { |f| require f } -Dir[File.expand_path('api/actions/**/*.rb', __dir__)].sort.each { |f| require f } -Dir[File.expand_path('api/namespace/**/*.rb', __dir__)].sort.each { |f| require f } - module OpenSearch module API - DEFAULT_SERIALIZER = MultiJson + GLOBAL_QUERY_PARAMS = Set.new([ + 'pretty', # Whether to pretty format the returned JSON response. + 'human', # Whether to return human readable values for statistics. + 'error_trace', # Whether to include the stack trace of returned errors. + 'source', # The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + 'filter_path' # Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-". + ]).freeze - COMMON_PARAMS = [ - :ignore, # Client specific parameters - :index, :id, # :index/:id - :body, # Request body - :node_id, # Cluster - :name, # Alias, template, settings, warmer, ... - :field # Get field mapping - ] - - COMMON_QUERY_PARAMS = [ - :ignore, # Client specific parameters - :format, # Search, Cat, ... - :pretty, # Pretty-print the response - :human, # Return numeric values in human readable format - :filter_path, # Filter the JSON response - :opaque_id # Use X-Opaque-Id - ] - - HTTP_GET = 'GET' - HTTP_HEAD = 'HEAD' - HTTP_PATCH = 'PATCH' - HTTP_POST = 'POST' - HTTP_PUT = 'PUT' - HTTP_DELETE = 'DELETE' - - UNDERSCORE_SEARCH = '_search' - UNDERSCORE_ALL = '_all' - DEFAULT_DOC = '_doc' - - # Auto-include all namespaces in the receiver - def self.included(base) - base.send :include, - OpenSearch::API::Common, - OpenSearch::API::Actions, - OpenSearch::API::Cat, - OpenSearch::API::Cluster, - OpenSearch::API::DanglingIndices, - OpenSearch::API::Features, - OpenSearch::API::Http, - OpenSearch::API::Indices, - OpenSearch::API::Ingest, - OpenSearch::API::Nodes, - OpenSearch::API::Remote, - OpenSearch::API::RemoteStore, - OpenSearch::API::Security, - OpenSearch::API::Shutdown, - OpenSearch::API::Snapshot, - OpenSearch::API::Tasks - end + DEFAULT_SERIALIZER = MultiJson - # The serializer class def self.serializer settings[:serializer] || DEFAULT_SERIALIZER end - # Access the module settings def self.settings @settings ||= {} end diff --git a/lib/opensearch/api/actions/abort_benchmark.rb b/lib/opensearch/api/actions/abort_benchmark.rb deleted file mode 100644 index 0f87fb975..000000000 --- a/lib/opensearch/api/actions/abort_benchmark.rb +++ /dev/null @@ -1,49 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Actions - # Abort a running benchmark - # - # @example - # - # client.abort_benchmark name: 'my_benchmark' - # - # @option arguments [String] :name A benchmark name - # - # - def abort_benchmark(arguments = {}) - method = HTTP_POST - path = "_bench/abort/#{arguments[:name]}" - params = {} - body = nil - - perform_request(method, path, params, body).body - end - end - end -end diff --git a/lib/opensearch/api/actions/asynchronous_search/delete.rb b/lib/opensearch/api/actions/asynchronous_search/delete.rb new file mode 100644 index 000000000..2d27a0c80 --- /dev/null +++ b/lib/opensearch/api/actions/asynchronous_search/delete.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module AsynchronousSearch + module Actions + # Delete asynchronous search. + # + # @option args [String] :id *Required* + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_asynchronous_search', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/asynchronous_search/get.rb b/lib/opensearch/api/actions/asynchronous_search/get.rb new file mode 100644 index 000000000..7a1fdbe6a --- /dev/null +++ b/lib/opensearch/api/actions/asynchronous_search/get.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module AsynchronousSearch + module Actions + # Get partial responses from asynchronous search. + # + # @option args [String] :id *Required* + def get(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_asynchronous_search', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/asynchronous_search/search.rb b/lib/opensearch/api/actions/asynchronous_search/search.rb new file mode 100644 index 000000000..864593bad --- /dev/null +++ b/lib/opensearch/api/actions/asynchronous_search/search.rb @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module AsynchronousSearch + module Actions + # Perform an asynchronous search. + # + # @option args [String] :index The name of the index to be searched. Can be an individual name, a comma-separated list of indexes, or a wildcard expression of index names. + # @option args [String] :keep_alive The amount of time that the result is saved in the cluster. For example, `2d` means that the results are stored in the cluster for 48 hours. The saved search results are deleted after this period or if the search is canceled. Note that this includes the query execution time. If the query overruns this time, the process cancels this query automatically. + # @option args [Boolean] :keep_on_completion Whether you want to save the results in the cluster after the search is complete. + # @option args [String] :wait_for_completion_timeout The amount of time that you plan to wait for the results. You can poll the remaining results based on an ID. The maximum value is `300s`. Default is `1s`. + # @option args [Hash] :body The search definition using the Query DSL. + def search(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_asynchronous_search' + + Utils.validate_query_params args, SEARCH_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + SEARCH_QUERY_PARAMS = Set.new(%w[ + index + keep_alive + keep_on_completion + wait_for_completion_timeout + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/asynchronous_search/stats.rb b/lib/opensearch/api/actions/asynchronous_search/stats.rb new file mode 100644 index 000000000..9a5e29856 --- /dev/null +++ b/lib/opensearch/api/actions/asynchronous_search/stats.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module AsynchronousSearch + module Actions + # Monitoring of asynchronous searches that are running, completed, and/or persisted. + # + def stats(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_asynchronous_search/stats' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/benchmark.rb b/lib/opensearch/api/actions/benchmark.rb deleted file mode 100644 index 3d2201f49..000000000 --- a/lib/opensearch/api/actions/benchmark.rb +++ /dev/null @@ -1,88 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Actions - # Run a single query, or a set of queries, and return statistics on their performance - # - # @example Return statistics for a single query - # - # client.benchmark body: { - # name: 'my_benchmark', - # competitors: [ - # { - # name: 'query_1', - # requests: [ - # { query: { match: { _all: 'a*' } } } - # ] - # } - # ] - # } - # - # @example Return statistics for a set of "competing" queries - # - # client.benchmark body: { - # name: 'my_benchmark', - # competitors: [ - # { - # name: 'query_a', - # requests: [ - # { query: { match: { _all: 'a*' } } } - # ] - # }, - # { - # name: 'query_b', - # requests: [ - # { query: { match: { _all: 'b*' } } } - # ] - # } - # ] - # } - # - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string - # to perform the operation on all indices - # @option arguments [Hash] :body The search definition using the Query DSL - # @option arguments [Boolean] :verbose Specify whether to return verbose statistics about each iteration - # (default: false) - # - # - def benchmark(arguments = {}) - method = HTTP_PUT - path = '_bench' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - body = arguments[:body] - - perform_request(method, path, params, body).body - end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.1.1 - ParamsRegistry.register(:benchmark, [:verbose].freeze) - end - end -end diff --git a/lib/opensearch/api/actions/bulk.rb b/lib/opensearch/api/actions/bulk.rb index c7d004db4..8b5844720 100644 --- a/lib/opensearch/api/actions/bulk.rb +++ b/lib/opensearch/api/actions/bulk.rb @@ -3,89 +3,58 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Actions - # Allows to perform multiple index/update/delete operations in a single request. - # - # @option arguments [String] :index Default index for items which don't provide one - # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - # @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for) - # @option arguments [String] :routing Specific routing value - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [List] :_source True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request - # @option arguments [List] :_source_excludes Default list of fields to exclude from the returned _source field, can be overridden on each sub-request - # @option arguments [List] :_source_includes Default list of fields to extract and return from the _source field, can be overridden on each sub-request - # @option arguments [String] :pipeline The pipeline id to preprocess incoming documents with - # @option arguments [Boolean] :require_alias Sets require_alias for all incoming documents. Defaults to unset (false) - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [String|Array] :body The operation definition and data (action-data pairs), separated by newlines. Array of Strings, Header/Data pairs, - # or the conveniency "combined" format can be passed, refer to OpenSearch::API::Utils.__bulkify documentation. - # - # - def bulk(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_POST - path = if _index - "#{Utils.__listify(_index)}/_bulk" - else - '_bulk' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - payload = if body.is_a? Array - OpenSearch::API::Utils.__bulkify(body) - else - body - end - - headers.merge!('Content-Type' => 'application/x-ndjson') - perform_request(method, path, params, payload, headers).body +module OpenSearch + module API + module Root + module Actions + # Allows to perform multiple index/update/delete operations in a single request. + # + # @option args [Boolean, Enumerable, String] :_source `true` or `false` to return the `_source` field or not, or a list of fields to return. + # @option args [Enumerable, String] :_source_excludes A comma-separated list of source fields to exclude from the response. + # @option args [Enumerable, String] :_source_includes A comma-separated list of source fields to include in the response. + # @option args [String] :pipeline ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request. If a final pipeline is configured it will always run, regardless of the value of this parameter. + # @option args [Boolean, String] :refresh If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes. Valid values: `true`, `false`, `wait_for`. + # @option args [Boolean] :require_alias If `true`, the request's actions must target an index alias. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [String] :timeout Period each action waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. + # @option args [String] :type Default document type for items which don't provide one. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + # @option args [String] :index Name of the data stream, index, or index alias to perform bulk actions on. + # @option args [Enumerable] :body *Required* The operation definition and data (action-data pairs), separated by newlines + def bulk(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _index = args.delete('index') + + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = _index.present? ? 'PUT' : 'POST' + url = [_index, '_bulk'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, BULK_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + BULK_QUERY_PARAMS = Set.new(%w[ + _source + _source_excludes + _source_includes + pipeline + refresh + require_alias + routing + timeout + type + wait_for_active_shards + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:bulk, %i[ - wait_for_active_shards - refresh - routing - timeout - _source - _source_excludes - _source_includes - pipeline - require_alias - ].freeze) end end end diff --git a/lib/opensearch/api/actions/bulk_stream.rb b/lib/opensearch/api/actions/bulk_stream.rb new file mode 100644 index 000000000..624c0e69c --- /dev/null +++ b/lib/opensearch/api/actions/bulk_stream.rb @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Root + module Actions + # Allows to perform multiple index/update/delete operations using request response streaming. + # + # @option args [Boolean, Enumerable, String] :_source `true` or `false` to return the `_source` field or not, or a list of fields to return. + # @option args [Enumerable, String] :_source_excludes A comma-separated list of source fields to exclude from the response. + # @option args [Enumerable, String] :_source_includes A comma-separated list of source fields to include in the response. + # @option args [String] :batch_interval Specifies for how long bulk operations should be accumulated into a batch before sending the batch to data nodes. + # @option args [Integer] :batch_size Specifies how many bulk operations should be accumulated into a batch before sending the batch to data nodes. + # @option args [String] :pipeline ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request. If a final pipeline is configured it will always run, regardless of the value of this parameter. + # @option args [Boolean, String] :refresh If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes. Valid values: `true`, `false`, `wait_for`. + # @option args [Boolean] :require_alias If `true`, the request's actions must target an index alias. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [String] :timeout Period each action waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. + # @option args [String] :type Default document type for items which don't provide one. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + # @option args [String] :index Name of the data stream, index, or index alias to perform bulk actions on. + # @option args [Enumerable] :body *Required* The operation definition and data (action-data pairs), separated by newlines + def bulk_stream(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _index = args.delete('index') + + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = _index.present? ? 'PUT' : 'POST' + url = [_index, '_bulk/stream'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, BULK_STREAM_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + BULK_STREAM_QUERY_PARAMS = Set.new(%w[ + _source + _source_excludes + _source_includes + batch_interval + batch_size + pipeline + refresh + require_alias + routing + timeout + type + wait_for_active_shards + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/cat/aliases.rb b/lib/opensearch/api/actions/cat/aliases.rb index 3752da589..32704fbec 100644 --- a/lib/opensearch/api/actions/cat/aliases.rb +++ b/lib/opensearch/api/actions/cat/aliases.rb @@ -3,76 +3,48 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Cat module Actions - # Shows information about currently configured aliases to indices including filter and routing infos. - # - # @option arguments [List] :name A comma-separated list of alias names to return - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Hash] :headers Custom HTTP headers - # + # Shows information about currently configured aliases to indexes including filter and routing info. # - def aliases(arguments = {}) - headers = arguments.delete(:headers) || {} + # @option args [Enumerable, String] :expand_wildcards Whether to expand wildcard expression to concrete indexes that are open, closed or both. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Boolean] :v Verbose mode. Display column headers. + # @option args [Enumerable, String] :name A comma-separated list of aliases to retrieve. Supports wildcards (`*`). To retrieve all aliases, omit this parameter or use `*` or `_all`. + def aliases(args = {}) + args = Utils.normalize_arguments(args) + _name = args.delete('name') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cat/aliases', _name].filter(&:present?).join('/').squeeze('/') - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_GET - path = if _name - "_cat/aliases/#{Utils.__listify(_name)}" - else - '_cat/aliases' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - params[:h] = Utils.__listify(params[:h]) if params[:h] - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, ALIASES_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:aliases, %i[ + ALIASES_QUERY_PARAMS = Set.new(%w[ + expand_wildcards format - local h help + local s v - expand_wildcards - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/all_pit_segments.rb b/lib/opensearch/api/actions/cat/all_pit_segments.rb index 0ca3aed73..6b489f8b6 100644 --- a/lib/opensearch/api/actions/cat/all_pit_segments.rb +++ b/lib/opensearch/api/actions/cat/all_pit_segments.rb @@ -3,42 +3,43 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Cat module Actions - # Retrieves info of all PIT segments + # Lists all active point-in-time segments. # - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - def all_pit_segments(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - method = OpenSearch::API::HTTP_GET - path = '_cat/pit_segments/_all' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - params[:h] = Utils.__listify(params[:h]) if params[:h] + # @option args [String] :bytes The unit in which to display byte values. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Boolean] :v Verbose mode. Display column headers. + def all_pit_segments(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_cat/pit_segments/_all' - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, ALL_PIT_SEGMENTS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - ParamsRegistry.register(:all_pit_segments, %i[ + ALL_PIT_SEGMENTS_QUERY_PARAMS = Set.new(%w[ + bytes format h help s v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/allocation.rb b/lib/opensearch/api/actions/cat/allocation.rb index 285c1e33f..677de63dd 100644 --- a/lib/opensearch/api/actions/cat/allocation.rb +++ b/lib/opensearch/api/actions/cat/allocation.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,53 +15,40 @@ module Cat module Actions # Provides a snapshot of how many shards are allocated to each data node and how much disk space they are using. # - # @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [String] :bytes The unit in which to display byte values (options: b, k, kb, m, mb, g, gb, t, tb, p, pb) - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def allocation(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :bytes The unit used to display byte values. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Boolean] :v Verbose mode. Display column headers. + # @option args [Enumerable, String] :node_id Comma-separated list of node identifiers or names used to limit the returned information. + def allocation(args = {}) + args = Utils.normalize_arguments(args) + _node_id = args.delete('node_id') - _node_id = arguments.delete(:node_id) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cat/allocation', _node_id].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_GET - path = if _node_id - "_cat/allocation/#{Utils.__listify(_node_id)}" - else - '_cat/allocation' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - params[:h] = Utils.__listify(params[:h]) if params[:h] - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, ALLOCATION_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:allocation, %i[ - format + ALLOCATION_QUERY_PARAMS = Set.new(%w[ bytes - local - master_timeout cluster_manager_timeout + format h help + local + master_timeout s v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/cluster_manager.rb b/lib/opensearch/api/actions/cat/cluster_manager.rb index 57f201bd2..c1ef1fd79 100644 --- a/lib/opensearch/api/actions/cat/cluster_manager.rb +++ b/lib/opensearch/api/actions/cat/cluster_manager.rb @@ -3,51 +3,47 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Cat module Actions - # Returns information about the cluster_manager node. + # Returns information about the cluster-manager node. # - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def cluster_manager(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Boolean] :v Verbose mode. Display column headers. + def cluster_manager(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_cat/cluster_manager' - method = OpenSearch::API::HTTP_GET - path = '_cat/cluster_manager' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, CLUSTER_MANAGER_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:cluster_manager, %i[ - format - local + CLUSTER_MANAGER_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + format h help + local + master_timeout s v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/count.rb b/lib/opensearch/api/actions/cat/count.rb index 7cd6845cf..2990bf6e5 100644 --- a/lib/opensearch/api/actions/cat/count.rb +++ b/lib/opensearch/api/actions/cat/count.rb @@ -3,72 +3,44 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Cat module Actions - # Provides quick access to the document count of the entire cluster, or individual indices. + # Provides quick access to the document count of the entire cluster, or individual indexes. # - # @option arguments [List] :index A comma-separated list of index names to limit the returned information - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def count(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Boolean] :v Verbose mode. Display column headers. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + def count(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - _index = arguments.delete(:index) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cat/count', _index].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_GET - path = if _index - "_cat/count/#{Utils.__listify(_index)}" - else - '_cat/count' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - params[:h] = Utils.__listify(params[:h]) if params[:h] - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, COUNT_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:count, %i[ + COUNT_QUERY_PARAMS = Set.new(%w[ format h help s v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/fielddata.rb b/lib/opensearch/api/actions/cat/fielddata.rb index b99be5bec..03a973565 100644 --- a/lib/opensearch/api/actions/cat/fielddata.rb +++ b/lib/opensearch/api/actions/cat/fielddata.rb @@ -3,74 +3,46 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Cat module Actions - # Shows how much heap memory is currently being used by fielddata on every data node in the cluster. - # - # @option arguments [List] :fields A comma-separated list of fields to return the fielddata size - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [String] :bytes The unit in which to display byte values (options: b, k, kb, m, mb, g, gb, t, tb, p, pb) - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers + # Shows how much heap memory is currently being used by field data on every data node in the cluster. # - # - def fielddata(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _fields = arguments.delete(:fields) + # @option args [String] :bytes The unit used to display byte values. + # @option args [Enumerable, String] :fields Comma-separated list of fields used to limit returned information. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Boolean] :v Verbose mode. Display column headers. + def fielddata(args = {}) + args = Utils.normalize_arguments(args) + _fields = args.delete('fields') - method = OpenSearch::API::HTTP_GET - path = if _fields - "_cat/fielddata/#{Utils.__listify(_fields)}" - else - '_cat/fielddata' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cat/fielddata', _fields].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, FIELDDATA_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:fielddata, %i[ - format + FIELDDATA_QUERY_PARAMS = Set.new(%w[ bytes + format h help s v - fields - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/health.rb b/lib/opensearch/api/actions/cat/health.rb index 213d5f585..826527a3b 100644 --- a/lib/opensearch/api/actions/cat/health.rb +++ b/lib/opensearch/api/actions/cat/health.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,34 +15,25 @@ module Cat module Actions # Returns a concise representation of the cluster health. # - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [String] :time The unit in which to display time values (options: d, h, m, s, ms, micros, nanos) - # @option arguments [Boolean] :ts Set to false to disable timestamping - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def health(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [String] :time The unit used to display time values. + # @option args [Boolean] :ts If `true`, returns `HH:MM:SS` and Unix epoch timestamps. + # @option args [Boolean] :v Verbose mode. Display column headers. + def health(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_cat/health' - method = OpenSearch::API::HTTP_GET - path = '_cat/health' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - params[:h] = Utils.__listify(params[:h]) if params[:h] - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, HEALTH_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:health, %i[ + HEALTH_QUERY_PARAMS = Set.new(%w[ format h help @@ -65,7 +41,7 @@ def health(arguments = {}) time ts v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/help.rb b/lib/opensearch/api/actions/cat/help.rb index ad0d36f74..285fe44a1 100644 --- a/lib/opensearch/api/actions/cat/help.rb +++ b/lib/opensearch/api/actions/cat/help.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,31 +15,16 @@ module Cat module Actions # Returns help for the Cat APIs. # - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def help(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + def help(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_cat' - method = OpenSearch::API::HTTP_GET - path = '_cat' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:help, %i[ - help - s - ].freeze) end end end diff --git a/lib/opensearch/api/actions/cat/indices.rb b/lib/opensearch/api/actions/cat/indices.rb index e01021ca8..c4aebbcdf 100644 --- a/lib/opensearch/api/actions/cat/indices.rb +++ b/lib/opensearch/api/actions/cat/indices.rb @@ -3,90 +3,62 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Cat module Actions - # Returns information about indices: number of primaries and replicas, document counts, disk size, ... + # Returns information about indexes: number of primaries and replicas, document counts, disk size, ... # - # @option arguments [List] :index A comma-separated list of index names to limit the returned information - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [String] :bytes The unit in which to display byte values (options: b, k, kb, m, mb, g, gb, t, tb, p, pb) - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [String] :health A health status ("green", "yellow", or "red" to filter only indices matching the specified health status (options: green, yellow, red) - # @option arguments [Boolean] :help Return help information - # @option arguments [Boolean] :pri Set to true to return stats only for primary shards - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [String] :time The unit in which to display time values (options: d, h, m, s, ms, micros, nanos) - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Boolean] :include_unloaded_segments If set to true segment stats will include stats for segments that are not currently loaded into memory - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def indices(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :bytes The unit used to display byte values. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :expand_wildcards The type of index that wildcard patterns can match. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [String] :health The health status used to limit returned indexes. By default, the response includes indexes of any health status. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :include_unloaded_segments If `true`, the response includes information from segments that are not loaded into memory. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :pri If `true`, the response only includes information from primary shards. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [String] :time The unit used to display time values. + # @option args [Boolean] :v Verbose mode. Display column headers. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + def indices(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - _index = arguments.delete(:index) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cat/indices', _index].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_GET - path = if _index - "_cat/indices/#{Utils.__listify(_index)}" - else - '_cat/indices' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - params[:h] = Utils.__listify(params[:h]) if params[:h] - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, INDICES_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:indices, %i[ - format + INDICES_QUERY_PARAMS = Set.new(%w[ bytes - local - master_timeout cluster_manager_timeout + expand_wildcards + format h health help + include_unloaded_segments + local + master_timeout pri s time v - include_unloaded_segments - expand_wildcards - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/master.rb b/lib/opensearch/api/actions/cat/master.rb index b72528ab4..afdfbd241 100644 --- a/lib/opensearch/api/actions/cat/master.rb +++ b/lib/opensearch/api/actions/cat/master.rb @@ -3,70 +3,47 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# @deprecated Please use cluster_manager instead. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + module OpenSearch module API module Cat module Actions - # Returns information about the master node. - # - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers + # Returns information about the cluster-manager node. # - # - def master(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Boolean] :v Verbose mode. Display column headers. + def master(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_cat/master' - method = OpenSearch::API::HTTP_GET - path = '_cat/master' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, MASTER_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:master, %i[ - format - local - master_timeout + MASTER_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + format h help + local + master_timeout s v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/nodeattrs.rb b/lib/opensearch/api/actions/cat/nodeattrs.rb index 3970142db..57ad77e99 100644 --- a/lib/opensearch/api/actions/cat/nodeattrs.rb +++ b/lib/opensearch/api/actions/cat/nodeattrs.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,43 +15,35 @@ module Cat module Actions # Returns information about custom node attributes. # - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def nodeattrs(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Boolean] :v Verbose mode. Display column headers. + def nodeattrs(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_cat/nodeattrs' - method = OpenSearch::API::HTTP_GET - path = '_cat/nodeattrs' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, NODEATTRS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:nodeattrs, %i[ - format - local - master_timeout + NODEATTRS_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + format h help + local + master_timeout s v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/nodes.rb b/lib/opensearch/api/actions/cat/nodes.rb index e09a7bc27..ce637324f 100644 --- a/lib/opensearch/api/actions/cat/nodes.rb +++ b/lib/opensearch/api/actions/cat/nodes.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,52 +15,41 @@ module Cat module Actions # Returns basic statistics about performance of cluster nodes. # - # @option arguments [String] :bytes The unit in which to display byte values (options: b, k, kb, m, mb, g, gb, t, tb, p, pb) - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [Boolean] :full_id Return the full node ID instead of the shortened version (default: false) - # @option arguments [Boolean] :local Calculate the selected nodes using the local cluster state rather than the state from cluster_manager node (default: false) *Deprecated* - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [String] :time The unit in which to display time values (options: d, h, m, s, ms, micros, nanos) - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Boolean] :include_unloaded_segments If set to true segment stats will include stats for segments that are not currently loaded into memory - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def nodes(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :bytes The unit used to display byte values. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Boolean, String] :full_id If `true`, return the full node ID. If `false`, return the shortened node ID. + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :local DEPRECATED Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [String] :time The unit in which to display time values. + # @option args [Boolean] :v Verbose mode. Display column headers. + def nodes(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_cat/nodes' - method = OpenSearch::API::HTTP_GET - path = '_cat/nodes' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - params[:h] = Utils.__listify(params[:h], escape: false) if params[:h] - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, NODES_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:nodes, %i[ + NODES_QUERY_PARAMS = Set.new(%w[ bytes + cluster_manager_timeout format full_id - local - master_timeout - cluster_manager_timeout h help + local + master_timeout s time v - include_unloaded_segments - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/params_registry.rb b/lib/opensearch/api/actions/cat/params_registry.rb deleted file mode 100644 index 91fd6055e..000000000 --- a/lib/opensearch/api/actions/cat/params_registry.rb +++ /dev/null @@ -1,69 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Cat - module Actions - module ParamsRegistry - extend self - - # A Mapping of all the actions to their list of valid params. - # - # @since 6.1.1 - PARAMS = {} - - # Register an action with its list of valid params. - # - # @example Register the action. - # ParamsRegistry.register(:benchmark, [ :verbose ]) - # - # @param [ Symbol ] action The action to register. - # @param [ Array[Symbol] ] valid_params The list of valid params. - # - # @since 6.1.1 - def register(action, valid_params) - PARAMS[action.to_sym] = valid_params - end - - # Get the list of valid params for a given action. - # - # @example Get the list of valid params. - # ParamsRegistry.get(:benchmark) - # - # @param [ Symbol ] action The action. - # - # @return [ Array ] The list of valid params for the action. - # - # @since 6.1.1 - def get(action) - PARAMS.fetch(action, []) - end - end - end - end - end -end diff --git a/lib/opensearch/api/actions/cat/pending_tasks.rb b/lib/opensearch/api/actions/cat/pending_tasks.rb index 1763ac708..b060e3503 100644 --- a/lib/opensearch/api/actions/cat/pending_tasks.rb +++ b/lib/opensearch/api/actions/cat/pending_tasks.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,46 +15,37 @@ module Cat module Actions # Returns a concise representation of the cluster pending tasks. # - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [String] :time The unit in which to display time values (options: d, h, m, s, ms, micros, nanos) - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def pending_tasks(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [String] :time The unit in which to display time values. + # @option args [Boolean] :v Verbose mode. Display column headers. + def pending_tasks(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_cat/pending_tasks' - method = OpenSearch::API::HTTP_GET - path = '_cat/pending_tasks' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - params[:h] = Utils.__listify(params[:h]) if params[:h] - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, PENDING_TASKS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:pending_tasks, %i[ - format - local - master_timeout + PENDING_TASKS_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + format h help + local + master_timeout s time v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/pit_segments.rb b/lib/opensearch/api/actions/cat/pit_segments.rb index 9d41fcf8a..64419a017 100644 --- a/lib/opensearch/api/actions/cat/pit_segments.rb +++ b/lib/opensearch/api/actions/cat/pit_segments.rb @@ -3,45 +3,44 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Cat module Actions - # Retrieves info of certain PIT segments + # List segments for one or several PITs. # - # @option arguments [Hash] body: Must include `pit_id`, which is an array of PIT IDs. (required) - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - def pit_segments(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - method = OpenSearch::API::HTTP_GET - path = '_cat/pit_segments' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - params[:h] = Utils.__listify(params[:h]) if params[:h] + # @option args [String] :bytes The unit in which to display byte values. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Boolean] :v Verbose mode. Display column headers. + # @option args [Hash] :body + def pit_segments(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_cat/pit_segments' - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, PIT_SEGMENTS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - ParamsRegistry.register(:pit_segments, %i[ + PIT_SEGMENTS_QUERY_PARAMS = Set.new(%w[ + bytes format h help s v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/plugins.rb b/lib/opensearch/api/actions/cat/plugins.rb index c0644888d..bc7f518fe 100644 --- a/lib/opensearch/api/actions/cat/plugins.rb +++ b/lib/opensearch/api/actions/cat/plugins.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,45 +15,35 @@ module Cat module Actions # Returns information about installed plugins across nodes node. # - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [Boolean] :include_bootstrap Include bootstrap plugins in the response - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def plugins(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Boolean] :v Verbose mode. Display column headers. + def plugins(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_cat/plugins' - method = OpenSearch::API::HTTP_GET - path = '_cat/plugins' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, PLUGINS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:plugins, %i[ - format - local - master_timeout + PLUGINS_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + format h help - include_bootstrap + local + master_timeout s v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/recovery.rb b/lib/opensearch/api/actions/cat/recovery.rb index c31707c13..230c54758 100644 --- a/lib/opensearch/api/actions/cat/recovery.rb +++ b/lib/opensearch/api/actions/cat/recovery.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,54 +15,40 @@ module Cat module Actions # Returns information about index shard recoveries, both on-going completed. # - # @option arguments [List] :index Comma-separated list or wildcard expression of index names to limit the returned information - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [Boolean] :active_only If `true`, the response only includes ongoing shard recoveries - # @option arguments [String] :bytes The unit in which to display byte values (options: b, k, kb, m, mb, g, gb, t, tb, p, pb) - # @option arguments [Boolean] :detailed If `true`, the response includes detailed information about shard recoveries - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [String] :time The unit in which to display time values (options: d, h, m, s, ms, micros, nanos) - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def recovery(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) + # @option args [Boolean] :active_only If `true`, the response only includes ongoing shard recoveries. + # @option args [String] :bytes The unit used to display byte values. + # @option args [Boolean] :detailed If `true`, the response includes detailed information about shard recoveries. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Enumerable] :index Comma-separated list or wildcard expression of index names to limit the returned information. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [String] :time The unit in which to display time values. + # @option args [Boolean] :v Verbose mode. Display column headers. + def recovery(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - method = OpenSearch::API::HTTP_GET - path = if _index - "_cat/recovery/#{Utils.__listify(_index)}" - else - '_cat/recovery' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - params[:h] = Utils.__listify(params[:h]) if params[:h] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cat/recovery', _index].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, RECOVERY_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:recovery, %i[ - format + RECOVERY_QUERY_PARAMS = Set.new(%w[ active_only bytes detailed + format h help - index s time v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/repositories.rb b/lib/opensearch/api/actions/cat/repositories.rb index 902722674..64e5f615e 100644 --- a/lib/opensearch/api/actions/cat/repositories.rb +++ b/lib/opensearch/api/actions/cat/repositories.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,43 +15,35 @@ module Cat module Actions # Returns information about snapshot repositories registered in the cluster. # - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def repositories(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Boolean] :v Verbose mode. Display column headers. + def repositories(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_cat/repositories' - method = OpenSearch::API::HTTP_GET - path = '_cat/repositories' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, REPOSITORIES_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:repositories, %i[ - format - local - master_timeout + REPOSITORIES_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + format h help + local + master_timeout s v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/segment_replication.rb b/lib/opensearch/api/actions/cat/segment_replication.rb new file mode 100644 index 000000000..5c6e8b0ea --- /dev/null +++ b/lib/opensearch/api/actions/cat/segment_replication.rb @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Cat + module Actions + # Returns information about both on-going and latest completed Segment Replication events. + # + # @option args [Boolean] :active_only If `true`, the response only includes ongoing segment replication events. + # @option args [Boolean] :allow_no_indices Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified). + # @option args [String] :bytes The unit in which to display byte values. + # @option args [Boolean] :completed_only If `true`, the response only includes latest completed segment replication events. + # @option args [Boolean] :detailed If `true`, the response includes detailed information about segment replications. + # @option args [Enumerable, String] :expand_wildcards Whether to expand wildcard expression to concrete indexes that are open, closed or both. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :ignore_throttled Whether specified concrete, expanded or aliased indexes should be ignored when throttled. + # @option args [Boolean] :ignore_unavailable Whether specified concrete indexes should be ignored when unavailable (missing or closed). + # @option args [Enumerable] :index Comma-separated list or wildcard expression of index names to limit the returned information. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Enumerable] :shards Comma-separated list of shards to display. + # @option args [String] :time The unit in which to display time values. + # @option args [String] :timeout Operation timeout. + # @option args [Boolean] :v Verbose mode. Display column headers. + def segment_replication(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cat/segment_replication', _index].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, SEGMENT_REPLICATION_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + SEGMENT_REPLICATION_QUERY_PARAMS = Set.new(%w[ + active_only + allow_no_indices + bytes + completed_only + detailed + expand_wildcards + format + h + help + ignore_throttled + ignore_unavailable + s + shards + time + timeout + v + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/cat/segments.rb b/lib/opensearch/api/actions/cat/segments.rb index 25170e7d9..1fa9620f7 100644 --- a/lib/opensearch/api/actions/cat/segments.rb +++ b/lib/opensearch/api/actions/cat/segments.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,46 +15,38 @@ module Cat module Actions # Provides low-level information about the segments in the shards of an index. # - # @option arguments [List] :index A comma-separated list of index names to limit the returned information - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [String] :bytes The unit in which to display byte values (options: b, k, kb, m, mb, g, gb, t, tb, p, pb) - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def segments(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) + # @option args [String] :bytes The unit used to display byte values. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Boolean] :v Verbose mode. Display column headers. + # @option args [Enumerable, String] :index A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + def segments(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - method = OpenSearch::API::HTTP_GET - path = if _index - "_cat/segments/#{Utils.__listify(_index)}" - else - '_cat/segments' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cat/segments', _index].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, SEGMENTS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:segments, %i[ - format + SEGMENTS_QUERY_PARAMS = Set.new(%w[ bytes + cluster_manager_timeout + format h help + master_timeout s v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/shards.rb b/lib/opensearch/api/actions/cat/shards.rb index 2523de75d..36a08872b 100644 --- a/lib/opensearch/api/actions/cat/shards.rb +++ b/lib/opensearch/api/actions/cat/shards.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,55 +15,42 @@ module Cat module Actions # Provides a detailed view of shard allocation on nodes. # - # @option arguments [List] :index A comma-separated list of index names to limit the returned information - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [String] :bytes The unit in which to display byte values (options: b, k, kb, m, mb, g, gb, t, tb, p, pb) - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) *Deprecated* - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [String] :time The unit in which to display time values (options: d, h, m, s, ms, micros, nanos) - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def shards(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :bytes The unit used to display byte values. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [String] :time The unit in which to display time values. + # @option args [Boolean] :v Verbose mode. Display column headers. + # @option args [Enumerable, String] :index A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + def shards(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - _index = arguments.delete(:index) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cat/shards', _index].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_GET - path = if _index - "_cat/shards/#{Utils.__listify(_index)}" - else - '_cat/shards' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - params[:h] = Utils.__listify(params[:h]) if params[:h] - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, SHARDS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:shards, %i[ - format + SHARDS_QUERY_PARAMS = Set.new(%w[ bytes - local - master_timeout cluster_manager_timeout + format h help + local + master_timeout s time v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/snapshots.rb b/lib/opensearch/api/actions/cat/snapshots.rb index 47387c48c..a8655d5ea 100644 --- a/lib/opensearch/api/actions/cat/snapshots.rb +++ b/lib/opensearch/api/actions/cat/snapshots.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,52 +15,42 @@ module Cat module Actions # Returns all snapshots in a specific repository. # - # @option arguments [List] :repository Name of repository from which to fetch the snapshot information - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [Boolean] :ignore_unavailable Set to true to ignore unavailable snapshots - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [String] :time The unit in which to display time values (options: d, h, m, s, ms, micros, nanos) - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def snapshots(arguments = {}) - headers = arguments.delete(:headers) || {} + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :ignore_unavailable If `true`, the response does not include information from unavailable snapshots. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :repository *Required* A comma-separated list of snapshot repositories used to limit the request. Accepts wildcard expressions. `_all` returns all repositories. If any repository fails during the request, OpenSearch returns an error. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [String] :time The unit in which to display time values. + # @option args [Boolean] :v Verbose mode. Display column headers. + def snapshots(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'repository' missing" unless args['repository'] - arguments = arguments.clone + _repository = args.delete('repository') - _repository = arguments.delete(:repository) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cat/snapshots', _repository].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_GET - path = if _repository - "_cat/snapshots/#{Utils.__listify(_repository)}" - else - '_cat/snapshots' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, SNAPSHOTS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:snapshots, %i[ - format - ignore_unavailable - master_timeout + SNAPSHOTS_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + format h help + ignore_unavailable + master_timeout s time v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/tasks.rb b/lib/opensearch/api/actions/cat/tasks.rb index f47b50157..559f1c3bc 100644 --- a/lib/opensearch/api/actions/cat/tasks.rb +++ b/lib/opensearch/api/actions/cat/tasks.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,47 +15,39 @@ module Cat module Actions # Returns information about the tasks currently executing on one or more nodes in the cluster. # - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [List] :nodes A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - # @option arguments [List] :actions A comma-separated list of actions that should be returned. Leave empty to return all. - # @option arguments [Boolean] :detailed Return detailed task information (default: false) - # @option arguments [String] :parent_task_id Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [String] :time The unit in which to display time values (options: d, h, m, s, ms, micros, nanos) - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def tasks(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Enumerable] :actions The task action names, which are used to limit the response. + # @option args [Boolean] :detailed If `true`, the response includes detailed information about shard recoveries. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Enumerable] :nodes Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes. + # @option args [String] :parent_task_id The parent task identifier, which is used to limit the response. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [String] :time The unit in which to display time values. + # @option args [Boolean] :v Verbose mode. Display column headers. + def tasks(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_cat/tasks' - method = OpenSearch::API::HTTP_GET - path = '_cat/tasks' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, TASKS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:tasks, %i[ - format - nodes + TASKS_QUERY_PARAMS = Set.new(%w[ actions detailed - parent_task_id + format h help + nodes + parent_task_id s time v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/templates.rb b/lib/opensearch/api/actions/cat/templates.rb index e7bdc77f9..89f8c908c 100644 --- a/lib/opensearch/api/actions/cat/templates.rb +++ b/lib/opensearch/api/actions/cat/templates.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,50 +15,38 @@ module Cat module Actions # Returns information about existing templates. # - # @option arguments [String] :name A pattern that returned template names must match - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def templates(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Boolean] :v Verbose mode. Display column headers. + # @option args [String] :name The name of the template to return. Accepts wildcard expressions. If omitted, all templates are returned. + def templates(args = {}) + args = Utils.normalize_arguments(args) + _name = args.delete('name') - _name = arguments.delete(:name) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cat/templates', _name].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_GET - path = if _name - "_cat/templates/#{Utils.__listify(_name)}" - else - '_cat/templates' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, TEMPLATES_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:templates, %i[ - format - local - master_timeout + TEMPLATES_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + format h help + local + master_timeout s v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cat/thread_pool.rb b/lib/opensearch/api/actions/cat/thread_pool.rb index 1d5154b0c..4ad5290ac 100644 --- a/lib/opensearch/api/actions/cat/thread_pool.rb +++ b/lib/opensearch/api/actions/cat/thread_pool.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -31,53 +16,40 @@ module Actions # Returns cluster-wide thread pool statistics per node. # By default the active, queue and rejected statistics are returned for all thread pools. # - # @option arguments [List] :thread_pool_patterns A comma-separated list of regular-expressions to filter the thread pools in the output - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml - # @option arguments [String] :size The multiplier in which to display values *Deprecated* (options: , k, m, g, t, p) - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [List] :h Comma-separated list of column names to display - # @option arguments [Boolean] :help Return help information - # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by - # @option arguments [Boolean] :v Verbose mode. Display column headers - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def thread_pool(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _thread_pool_patterns = arguments.delete(:thread_pool_patterns) + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Integer] :size The multiplier in which to display values. + # @option args [Boolean] :v Verbose mode. Display column headers. + # @option args [Enumerable, String] :thread_pool_patterns A comma-separated list of thread pool names used to limit the request. Accepts wildcard expressions. + def thread_pool(args = {}) + args = Utils.normalize_arguments(args) + _thread_pool_patterns = args.delete('thread_pool_patterns') - method = OpenSearch::API::HTTP_GET - path = if _thread_pool_patterns - "_cat/thread_pool/#{Utils.__listify(_thread_pool_patterns)}" - else - '_cat/thread_pool' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - params[:h] = Utils.__listify(params[:h]) if params[:h] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cat/thread_pool', _thread_pool_patterns].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, THREAD_POOL_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:thread_pool, %i[ - format - size - local - master_timeout + THREAD_POOL_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + format h help + local + master_timeout s + size v - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/clear_scroll.rb b/lib/opensearch/api/actions/clear_scroll.rb index 64c5d3de2..f2926607c 100644 --- a/lib/opensearch/api/actions/clear_scroll.rb +++ b/lib/opensearch/api/actions/clear_scroll.rb @@ -3,59 +3,34 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -module OpenSearch - module API - module Actions - # Explicitly clears the search context for a scroll. - # - # @option arguments [List] :scroll_id A comma-separated list of scroll IDs to clear *Deprecated* - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter - # - # *Deprecation notice*: - # A scroll id can be quite large and should be specified as part of the body - # Deprecated since version 7.0.0 - # - # - # - def clear_scroll(arguments = {}) - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - _scroll_id = arguments.delete(:scroll_id) +module OpenSearch + module API + module Root + module Actions + # Explicitly clears the search context for a scroll. + # + # @option args [Enumerable, String] :scroll_id DEPRECATED Comma-separated list of scroll IDs to clear. To clear all scroll IDs, use `_all`. + # @option args [Hash] :body Comma-separated list of scroll IDs to clear if none was specified using the `scroll_id` parameter + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def clear_scroll(args = {}) + args = Utils.normalize_arguments(args) + _scroll_id = args.delete('scroll_id') - method = OpenSearch::API::HTTP_DELETE - path = if _scroll_id - "_search/scroll/#{Utils.__listify(_scroll_id)}" - else - '_search/scroll' - end - params = {} + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_search/scroll', _scroll_id].filter(&:present?).join('/').squeeze('/') - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end end end end diff --git a/lib/opensearch/api/actions/cluster/allocation_explain.rb b/lib/opensearch/api/actions/cluster/allocation_explain.rb index 291fdc5e9..5650c207b 100644 --- a/lib/opensearch/api/actions/cluster/allocation_explain.rb +++ b/lib/opensearch/api/actions/cluster/allocation_explain.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,37 +15,24 @@ module Cluster module Actions # Provides explanations for shard allocations in the cluster. # - # @option arguments [Boolean] :include_yes_decisions Return 'YES' decisions in explanation (default: false) - # @option arguments [Boolean] :include_disk_info Return information about disk usage and shard sizes (default: false) - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard' - # - # - def allocation_explain(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - method = if arguments[:body] - OpenSearch::API::HTTP_POST - else - OpenSearch::API::HTTP_GET - end - - path = '_cluster/allocation/explain' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + # @option args [Boolean] :include_disk_info If `true`, returns information about disk usage and shard sizes. + # @option args [Boolean] :include_yes_decisions If `true`, returns YES decisions in explanation. + # @option args [Hash] :body The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard' + def allocation_explain(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = '_cluster/allocation/explain' - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, ALLOCATION_EXPLAIN_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:allocation_explain, %i[ - include_yes_decisions + ALLOCATION_EXPLAIN_QUERY_PARAMS = Set.new(%w[ include_disk_info - ].freeze) + include_yes_decisions + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cluster/delete_component_template.rb b/lib/opensearch/api/actions/cluster/delete_component_template.rb index c44a9eaec..929b81f8c 100644 --- a/lib/opensearch/api/actions/cluster/delete_component_template.rb +++ b/lib/opensearch/api/actions/cluster/delete_component_template.rb @@ -3,65 +3,44 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Cluster module Actions - # Deletes a component template - # - # @option arguments [String] :name The name of the template - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # + # Deletes a component template. # - def delete_component_template(arguments = {}) - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] + # @option args [String] :name *Required* Name of the component template to delete. Wildcard (*) expressions are supported. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_component_template(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] - headers = arguments.delete(:headers) || {} + _name = args.delete('name') - arguments = arguments.clone + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_component_template', _name].filter(&:present?).join('/').squeeze('/') - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_DELETE - path = "_component_template/#{Utils.__listify(_name)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, DELETE_COMPONENT_TEMPLATE_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:delete_component_template, %i[ - timeout - master_timeout + DELETE_COMPONENT_TEMPLATE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout - ].freeze) + master_timeout + timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cluster/delete_decommission_awareness.rb b/lib/opensearch/api/actions/cluster/delete_decommission_awareness.rb new file mode 100644 index 000000000..3844673b2 --- /dev/null +++ b/lib/opensearch/api/actions/cluster/delete_decommission_awareness.rb @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Cluster + module Actions + # Delete any existing decommission. + # + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_decommission_awareness(args = {}) + args = Utils.normalize_arguments(args) + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = '_cluster/decommission/awareness' + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/cluster/delete_voting_config_exclusions.rb b/lib/opensearch/api/actions/cluster/delete_voting_config_exclusions.rb index b6f42f1b4..4d0c8c90e 100644 --- a/lib/opensearch/api/actions/cluster/delete_voting_config_exclusions.rb +++ b/lib/opensearch/api/actions/cluster/delete_voting_config_exclusions.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,29 +15,23 @@ module Cluster module Actions # Clears cluster voting config exclusions. # - # @option arguments [Boolean] :wait_for_removal Specifies whether to wait for all excluded nodes to be removed from the cluster before clearing the voting configuration exclusions list. - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def delete_voting_config_exclusions(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Boolean] :wait_for_removal Specifies whether to wait for all excluded nodes to be removed from the cluster before clearing the voting configuration exclusions list. Defaults to true, meaning that all excluded nodes must be removed from the cluster before this API takes any action. If set to `false` then the voting configuration exclusions list is cleared even if some excluded nodes are still in the cluster. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_voting_config_exclusions(args = {}) + args = Utils.normalize_arguments(args) + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = '_cluster/voting_config_exclusions' - method = OpenSearch::API::HTTP_DELETE - path = '_cluster/voting_config_exclusions' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, DELETE_VOTING_CONFIG_EXCLUSIONS_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:delete_voting_config_exclusions, [ - :wait_for_removal - ].freeze) + DELETE_VOTING_CONFIG_EXCLUSIONS_QUERY_PARAMS = Set.new(%w[ + wait_for_removal + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cluster/delete_weighted_routing.rb b/lib/opensearch/api/actions/cluster/delete_weighted_routing.rb new file mode 100644 index 000000000..e333c0375 --- /dev/null +++ b/lib/opensearch/api/actions/cluster/delete_weighted_routing.rb @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Cluster + module Actions + # Delete weighted shard routing weights. + # + # @option args [Hash] :body + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_weighted_routing(args = {}) + args = Utils.normalize_arguments(args) + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = '_cluster/routing/awareness/weights' + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/cluster/exists_component_template.rb b/lib/opensearch/api/actions/cluster/exists_component_template.rb index 324bd8453..4c4f15e3b 100644 --- a/lib/opensearch/api/actions/cluster/exists_component_template.rb +++ b/lib/opensearch/api/actions/cluster/exists_component_template.rb @@ -3,67 +3,42 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Cluster module Actions - # Returns information about whether a particular component template exist - # - # @option arguments [String] :name The name of the template - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Hash] :headers Custom HTTP headers + # Returns information about whether a particular component template exist. # - # - def exists_component_template(arguments = {}) - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_HEAD - path = "_component_template/#{Utils.__listify(_name)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + # @option args [String] :name *Required* Name of the component template to check existence of. Wildcard (*) expressions are supported. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :local If `true`, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + def exists_component_template(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] + + _name = args.delete('name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'HEAD' + url = ['_component_template', _name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, EXISTS_COMPONENT_TEMPLATE_QUERY_PARAMS + transport.perform_head_request method, url, args, body, headers end - alias exists_component_template? exists_component_template - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:exists_component_template, %i[ - master_timeout + EXISTS_COMPONENT_TEMPLATE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout local - ].freeze) + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cluster/get_component_template.rb b/lib/opensearch/api/actions/cluster/get_component_template.rb index 6c1f1249b..b7f19fa7b 100644 --- a/lib/opensearch/api/actions/cluster/get_component_template.rb +++ b/lib/opensearch/api/actions/cluster/get_component_template.rb @@ -3,67 +3,40 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Cluster module Actions - # Returns one or more component templates - # - # @option arguments [List] :name The comma separated names of the component templates - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Hash] :headers Custom HTTP headers + # Returns one or more component templates. # - # - def get_component_template(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _name = arguments.delete(:name) + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :local If `true`, the request retrieves information from the local node only. If `false`, information is retrieved from the cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :name Name of the component template to retrieve. Wildcard (`*`) expressions are supported. + def get_component_template(args = {}) + args = Utils.normalize_arguments(args) + _name = args.delete('name') - method = OpenSearch::API::HTTP_GET - path = if _name - "_component_template/#{Utils.__listify(_name)}" - else - '_component_template' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_component_template', _name].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, GET_COMPONENT_TEMPLATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_component_template, %i[ - master_timeout + GET_COMPONENT_TEMPLATE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout local - ].freeze) + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cluster/get_decommission_awareness.rb b/lib/opensearch/api/actions/cluster/get_decommission_awareness.rb new file mode 100644 index 000000000..72b10cc90 --- /dev/null +++ b/lib/opensearch/api/actions/cluster/get_decommission_awareness.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Cluster + module Actions + # Get details and status of decommissioned attribute. + # + # @option args [String] :awareness_attribute_name *Required* Awareness attribute name. + def get_decommission_awareness(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'awareness_attribute_name' missing" unless args['awareness_attribute_name'] + + _awareness_attribute_name = args.delete('awareness_attribute_name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cluster/decommission/awareness', _awareness_attribute_name, '_status'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/cluster/get_settings.rb b/lib/opensearch/api/actions/cluster/get_settings.rb index f9711d9a1..0674b2cf0 100644 --- a/lib/opensearch/api/actions/cluster/get_settings.rb +++ b/lib/opensearch/api/actions/cluster/get_settings.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,37 +15,29 @@ module Cluster module Actions # Returns cluster settings. # - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Boolean] :include_defaults Whether to return all default clusters setting. - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def get_settings(arguments = {}) - headers = arguments.delete(:headers) || {} + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :flat_settings If `true`, returns settings in flat format. + # @option args [Boolean] :include_defaults If `true`, returns default cluster settings from the local node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + def get_settings(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_cluster/settings' - arguments = arguments.clone - - method = OpenSearch::API::HTTP_GET - path = '_cluster/settings' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, GET_SETTINGS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_settings, %i[ + GET_SETTINGS_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout flat_settings + include_defaults master_timeout - cluster_manager_timeout timeout - include_defaults - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cluster/get_weighted_routing.rb b/lib/opensearch/api/actions/cluster/get_weighted_routing.rb new file mode 100644 index 000000000..8c77491e7 --- /dev/null +++ b/lib/opensearch/api/actions/cluster/get_weighted_routing.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Cluster + module Actions + # Fetches weighted shard routing weights. + # + # @option args [String] :attribute *Required* Awareness attribute name. + def get_weighted_routing(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'attribute' missing" unless args['attribute'] + + _attribute = args.delete('attribute') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cluster/routing/awareness', _attribute, 'weights'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/cluster/health.rb b/lib/opensearch/api/actions/cluster/health.rb index d9505c6dc..2c2fe4f7c 100644 --- a/lib/opensearch/api/actions/cluster/health.rb +++ b/lib/opensearch/api/actions/cluster/health.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,58 +15,48 @@ module Cluster module Actions # Returns basic information about the health of the cluster. # - # @option arguments [List] :index Limit the information returned to a specific index - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [String] :level Specify the level of detail for returned information (options: cluster, indices, shards) - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [String] :wait_for_active_shards Wait until the specified number of shards is active - # @option arguments [String] :wait_for_nodes Wait until the specified number of nodes is available - # @option arguments [String] :wait_for_events Wait until all currently queued events with the given priority are processed (options: immediate, urgent, high, normal, low, languid) - # @option arguments [Boolean] :wait_for_no_relocating_shards Whether to wait until there are no relocating shards in the cluster - # @option arguments [Boolean] :wait_for_no_initializing_shards Whether to wait until there are no initializing shards in the cluster - # @option arguments [String] :wait_for_status Wait until cluster is in a specific state (options: green, yellow, red) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def health(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :awareness_attribute The awareness attribute for which the health is required. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :expand_wildcards Whether to expand wildcard expression to concrete indexes that are open, closed or both. + # @option args [String] :level Can be one of cluster, indexes or shards. Controls the details level of the health information returned. + # @option args [Boolean] :local If `true`, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Integer, String] :wait_for_active_shards A number controlling to how many active shards to wait for, all to wait for all shards in the cluster to be active, or 0 to not wait. + # @option args [String] :wait_for_events Can be one of immediate, urgent, high, normal, low, languid. Wait until all currently queued events with the given priority are processed. + # @option args [Boolean] :wait_for_no_initializing_shards A Boolean value which controls whether to wait (until the timeout provided) for the cluster to have no shard initializations. Defaults to false, which means it will not wait for initializing shards. + # @option args [Boolean] :wait_for_no_relocating_shards A Boolean value which controls whether to wait (until the timeout provided) for the cluster to have no shard relocations. Defaults to false, which means it will not wait for relocating shards. + # @option args [Float, String] :wait_for_nodes The request waits until the specified number N of nodes is available. It also accepts >=N, <=N, >N and yellow > red. By default, will not wait for any status. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and index aliases used to limit the request. Wildcard expressions (*) are supported. To target all data streams and indexes in a cluster, omit this parameter or use `_all` or `*`. + def health(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - _index = arguments.delete(:index) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cluster/health', _index].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_GET - path = if _index - "_cluster/health/#{Utils.__listify(_index)}" - else - '_cluster/health' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, HEALTH_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:health, %i[ + HEALTH_QUERY_PARAMS = Set.new(%w[ + awareness_attribute + cluster_manager_timeout expand_wildcards level local master_timeout - cluster_manager_timeout timeout wait_for_active_shards - wait_for_nodes wait_for_events - wait_for_no_relocating_shards wait_for_no_initializing_shards + wait_for_no_relocating_shards + wait_for_nodes wait_for_status - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cluster/params_registry.rb b/lib/opensearch/api/actions/cluster/params_registry.rb deleted file mode 100644 index 936a52e3d..000000000 --- a/lib/opensearch/api/actions/cluster/params_registry.rb +++ /dev/null @@ -1,69 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Cluster - module Actions - module ParamsRegistry - extend self - - # A Mapping of all the actions to their list of valid params. - # - # @since 6.1.1 - PARAMS = {} - - # Register an action with its list of valid params. - # - # @example Register the action. - # ParamsRegistry.register(:benchmark, [ :verbose ]) - # - # @param [ Symbol ] action The action to register. - # @param [ Array[Symbol] ] valid_params The list of valid params. - # - # @since 6.1.1 - def register(action, valid_params) - PARAMS[action.to_sym] = valid_params - end - - # Get the list of valid params for a given action. - # - # @example Get the list of valid params. - # ParamsRegistry.get(:benchmark) - # - # @param [ Symbol ] action The action. - # - # @return [ Array ] The list of valid params for the action. - # - # @since 6.1.1 - def get(action) - PARAMS.fetch(action, []) - end - end - end - end - end -end diff --git a/lib/opensearch/api/actions/cluster/pending_tasks.rb b/lib/opensearch/api/actions/cluster/pending_tasks.rb index ee3ecb20e..2da3c1c70 100644 --- a/lib/opensearch/api/actions/cluster/pending_tasks.rb +++ b/lib/opensearch/api/actions/cluster/pending_tasks.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -31,33 +16,25 @@ module Actions # Returns a list of any cluster-level changes (e.g. create index, update mapping, # allocate or fail shard) which have not yet been executed. # - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def pending_tasks(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - method = OpenSearch::API::HTTP_GET - path = '_cluster/pending_tasks' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :local If `true`, the request retrieves information from the local node only. If `false`, information is retrieved from the cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + def pending_tasks(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_cluster/pending_tasks' - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, PENDING_TASKS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:pending_tasks, %i[ + PENDING_TASKS_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout local master_timeout - cluster_manager_timeout - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cluster/post_voting_config_exclusions.rb b/lib/opensearch/api/actions/cluster/post_voting_config_exclusions.rb index 7936ecd65..aa28b6a57 100644 --- a/lib/opensearch/api/actions/cluster/post_voting_config_exclusions.rb +++ b/lib/opensearch/api/actions/cluster/post_voting_config_exclusions.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,33 +15,25 @@ module Cluster module Actions # Updates the cluster voting config exclusions by node ids or node names. # - # @option arguments [String] :node_ids A comma-separated list of the persistent ids of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_names. - # @option arguments [String] :node_names A comma-separated list of the names of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_ids. - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def post_voting_config_exclusions(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Enumerable, String] :node_ids A comma-separated list of the persistent ids of the nodes to exclude from the voting configuration. If specified, you may not also specify `node_names`. + # @option args [Enumerable, String] :node_names A comma-separated list of the names of the nodes to exclude from the voting configuration. If specified, you may not also specify `node_ids`. + # @option args [String] :timeout When adding a voting configuration exclusion, the API waits for the specified nodes to be excluded from the voting configuration before returning. If the timeout expires before the appropriate condition is satisfied, the request fails and returns an error. + def post_voting_config_exclusions(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_cluster/voting_config_exclusions' - method = OpenSearch::API::HTTP_POST - path = '_cluster/voting_config_exclusions' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, POST_VOTING_CONFIG_EXCLUSIONS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:post_voting_config_exclusions, %i[ + POST_VOTING_CONFIG_EXCLUSIONS_QUERY_PARAMS = Set.new(%w[ node_ids node_names timeout - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cluster/put_component_template.rb b/lib/opensearch/api/actions/cluster/put_component_template.rb index a5e3530e2..081349e8b 100644 --- a/lib/opensearch/api/actions/cluster/put_component_template.rb +++ b/lib/opensearch/api/actions/cluster/put_component_template.rb @@ -3,69 +3,46 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Cluster module Actions - # Creates or updates a component template - # - # @option arguments [String] :name The name of the template - # @option arguments [Boolean] :create Whether the index template should only be added if new or can also replace an existing one - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The template definition (*Required*) - # + # Creates or updates a component template. # - def put_component_template(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] + # @option args [String] :name *Required* Name of the component template to create. OpenSearch includes the following built-in component templates: `logs-mappings`; 'logs-settings`; `metrics-mappings`; `metrics-settings`;`synthetics-mapping`; `synthetics-settings`. OpenSearch Agent uses these templates to configure backing indexes for its data streams. If you use OpenSearch Agent and want to overwrite one of these templates, set the `version` for your replacement template higher than the current version. If you don't use OpenSearch Agent and want to disable all built-in component and index templates, set `stack.templates.enabled` to `false` using the cluster update settings API. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :create If `true`, this request cannot replace or update existing component templates. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Operation timeout. + # @option args [Hash] :body *Required* The template definition + def put_component_template(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - headers = arguments.delete(:headers) || {} + _name = args.delete('name') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_component_template', _name].filter(&:present?).join('/').squeeze('/') - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_PUT - path = "_component_template/#{Utils.__listify(_name)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, PUT_COMPONENT_TEMPLATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:put_component_template, %i[ + PUT_COMPONENT_TEMPLATE_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout create - timeout master_timeout - cluster_manager_timeout - ].freeze) + timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cluster/put_decommission_awareness.rb b/lib/opensearch/api/actions/cluster/put_decommission_awareness.rb new file mode 100644 index 000000000..e131a93a3 --- /dev/null +++ b/lib/opensearch/api/actions/cluster/put_decommission_awareness.rb @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Cluster + module Actions + # Decommissions an awareness attribute. + # + # @option args [String] :awareness_attribute_name *Required* Awareness attribute name. + # @option args [String] :awareness_attribute_value *Required* Awareness attribute value. + def put_decommission_awareness(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'awareness_attribute_name' missing" unless args['awareness_attribute_name'] + raise ArgumentError, "Required argument 'awareness_attribute_value' missing" unless args['awareness_attribute_value'] + + _awareness_attribute_name = args.delete('awareness_attribute_name') + _awareness_attribute_value = args.delete('awareness_attribute_value') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_cluster/decommission/awareness', _awareness_attribute_name, _awareness_attribute_value].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/cluster/put_settings.rb b/lib/opensearch/api/actions/cluster/put_settings.rb index d2c60a59b..1df2d8680 100644 --- a/lib/opensearch/api/actions/cluster/put_settings.rb +++ b/lib/opensearch/api/actions/cluster/put_settings.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,38 +15,30 @@ module Cluster module Actions # Updates the cluster settings. # - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart). (*Required*) - # - # - def put_settings(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :flat_settings Return settings in flat format. + # @option args [String] :master_timeout DEPRECATED Explicit operation timeout for connection to cluster-manager node + # @option args [String] :timeout Explicit operation timeout + # @option args [Hash] :body *Required* The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart). + def put_settings(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - method = OpenSearch::API::HTTP_PUT - path = '_cluster/settings' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = '_cluster/settings' - body = arguments[:body] || {} - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, PUT_SETTINGS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:put_settings, %i[ + PUT_SETTINGS_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout flat_settings master_timeout - cluster_manager_timeout timeout - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cluster/put_weighted_routing.rb b/lib/opensearch/api/actions/cluster/put_weighted_routing.rb new file mode 100644 index 000000000..6ea02abc0 --- /dev/null +++ b/lib/opensearch/api/actions/cluster/put_weighted_routing.rb @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Cluster + module Actions + # Updates weighted shard routing weights. + # + # @option args [String] :attribute *Required* Awareness attribute name. + # @option args [Hash] :body + def put_weighted_routing(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'attribute' missing" unless args['attribute'] + + _attribute = args.delete('attribute') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_cluster/routing/awareness', _attribute, 'weights'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/cluster/remote_info.rb b/lib/opensearch/api/actions/cluster/remote_info.rb index f3d3ccbb0..250ef1190 100644 --- a/lib/opensearch/api/actions/cluster/remote_info.rb +++ b/lib/opensearch/api/actions/cluster/remote_info.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,20 +15,15 @@ module Cluster module Actions # Returns the information about configured remote clusters. # - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def remote_info(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - method = OpenSearch::API::HTTP_GET - path = '_remote/info' - params = {} + def remote_info(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_remote/info' - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/cluster/reroute.rb b/lib/opensearch/api/actions/cluster/reroute.rb index 8ed9afced..5f675cc01 100644 --- a/lib/opensearch/api/actions/cluster/reroute.rb +++ b/lib/opensearch/api/actions/cluster/reroute.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,42 +15,34 @@ module Cluster module Actions # Allows to manually change the allocation of individual shards in the cluster. # - # @option arguments [Boolean] :dry_run Simulate the operation only and return the resulting state - # @option arguments [Boolean] :explain Return an explanation of why the commands can or cannot be executed - # @option arguments [Boolean] :retry_failed Retries allocation of shards that are blocked due to too many subsequent allocation failures - # @option arguments [List] :metric Limit the information returned to the specified metrics. Defaults to all but metadata (options: _all, blocks, metadata, nodes, routing_table, cluster_manager_node, version) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The definition of `commands` to perform (`move`, `cancel`, `allocate`) - # - # - def reroute(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :dry_run If `true`, then the request simulates the operation only and returns the resulting state. + # @option args [Boolean] :explain If `true`, then the response contains an explanation of why the commands can or cannot be executed. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Enumerable, String] :metric Limits the information returned to the specified metrics. + # @option args [Boolean] :retry_failed If `true`, then retries allocation of shards that are blocked due to too many subsequent allocation failures. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Hash] :body The definition of `commands` to perform (`move`, `cancel`, `allocate`) + def reroute(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_cluster/reroute' - method = OpenSearch::API::HTTP_POST - path = '_cluster/reroute' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] || {} - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, REROUTE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:reroute, %i[ + REROUTE_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout dry_run explain - retry_failed - metric master_timeout - cluster_manager_timeout + metric + retry_failed timeout - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cluster/state.rb b/lib/opensearch/api/actions/cluster/state.rb index 55e6ba1bc..10fceea98 100644 --- a/lib/opensearch/api/actions/cluster/state.rb +++ b/lib/opensearch/api/actions/cluster/state.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,57 +15,42 @@ module Cluster module Actions # Returns a comprehensive information about the state of the cluster. # - # @option arguments [List] :metric Limit the information returned to the specified metrics (options: _all, blocks, metadata, nodes, routing_table, routing_nodes, master_node, version) - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Number] :wait_for_metadata_version Wait for the metadata version to be equal or greater than the specified metadata version - # @option arguments [Time] :wait_for_timeout The maximum time to wait for wait_for_metadata_version before timing out - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def state(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _metric = arguments.delete(:metric) - - _index = arguments.delete(:index) + # @option args [Boolean] :allow_no_indices Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified) + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :expand_wildcards Whether to expand wildcard expression to concrete indexes that are open, closed or both. + # @option args [Boolean] :flat_settings Return settings in flat format. + # @option args [Boolean] :ignore_unavailable Whether specified concrete indexes should be ignored when unavailable (missing or closed) + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Specify timeout for connection to cluster manager. + # @option args [Integer] :wait_for_metadata_version Wait for the metadata version to be equal or greater than the specified metadata version. + # @option args [String] :wait_for_timeout The maximum time to wait for `wait_for_metadata_version` before timing out. + # @option args [Enumerable] :metric Limit the information returned to the specified metrics + # @option args [Enumerable, String] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indexes + def state(args = {}) + args = Utils.normalize_arguments(args) + _metric = args.delete('metric') + _index = args.delete('index') - method = OpenSearch::API::HTTP_GET - path = if _metric && _index - "_cluster/state/#{Utils.__listify(_metric)}/#{Utils.__listify(_index)}" - elsif _metric - "_cluster/state/#{Utils.__listify(_metric)}" - else - '_cluster/state' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cluster/state', _metric, _index].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, STATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:state, %i[ - local - master_timeout + STATE_QUERY_PARAMS = Set.new(%w[ + allow_no_indices cluster_manager_timeout + expand_wildcards flat_settings + ignore_unavailable + local + master_timeout wait_for_metadata_version wait_for_timeout - ignore_unavailable - allow_no_indices - expand_wildcards - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/cluster/stats.rb b/lib/opensearch/api/actions/cluster/stats.rb index 4302abb78..80b5ede66 100644 --- a/lib/opensearch/api/actions/cluster/stats.rb +++ b/lib/opensearch/api/actions/cluster/stats.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,38 +15,30 @@ module Cluster module Actions # Returns high-level overview of cluster statistics. # - # @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def stats(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Boolean] :flat_settings If `true`, returns settings in flat format. + # @option args [String] :timeout Period to wait for each node to respond. If a node does not respond before its timeout expires, the response does not include its stats. However, timed out nodes are included in the response's `_nodes.failed` property. Defaults to no timeout. + # @option args [Enumerable] :index_metric Limit the information returned for indexes metric to the specific index metrics. It can be used only if indexes (or all) metric is specified. + # @option args [Enumerable] :metric Limit the information returned to the specified metrics. + # @option args [Enumerable, String] :node_id Comma-separated list of node filters used to limit returned information. Defaults to all nodes in the cluster. + def stats(args = {}) + args = Utils.normalize_arguments(args) + _index_metric = args.delete('index_metric') + _metric = args.delete('metric') + _node_id = args.delete('node_id') - _node_id = arguments.delete(:node_id) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_cluster/stats', _metric, _index_metric, 'nodes', _node_id].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_GET - path = if _node_id - "_cluster/stats/nodes/#{Utils.__listify(_node_id)}" - else - '_cluster/stats' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, STATS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:stats, %i[ + STATS_QUERY_PARAMS = Set.new(%w[ flat_settings timeout - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/count.rb b/lib/opensearch/api/actions/count.rb index 64707b483..32345d778 100644 --- a/lib/opensearch/api/actions/count.rb +++ b/lib/opensearch/api/actions/count.rb @@ -3,94 +3,64 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Returns number of documents matching a query. - # - # @option arguments [List] :index A comma-separated list of indices to restrict the results - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :ignore_throttled Whether specified concrete, expanded or aliased indices should be ignored when throttled - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Number] :min_score Include only documents with a specific `_score` value in the result - # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) - # @option arguments [List] :routing A comma-separated list of specific routing values - # @option arguments [String] :q Query in the Lucene query string syntax - # @option arguments [String] :analyzer The analyzer to use for the query string - # @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false) - # @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR) - # @option arguments [String] :df The field to use as default where no field prefix is given in the query string - # @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - # @option arguments [Number] :terminate_after The maximum count for each shard, upon reaching which the query execution will terminate early - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body A query to restrict the results specified with the Query DSL (optional) - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def count(arguments = {}) - headers = arguments.delete(:headers) || {} + module Root + module Actions + # Returns number of documents matching a query. + # + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [Boolean] :analyze_wildcard If `true`, wildcard and prefix queries are analyzed. This parameter can only be used when the `q` query string parameter is specified. + # @option args [String] :analyzer Analyzer to use for the query string. This parameter can only be used when the `q` query string parameter is specified. + # @option args [String] :default_operator The default operator for query string query: `AND` or `OR`. This parameter can only be used when the `q` query string parameter is specified. + # @option args [String] :df Field to use as default where no field prefix is given in the query string. This parameter can only be used when the `q` query string parameter is specified. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. + # @option args [Boolean] :ignore_throttled If `true`, concrete, expanded or aliased indexes are ignored when frozen. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Boolean] :lenient If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. + # @option args [Float] :min_score Sets the minimum `_score` value that documents must have to be included in the result. + # @option args [String] :preference Specifies the node or shard the operation should be performed on. Random by default. + # @option args [String] :q Query in the Lucene query string syntax. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [Integer] :terminate_after Maximum number of documents to collect for each shard. If a query reaches this limit, OpenSearch terminates the query early. OpenSearch collects documents before sorting. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams and indexes, omit this parameter or use `*` or `_all`. + # @option args [Hash] :body Query to restrict the results specified with the Query DSL (optional) + def count(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = [_index, '_count'].filter(&:present?).join('/').squeeze('/') - _index = arguments.delete(:index) + Utils.validate_query_params args, COUNT_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - method = OpenSearch::API::HTTP_POST - path = if _index - "#{Utils.__listify(_index)}/_count" - else - '_count' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + COUNT_QUERY_PARAMS = Set.new(%w[ + allow_no_indices + analyze_wildcard + analyzer + default_operator + df + expand_wildcards + ignore_throttled + ignore_unavailable + lenient + min_score + preference + q + routing + terminate_after + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:count, %i[ - ignore_unavailable - ignore_throttled - allow_no_indices - expand_wildcards - min_score - preference - routing - q - analyzer - analyze_wildcard - default_operator - df - lenient - terminate_after - ].freeze) end end end diff --git a/lib/opensearch/api/actions/create.rb b/lib/opensearch/api/actions/create.rb index 1672dc841..4fd3bd6f2 100644 --- a/lib/opensearch/api/actions/create.rb +++ b/lib/opensearch/api/actions/create.rb @@ -3,57 +3,56 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Creates a new document in the index. - # - # Returns a 409 response when a document with a same ID already exists in the index. - # - # @option arguments [String] :id Document ID - # @option arguments [String] :index The name of the index - # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - # @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for) - # @option arguments [String] :routing Specific routing value - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Number] :version Explicit version number for concurrency control - # @option arguments [String] :version_type Specific version type (options: internal, external, external_gte) - # @option arguments [String] :pipeline The pipeline id to preprocess incoming documents with - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The document (*Required*) - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - def create(arguments = {}) - if arguments[:id] - index arguments.update op_type: 'create' - else - index arguments + module Root + module Actions + # Creates a new document in the index. + # Returns a 409 response when a document with a same ID already exists in the index. + # + # @option args [String] :id *Required* Unique identifier for the document. + # @option args [String] :index *Required* Name of the data stream or index to target. If the target doesn't exist and matches the name or wildcard (`*`) pattern of an index template with a `data_stream` definition, this request creates the data stream. If the target doesn't exist and doesn't match a data stream template, this request creates the index. + # @option args [String] :pipeline ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request. If a final pipeline is configured it will always run, regardless of the value of this parameter. + # @option args [Boolean, String] :refresh If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes. Valid values: `true`, `false`, `wait_for`. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [String] :timeout Period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. + # @option args [Integer] :version Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed. + # @option args [String] :version_type Specific version type: `external`, `external_gte`. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + # @option args [Hash] :body *Required* The document + def create(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _id = args.delete('id') + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_index, '_create', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, CREATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end + + CREATE_QUERY_PARAMS = Set.new(%w[ + pipeline + refresh + routing + timeout + version + version_type + wait_for_active_shards + ]).freeze end end end diff --git a/lib/opensearch/api/actions/create_pit.rb b/lib/opensearch/api/actions/create_pit.rb index 2d95f565f..f433cc0ec 100644 --- a/lib/opensearch/api/actions/create_pit.rb +++ b/lib/opensearch/api/actions/create_pit.rb @@ -3,43 +3,47 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Creates a point in time. - # - # @option arguments [String] :index The name(s) of the target index(es) for the PIT. May contain a comma-separated list or a wildcard index pattern. (required) - # @option arguments [String] :keep_alive The amount of time to keep the PIT. (required) - # @option arguments [String] :preference The node or the shard used to perform the search. (default: random) - # @option arguments [String] :routing Specifies to route search requests to a specific shard. - # @option arguments [String] :expand_wildcards The type of index that can match the wildcard pattern. Supports comma-separated values. (default: open) - # @option arguments [String] :allow_partial_pit_creation Specifies whether to create a PIT with partial failures. (default: false) - def create_pit(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'keep_alive' missing" unless arguments[:keep_alive] + module Root + module Actions + # Creates point in time context. + # + # @option args [Enumerable] :index *Required* Comma-separated list of indexes; use `_all` or empty string to perform the operation on all indexes. + # @option args [Boolean] :allow_partial_pit_creation Allow if point in time can be created with partial failures. + # @option args [Enumerable, String] :expand_wildcards Whether to expand wildcard expression to concrete indexes that are open, closed or both. + # @option args [String] :keep_alive Specify the keep alive for point in time. + # @option args [String] :preference Specify the node or shard the operation should be performed on. + # @option args [Enumerable, String] :routing Comma-separated list of specific routing values. + def create_pit(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] - arguments = arguments.clone - _index = arguments.delete(:index) + _index = args.delete('index') - method = OpenSearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_search/point_in_time" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - body = nil + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_index, '_search/point_in_time'].filter(&:present?).join('/').squeeze('/') - perform_request(method, path, params, body).body - end + Utils.validate_query_params args, CREATE_PIT_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - ParamsRegistry.register(:create_pit, %i[ - keep_alive - preference - routing - expand_wildcards - allow_partial_pit_creation - ].freeze) + CREATE_PIT_QUERY_PARAMS = Set.new(%w[ + allow_partial_pit_creation + expand_wildcards + keep_alive + preference + routing + ]).freeze + end end end end diff --git a/lib/opensearch/api/actions/dangling_indices/delete_dangling_index.rb b/lib/opensearch/api/actions/dangling_indices/delete_dangling_index.rb index 787d67a39..c24721890 100644 --- a/lib/opensearch/api/actions/dangling_indices/delete_dangling_index.rb +++ b/lib/opensearch/api/actions/dangling_indices/delete_dangling_index.rb @@ -3,67 +3,47 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module DanglingIndices module Actions - # Deletes the specified dangling index - # - # @option arguments [String] :index_uuid The UUID of the dangling index - # @option arguments [Boolean] :accept_data_loss Must be set to true in order to delete the dangling index - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # + # Deletes the specified dangling index. # - def delete_dangling_index(arguments = {}) - raise ArgumentError, "Required argument 'index_uuid' missing" unless arguments[:index_uuid] + # @option args [String] :index_uuid *Required* The UUID of the dangling index. + # @option args [Boolean] :accept_data_loss *Required* Must be set to true in order to delete the dangling index. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Specify timeout for connection to cluster manager. + # @option args [String] :timeout Explicit operation timeout. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_dangling_index(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index_uuid' missing" unless args['index_uuid'] + raise ArgumentError, "Required argument 'accept_data_loss' missing" unless args['accept_data_loss'] - headers = arguments.delete(:headers) || {} + _index_uuid = args.delete('index_uuid') - arguments = arguments.clone + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_dangling', _index_uuid].filter(&:present?).join('/').squeeze('/') - _index_uuid = arguments.delete(:index_uuid) - - method = OpenSearch::API::HTTP_DELETE - path = "_dangling/#{Utils.__listify(_index_uuid)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, DELETE_DANGLING_INDEX_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:delete_dangling_index, %i[ + DELETE_DANGLING_INDEX_QUERY_PARAMS = Set.new(%w[ accept_data_loss - timeout - master_timeout cluster_manager_timeout - ].freeze) + master_timeout + timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/dangling_indices/import_dangling_index.rb b/lib/opensearch/api/actions/dangling_indices/import_dangling_index.rb index 71015298b..7c0618c80 100644 --- a/lib/opensearch/api/actions/dangling_indices/import_dangling_index.rb +++ b/lib/opensearch/api/actions/dangling_indices/import_dangling_index.rb @@ -3,66 +3,45 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module DanglingIndices module Actions - # Imports the specified dangling index - # - # @option arguments [String] :index_uuid The UUID of the dangling index - # @option arguments [Boolean] :accept_data_loss Must be set to true in order to import the dangling index - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers + # Imports the specified dangling index. # - def import_dangling_index(arguments = {}) - raise ArgumentError, "Required argument 'index_uuid' missing" unless arguments[:index_uuid] + # @option args [String] :index_uuid *Required* The UUID of the dangling index. + # @option args [Boolean] :accept_data_loss *Required* Must be set to true in order to import the dangling index. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Specify timeout for connection to cluster manager. + # @option args [String] :timeout Explicit operation timeout. + def import_dangling_index(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index_uuid' missing" unless args['index_uuid'] + raise ArgumentError, "Required argument 'accept_data_loss' missing" unless args['accept_data_loss'] - headers = arguments.delete(:headers) || {} + _index_uuid = args.delete('index_uuid') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_dangling', _index_uuid].filter(&:present?).join('/').squeeze('/') - _index_uuid = arguments.delete(:index_uuid) - - method = OpenSearch::API::HTTP_POST - path = "_dangling/#{Utils.__listify(_index_uuid)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, IMPORT_DANGLING_INDEX_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:import_dangling_index, %i[ + IMPORT_DANGLING_INDEX_QUERY_PARAMS = Set.new(%w[ accept_data_loss - timeout - master_timeout cluster_manager_timeout - ].freeze) + master_timeout + timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/dangling_indices/list_dangling_indices.rb b/lib/opensearch/api/actions/dangling_indices/list_dangling_indices.rb index 5d2048a0f..3696e9338 100644 --- a/lib/opensearch/api/actions/dangling_indices/list_dangling_indices.rb +++ b/lib/opensearch/api/actions/dangling_indices/list_dangling_indices.rb @@ -3,47 +3,27 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module DanglingIndices module Actions - # Returns all dangling indices. - # - # @option arguments [Hash] :headers Custom HTTP headers - # + # Returns all dangling indexes. # - def list_dangling_indices(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - method = OpenSearch::API::HTTP_GET - path = '_dangling' - params = {} + def list_dangling_indices(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_dangling' - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/dangling_indices/params_registry.rb b/lib/opensearch/api/actions/dangling_indices/params_registry.rb deleted file mode 100644 index e09b65879..000000000 --- a/lib/opensearch/api/actions/dangling_indices/params_registry.rb +++ /dev/null @@ -1,69 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module DanglingIndices - module Actions - module ParamsRegistry - extend self - - # A Mapping of all the actions to their list of valid params. - # - # @since 6.1.1 - PARAMS = {} - - # Register an action with its list of valid params. - # - # @example Register the action. - # ParamsRegistry.register(:benchmark, [ :verbose ]) - # - # @param [ Symbol ] action The action to register. - # @param [ Array[Symbol] ] valid_params The list of valid params. - # - # @since 6.1.1 - def register(action, valid_params) - PARAMS[action.to_sym] = valid_params - end - - # Get the list of valid params for a given action. - # - # @example Get the list of valid params. - # ParamsRegistry.get(:benchmark) - # - # @param [ Symbol ] action The action. - # - # @return [ Array ] The list of valid params for the action. - # - # @since 6.1.1 - def get(action) - PARAMS.fetch(action, []) - end - end - end - end - end -end diff --git a/lib/opensearch/api/actions/delete.rb b/lib/opensearch/api/actions/delete.rb index 69baf282a..2c06289bf 100644 --- a/lib/opensearch/api/actions/delete.rb +++ b/lib/opensearch/api/actions/delete.rb @@ -3,87 +3,58 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Actions - # Removes a document from the index. - # - # @option arguments [String] :id The document ID - # @option arguments [String] :index The name of the index - # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - # @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for) - # @option arguments [String] :routing Specific routing value - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Number] :if_seq_no only perform the delete operation if the last operation that has changed the document has the specified sequence number - # @option arguments [Number] :if_primary_term only perform the delete operation if the last operation that has changed the document has the specified primary term - # @option arguments [Number] :version Explicit version number for concurrency control - # @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) - # @option arguments [Hash] :headers Custom HTTP headers - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def delete(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - _id = arguments.delete(:id) - - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_DELETE - path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body } - else - perform_request(method, path, params, body, headers).body +module OpenSearch + module API + module Root + module Actions + # Removes a document from the index. + # + # @option args [String] :id *Required* Unique identifier for the document. + # @option args [String] :index *Required* Name of the target index. + # @option args [Integer] :if_primary_term Only perform the operation if the document has this primary term. + # @option args [Integer] :if_seq_no Only perform the operation if the document has this sequence number. + # @option args [Boolean, String] :refresh If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes. Valid values: `true`, `false`, `wait_for`. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [String] :timeout Period to wait for active shards. + # @option args [Integer] :version Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed. + # @option args [String] :version_type Specific version type: `external`, `external_gte`. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + + _id = args.delete('id') + _index = args.delete('index') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = [_index, '_doc', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, DELETE_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end - end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:delete, %i[ - wait_for_active_shards - refresh - routing - timeout - if_seq_no - if_primary_term - version - version_type - ].freeze) + DELETE_QUERY_PARAMS = Set.new(%w[ + if_primary_term + if_seq_no + refresh + routing + timeout + version + version_type + wait_for_active_shards + ]).freeze + end end end end diff --git a/lib/opensearch/api/actions/delete_all_pits.rb b/lib/opensearch/api/actions/delete_all_pits.rb index 2bdbe0509..581164118 100644 --- a/lib/opensearch/api/actions/delete_all_pits.rb +++ b/lib/opensearch/api/actions/delete_all_pits.rb @@ -3,24 +3,31 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Deletes all PITs. - def delete_all_pits(arguments = {}) - method = OpenSearch::API::HTTP_DELETE - path = '_search/point_in_time/_all' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - body = nil + module Root + module Actions + # Deletes all active point in time searches. + # + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_all_pits(args = {}) + args = Utils.normalize_arguments(args) + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = '_search/point_in_time/_all' - perform_request(method, path, params, body).body + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end end - - ParamsRegistry.register(:delete_all_pits, [].freeze) end end end diff --git a/lib/opensearch/api/actions/delete_by_query.rb b/lib/opensearch/api/actions/delete_by_query.rb index d9c792fb9..cae638de4 100644 --- a/lib/opensearch/api/actions/delete_by_query.rb +++ b/lib/opensearch/api/actions/delete_by_query.rb @@ -3,131 +3,105 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Deletes documents matching the provided query. - # - # @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices (*Required*) - # @option arguments [String] :analyzer The analyzer to use for the query string - # @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false) - # @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR) - # @option arguments [String] :df The field to use as default where no field prefix is given in the query string - # @option arguments [Number] :from Starting offset (default: 0) - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :conflicts What to do when the delete by query hits version conflicts? (options: abort, proceed) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) - # @option arguments [String] :q Query in the Lucene query string syntax - # @option arguments [List] :routing A comma-separated list of specific routing values - # @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search - # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) - # @option arguments [Time] :search_timeout Explicit timeout for each search request. Defaults to no timeout. - # @option arguments [Number] :size Deprecated, please use `max_docs` instead - # @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents) - # @option arguments [List] :sort A comma-separated list of : pairs - # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return - # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field - # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field - # @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - # @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes - # @option arguments [Boolean] :version Specify whether to return document version as part of a hit - # @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting - # @option arguments [Boolean] :refresh Should the effected indexes be refreshed? - # @option arguments [Time] :timeout Time each individual bulk request should wait for shards that are unavailable. - # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - # @option arguments [Number] :scroll_size Size on the scroll request powering the delete by query - # @option arguments [Boolean] :wait_for_completion Should the request should block until the delete by query is complete. - # @option arguments [Number] :requests_per_second The throttle for this request in sub-requests per second. -1 means no throttle. - # @option arguments [Number|string] :slices The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search definition using the Query DSL (*Required*) - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def delete_by_query(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] + module Root + module Actions + # Deletes documents matching the provided query. + # + # @option args [Enumerable, String] :index *Required* Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams or indexes, omit this parameter or use `*` or `_all`. + # @option args [Enumerable] :_source Set to `true` or `false` to return the `_source` field or not, or a list of fields to return. + # @option args [Enumerable] :_source_excludes List of fields to exclude from the returned `_source` field. + # @option args [Enumerable] :_source_includes List of fields to extract and return from the `_source` field. + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. + # @option args [Boolean] :analyze_wildcard If `true`, wildcard and prefix queries are analyzed. + # @option args [String] :analyzer Analyzer to use for the query string. + # @option args [String] :conflicts What to do if delete by query hits version conflicts: `abort` or `proceed`. + # @option args [String] :default_operator The default operator for query string query: `AND` or `OR`. + # @option args [String] :df Field to use as default where no field prefix is given in the query string. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Integer] :from Starting offset. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Boolean] :lenient If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. + # @option args [Integer] :max_docs Maximum number of documents to process. Defaults to all documents. + # @option args [String] :preference Specifies the node or shard the operation should be performed on. Random by default. + # @option args [String] :q Query in the Lucene query string syntax. + # @option args [Boolean, String] :refresh If `true`, OpenSearch refreshes all shards involved in the delete by query after the request completes. + # @option args [Boolean] :request_cache If `true`, the request cache is used for this request. Defaults to the index-level setting. + # @option args [Float] :requests_per_second The throttle for this request in sub-requests per second. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [String] :scroll Period to retain the search context for scrolling. + # @option args [Integer] :scroll_size Size of the scroll request that powers the operation. + # @option args [String] :search_timeout Explicit timeout for each search request. Defaults to no timeout. + # @option args [String] :search_type The type of the search operation. Available options: `query_then_fetch`, `dfs_query_then_fetch`. + # @option args [Integer] :size Deprecated, use `max_docs` instead. + # @option args [Float, String] :slices The number of slices this task should be divided into. + # @option args [Enumerable] :sort A comma-separated list of : pairs. + # @option args [Enumerable] :stats Specific `tag` of the request for logging and statistical purposes. + # @option args [Integer] :terminate_after Maximum number of documents to collect for each shard. If a query reaches this limit, OpenSearch terminates the query early. OpenSearch collects documents before sorting. Use with caution. OpenSearch applies this parameter to each shard handling the request. When possible, let OpenSearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indexes across multiple data tiers. + # @option args [String] :timeout Period each deletion request waits for active shards. + # @option args [Boolean] :version If `true`, returns the document version as part of a hit. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + # @option args [Boolean] :wait_for_completion If `true`, the request blocks until the operation is complete. + # @option args [Hash] :body *Required* The search definition using the Query DSL + def delete_by_query(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - headers = arguments.delete(:headers) || {} + _index = args.delete('index') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_index, '_delete_by_query'].filter(&:present?).join('/').squeeze('/') - _index = arguments.delete(:index) + Utils.validate_query_params args, DELETE_BY_QUERY_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - method = OpenSearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_delete_by_query" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + DELETE_BY_QUERY_QUERY_PARAMS = Set.new(%w[ + _source + _source_excludes + _source_includes + allow_no_indices + analyze_wildcard + analyzer + conflicts + default_operator + df + expand_wildcards + from + ignore_unavailable + lenient + max_docs + preference + q + refresh + request_cache + requests_per_second + routing + scroll + scroll_size + search_timeout + search_type + size + slices + sort + stats + terminate_after + timeout + version + wait_for_active_shards + wait_for_completion + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:delete_by_query, %i[ - analyzer - analyze_wildcard - default_operator - df - from - ignore_unavailable - allow_no_indices - conflicts - expand_wildcards - lenient - preference - q - routing - scroll - search_type - search_timeout - size - max_docs - sort - _source - _source_excludes - _source_includes - terminate_after - stats - version - request_cache - refresh - timeout - wait_for_active_shards - scroll_size - wait_for_completion - requests_per_second - slices - ].freeze) end end end diff --git a/lib/opensearch/api/actions/delete_by_query_rethrottle.rb b/lib/opensearch/api/actions/delete_by_query_rethrottle.rb index 560e3850c..f4a58f831 100644 --- a/lib/opensearch/api/actions/delete_by_query_rethrottle.rb +++ b/lib/opensearch/api/actions/delete_by_query_rethrottle.rb @@ -3,60 +3,39 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Changes the number of requests per second for a particular Delete By Query operation. - # - # @option arguments [String] :task_id The task id to rethrottle - # @option arguments [Number] :requests_per_second The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. (*Required*) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def delete_by_query_rethrottle(arguments = {}) - raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id] + module Root + module Actions + # Changes the number of requests per second for a particular Delete By Query operation. + # + # @option args [Float, String] :task_id *Required* The ID for the task. + # @option args [Float] :requests_per_second The throttle for this request in sub-requests per second. + def delete_by_query_rethrottle(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'task_id' missing" unless args['task_id'] - headers = arguments.delete(:headers) || {} + _task_id = args.delete('task_id') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_delete_by_query', _task_id, '_rethrottle'].filter(&:present?).join('/').squeeze('/') - _task_id = arguments.delete(:task_id) + Utils.validate_query_params args, DELETE_BY_QUERY_RETHROTTLE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - method = OpenSearch::API::HTTP_POST - path = "_delete_by_query/#{Utils.__listify(_task_id)}/_rethrottle" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + DELETE_BY_QUERY_RETHROTTLE_QUERY_PARAMS = Set.new(%w[ + requests_per_second + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:delete_by_query_rethrottle, [ - :requests_per_second - ].freeze) end end end diff --git a/lib/opensearch/api/actions/delete_pit.rb b/lib/opensearch/api/actions/delete_pit.rb index 35cc8684c..24f821967 100644 --- a/lib/opensearch/api/actions/delete_pit.rb +++ b/lib/opensearch/api/actions/delete_pit.rb @@ -3,28 +3,32 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Deletes one or several PITs. - # - # @option arguments [Hash] body: Must include `pit_id`, which is an array of PIT IDs to be deleted. (required) - def delete_pit(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + module Root + module Actions + # Deletes one or more point in time searches based on the IDs passed. + # + # @option args [Hash] :body The point-in-time ids to be deleted + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_pit(args = {}) + args = Utils.normalize_arguments(args) + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = '_search/point_in_time' - method = OpenSearch::API::HTTP_DELETE - path = '_search/point_in_time' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - body = arguments[:body] - - perform_request(method, path, params, body).body + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end end - - ParamsRegistry.register(:delete_pit, [].freeze) end end end diff --git a/lib/opensearch/api/actions/delete_script.rb b/lib/opensearch/api/actions/delete_script.rb index de86e7b6c..3e035a3b8 100644 --- a/lib/opensearch/api/actions/delete_script.rb +++ b/lib/opensearch/api/actions/delete_script.rb @@ -3,64 +3,45 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Deletes a script. - # - # @option arguments [String] :id Script ID - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def delete_script(arguments = {}) - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] + module Root + module Actions + # Deletes a script. + # + # @option args [String] :id *Required* Identifier for the stored script or search template. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_script(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] - headers = arguments.delete(:headers) || {} + _id = args.delete('id') - arguments = arguments.clone + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_scripts', _id].filter(&:present?).join('/').squeeze('/') - _id = arguments.delete(:id) + Utils.validate_query_params args, DELETE_SCRIPT_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end - method = OpenSearch::API::HTTP_DELETE - path = "_scripts/#{Utils.__listify(_id)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + DELETE_SCRIPT_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout + master_timeout + timeout + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:delete_script, %i[ - timeout - master_timeout - cluster_manager_timeout - ].freeze) end end end diff --git a/lib/opensearch/api/actions/exists.rb b/lib/opensearch/api/actions/exists.rb index e9123193f..ff9e268fe 100644 --- a/lib/opensearch/api/actions/exists.rb +++ b/lib/opensearch/api/actions/exists.rb @@ -3,92 +3,60 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Actions - # Returns information about whether a document exists in an index. - # - # @option arguments [String] :id The document ID - # @option arguments [String] :index The name of the index - # @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response - # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) - # @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode - # @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation - # @option arguments [String] :routing Specific routing value - # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return - # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field - # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field - # @option arguments [Number] :version Explicit version number for concurrency control - # @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) - # @option arguments [Hash] :headers Custom HTTP headers - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def exists(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] - - headers = arguments.delete(:headers) || {} - arguments = arguments.clone +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - _id = arguments.delete(:id) +# frozen_string_literal: true - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_HEAD - path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - - Utils.__rescue_from_not_found do - perform_request(method, path, params, body, headers).status == 200 +module OpenSearch + module API + module Root + module Actions + # Returns information about whether a document exists in an index. + # + # @option args [String] :id *Required* Identifier of the document. + # @option args [String] :index *Required* Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). + # @option args [Boolean, Enumerable, String] :_source `true` or `false` to return the `_source` field or not, or a list of fields to return. + # @option args [Enumerable, String] :_source_excludes A comma-separated list of source fields to exclude in the response. + # @option args [Enumerable, String] :_source_includes A comma-separated list of source fields to include in the response. + # @option args [String] :preference Specifies the node or shard the operation should be performed on. Random by default. + # @option args [Boolean] :realtime If `true`, the request is real-time as opposed to near-real-time. + # @option args [Boolean, String] :refresh If `true`, OpenSearch refreshes all shards involved in the delete by query after the request completes. + # @option args [Enumerable, String] :routing Target the specified primary shard. + # @option args [Enumerable, String] :stored_fields List of stored fields to return as part of a hit. If no fields are specified, no stored fields are included in the response. If this field is specified, the `_source` parameter defaults to false. + # @option args [Integer] :version Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed. + # @option args [String] :version_type Specific version type: `external`, `external_gte`. + def exists(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + + _id = args.delete('id') + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'HEAD' + url = [_index, '_doc', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, EXISTS_QUERY_PARAMS + transport.perform_head_request method, url, args, body, headers end - end - alias exists? exists - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:exists, %i[ - stored_fields - preference - realtime - refresh - routing - _source - _source_excludes - _source_includes - version - version_type - ].freeze) + EXISTS_QUERY_PARAMS = Set.new(%w[ + _source + _source_excludes + _source_includes + preference + realtime + refresh + routing + stored_fields + version + version_type + ]).freeze + end end end end diff --git a/lib/opensearch/api/actions/exists_source.rb b/lib/opensearch/api/actions/exists_source.rb index c4e1f5c4e..9fcc9981a 100644 --- a/lib/opensearch/api/actions/exists_source.rb +++ b/lib/opensearch/api/actions/exists_source.rb @@ -3,87 +3,58 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Actions - # Returns information about whether a document source exists in an index. - # - # @option arguments [String] :id The document ID - # @option arguments [String] :index The name of the index - # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) - # @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode - # @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation - # @option arguments [String] :routing Specific routing value - # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return - # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field - # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field - # @option arguments [Number] :version Explicit version number for concurrency control - # @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) - # @option arguments [Hash] :headers Custom HTTP headers - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def exists_source(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - _id = arguments.delete(:id) - - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_HEAD - path = "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body +module OpenSearch + module API + module Root + module Actions + # Returns information about whether a document source exists in an index. + # + # @option args [String] :id *Required* Identifier of the document. + # @option args [String] :index *Required* Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). + # @option args [Boolean, Enumerable, String] :_source `true` or `false` to return the `_source` field or not, or a list of fields to return. + # @option args [Enumerable, String] :_source_excludes A comma-separated list of source fields to exclude in the response. + # @option args [Enumerable, String] :_source_includes A comma-separated list of source fields to include in the response. + # @option args [String] :preference Specifies the node or shard the operation should be performed on. Random by default. + # @option args [Boolean] :realtime If `true`, the request is real-time as opposed to near-real-time. + # @option args [Boolean, String] :refresh If `true`, OpenSearch refreshes all shards involved in the delete by query after the request completes. + # @option args [Enumerable, String] :routing Target the specified primary shard. + # @option args [Integer] :version Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed. + # @option args [String] :version_type Specific version type: `external`, `external_gte`. + def exists_source(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + + _id = args.delete('id') + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'HEAD' + url = [_index, '_source', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, EXISTS_SOURCE_QUERY_PARAMS + transport.perform_head_request method, url, args, body, headers + end + + EXISTS_SOURCE_QUERY_PARAMS = Set.new(%w[ + _source + _source_excludes + _source_includes + preference + realtime + refresh + routing + version + version_type + ]).freeze end - - alias exists_source? exists_source - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:exists_source, %i[ - preference - realtime - refresh - routing - _source - _source_excludes - _source_includes - version - version_type - ].freeze) end end end diff --git a/lib/opensearch/api/actions/explain.rb b/lib/opensearch/api/actions/explain.rb index c42ed2a86..f8115c4f8 100644 --- a/lib/opensearch/api/actions/explain.rb +++ b/lib/opensearch/api/actions/explain.rb @@ -3,97 +3,65 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Actions - # Returns information about why a specific matches (or doesn't match) a query. - # - # @option arguments [String] :id The document ID - # @option arguments [String] :index The name of the index - # @option arguments [Boolean] :analyze_wildcard Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) - # @option arguments [String] :analyzer The analyzer for the query string query - # @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR) - # @option arguments [String] :df The default field for query string query (default: _all) - # @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response - # @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) - # @option arguments [String] :q Query in the Lucene query string syntax - # @option arguments [String] :routing Specific routing value - # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return - # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field - # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The query definition using the Query DSL - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def explain(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - _id = arguments.delete(:id) +module OpenSearch + module API + module Root + module Actions + # Returns information about why a specific matches (or doesn't match) a query. + # + # @option args [String] :id *Required* Defines the document ID. + # @option args [String] :index *Required* Index names used to limit the request. Only a single index name can be provided to this parameter. + # @option args [Boolean, Enumerable, String] :_source Set to `true` or `false` to return the `_source` field or not, or a list of fields to return. + # @option args [Enumerable, String] :_source_excludes A comma-separated list of source fields to exclude from the response. + # @option args [Enumerable, String] :_source_includes A comma-separated list of source fields to include in the response. + # @option args [Boolean] :analyze_wildcard If `true`, wildcard and prefix queries are analyzed. + # @option args [String] :analyzer Analyzer to use for the query string. This parameter can only be used when the `q` query string parameter is specified. + # @option args [String] :default_operator The default operator for query string query: `AND` or `OR`. + # @option args [String] :df Field to use as default where no field prefix is given in the query string. + # @option args [Boolean] :lenient If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. + # @option args [String] :preference Specifies the node or shard the operation should be performed on. Random by default. + # @option args [String] :q Query in the Lucene query string syntax. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [Enumerable, String] :stored_fields A comma-separated list of stored fields to return in the response. + # @option args [Hash] :body The query definition using the Query DSL + def explain(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + raise ArgumentError, "Required argument 'index' missing" unless args['index'] - _index = arguments.delete(:index) + _id = args.delete('id') + _index = args.delete('index') - method = if arguments[:body] - OpenSearch::API::HTTP_POST - else - OpenSearch::API::HTTP_GET - end + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = [_index, '_explain', _id].filter(&:present?).join('/').squeeze('/') - path = "#{Utils.__listify(_index)}/_explain/#{Utils.__listify(_id)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + Utils.validate_query_params args, EXPLAIN_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - body = arguments[:body] - perform_request(method, path, params, body, headers).body + EXPLAIN_QUERY_PARAMS = Set.new(%w[ + _source + _source_excludes + _source_includes + analyze_wildcard + analyzer + default_operator + df + lenient + preference + q + routing + stored_fields + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:explain, %i[ - analyze_wildcard - analyzer - default_operator - df - stored_fields - lenient - preference - q - routing - _source - _source_excludes - _source_includes - ].freeze) end end end diff --git a/lib/opensearch/api/actions/features/get_features.rb b/lib/opensearch/api/actions/features/get_features.rb deleted file mode 100644 index 63e22b85e..000000000 --- a/lib/opensearch/api/actions/features/get_features.rb +++ /dev/null @@ -1,61 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Features - module Actions - # Gets a list of features which can be included in snapshots using the feature_states field when creating a snapshot - # - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def get_features(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - method = OpenSearch::API::HTTP_GET - path = '_features' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body - end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_features, %i[ - master_timeout - cluster_manager_timeout - ].freeze) - end - end - end -end diff --git a/lib/opensearch/api/actions/features/params_registry.rb b/lib/opensearch/api/actions/features/params_registry.rb deleted file mode 100644 index 0fe68df58..000000000 --- a/lib/opensearch/api/actions/features/params_registry.rb +++ /dev/null @@ -1,69 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Features - module Actions - module ParamsRegistry - extend self - - # A Mapping of all the actions to their list of valid params. - # - # @since 6.1.1 - PARAMS = {} - - # Register an action with its list of valid params. - # - # @example Register the action. - # ParamsRegistry.register(:benchmark, [ :verbose ]) - # - # @param [ Symbol ] action The action to register. - # @param [ Array[Symbol] ] valid_params The list of valid params. - # - # @since 6.1.1 - def register(action, valid_params) - PARAMS[action.to_sym] = valid_params - end - - # Get the list of valid params for a given action. - # - # @example Get the list of valid params. - # ParamsRegistry.get(:benchmark) - # - # @param [ Symbol ] action The action. - # - # @return [ Array ] The list of valid params for the action. - # - # @since 6.1.1 - def get(action) - PARAMS.fetch(action, []) - end - end - end - end - end -end diff --git a/lib/opensearch/api/actions/features/reset_features.rb b/lib/opensearch/api/actions/features/reset_features.rb deleted file mode 100644 index 0369a62dd..000000000 --- a/lib/opensearch/api/actions/features/reset_features.rb +++ /dev/null @@ -1,55 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Features - module Actions - # Resets the internal state of features, usually by deleting system indices - # This functionality is Experimental and may be changed or removed - # completely in a future release. OpenSearch will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. - # - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def reset_features(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - method = OpenSearch::API::HTTP_POST - path = '_features/_reset' - params = {} - - body = nil - perform_request(method, path, params, body, headers).body - end - end - end - end -end diff --git a/lib/opensearch/api/actions/field_caps.rb b/lib/opensearch/api/actions/field_caps.rb index 4c2f46790..eae0f4a8b 100644 --- a/lib/opensearch/api/actions/field_caps.rb +++ b/lib/opensearch/api/actions/field_caps.rb @@ -3,76 +3,46 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -module OpenSearch - module API - module Actions - # Returns the information about the capabilities of fields among multiple indices. - # - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - # @option arguments [List] :fields A comma-separated list of field names - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :include_unmapped Indicates whether unmapped fields should be included in the response. - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body An index filter specified with the Query DSL - # - # - def field_caps(arguments = {}) - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - _index = arguments.delete(:index) +module OpenSearch + module API + module Root + module Actions + # Returns the information about the capabilities of fields among multiple indexes. + # + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting `foo*,bar*` returns an error if an index starts with foo but no index starts with bar. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. + # @option args [Enumerable, String] :fields Comma-separated list of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported. + # @option args [Boolean] :ignore_unavailable If `true`, missing or closed indexes are not included in the response. + # @option args [Boolean] :include_unmapped If `true`, unmapped fields are included in the response. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (*). To target all data streams and indexes, omit this parameter or use * or `_all`. + # @option args [Hash] :body An index filter specified with the Query DSL + def field_caps(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - method = if arguments[:body] - OpenSearch::API::HTTP_POST - else - OpenSearch::API::HTTP_GET - end + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = [_index, '_field_caps'].filter(&:present?).join('/').squeeze('/') - path = if _index - "#{Utils.__listify(_index)}/_field_caps" - else - '_field_caps' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + Utils.validate_query_params args, FIELD_CAPS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - body = arguments[:body] - perform_request(method, path, params, body, headers).body + FIELD_CAPS_QUERY_PARAMS = Set.new(%w[ + allow_no_indices + expand_wildcards + fields + ignore_unavailable + include_unmapped + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:field_caps, %i[ - fields - ignore_unavailable - allow_no_indices - expand_wildcards - include_unmapped - ].freeze) end end end diff --git a/lib/opensearch/api/actions/flow_framework/create.rb b/lib/opensearch/api/actions/flow_framework/create.rb new file mode 100644 index 000000000..7d9e34815 --- /dev/null +++ b/lib/opensearch/api/actions/flow_framework/create.rb @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module FlowFramework + module Actions + # Create a workflow. + # + # @option args [Boolean] :provision Provision the workflow as part of the request. + # @option args [Boolean] :reprovision + # @option args [Boolean] :update_fields Update only the fields included in the request body. + # @option args [String] :use_case To use a workflow template, specify it in the `use_case` query parameter when creating a workflow. + # @option args [String] :validation Validate the workflow. Valid values are all (validate the template) and none (do not validate the template). Default is all. + # @option args [Hash] :body + def create(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_flow_framework/workflow' + + Utils.validate_query_params args, CREATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + CREATE_QUERY_PARAMS = Set.new(%w[ + provision + reprovision + update_fields + use_case + validation + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/flow_framework/delete.rb b/lib/opensearch/api/actions/flow_framework/delete.rb new file mode 100644 index 000000000..6bad19359 --- /dev/null +++ b/lib/opensearch/api/actions/flow_framework/delete.rb @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module FlowFramework + module Actions + # Delete a workflow. + # + # @option args [String] :workflow_id *Required* + # @option args [Boolean] :clear_status Delete the workflow state (without deprovisioning resources) after deleting the template. OpenSearch deletes the workflow state only if the provisioning status is not IN_PROGRESS. Default is false. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'workflow_id' missing" unless args['workflow_id'] + + _workflow_id = args.delete('workflow_id') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_flow_framework/workflow', _workflow_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, DELETE_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + + DELETE_QUERY_PARAMS = Set.new(%w[ + clear_status + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/flow_framework/deprovision.rb b/lib/opensearch/api/actions/flow_framework/deprovision.rb new file mode 100644 index 000000000..046e7c0fd --- /dev/null +++ b/lib/opensearch/api/actions/flow_framework/deprovision.rb @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module FlowFramework + module Actions + # Deprovision workflow's resources when you no longer need it. + # + # @option args [String] :workflow_id *Required* + # @option args [String] :allow_delete Required when deleting resources involves a high potential for data loss. + def deprovision(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'workflow_id' missing" unless args['workflow_id'] + + _workflow_id = args.delete('workflow_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_flow_framework/workflow', _workflow_id, '_deprovision'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, DEPROVISION_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + DEPROVISION_QUERY_PARAMS = Set.new(%w[ + allow_delete + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/flow_framework/get.rb b/lib/opensearch/api/actions/flow_framework/get.rb new file mode 100644 index 000000000..90de1bc38 --- /dev/null +++ b/lib/opensearch/api/actions/flow_framework/get.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module FlowFramework + module Actions + # Get a workflow. + # + # @option args [String] :workflow_id *Required* + def get(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'workflow_id' missing" unless args['workflow_id'] + + _workflow_id = args.delete('workflow_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_flow_framework/workflow', _workflow_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/flow_framework/get_status.rb b/lib/opensearch/api/actions/flow_framework/get_status.rb new file mode 100644 index 000000000..df18f98be --- /dev/null +++ b/lib/opensearch/api/actions/flow_framework/get_status.rb @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module FlowFramework + module Actions + # Get the provisioning deployment status until it is complete. + # + # @option args [String] :workflow_id *Required* + # @option args [Boolean] :all The all parameter specifies whether the response should return all fields. + def get_status(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'workflow_id' missing" unless args['workflow_id'] + + _workflow_id = args.delete('workflow_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_flow_framework/workflow', _workflow_id, '_status'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, GET_STATUS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + GET_STATUS_QUERY_PARAMS = Set.new(%w[ + all + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/flow_framework/get_steps.rb b/lib/opensearch/api/actions/flow_framework/get_steps.rb new file mode 100644 index 000000000..fbd88f12a --- /dev/null +++ b/lib/opensearch/api/actions/flow_framework/get_steps.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module FlowFramework + module Actions + # Get a list of workflow steps. + # + # @option args [String] :workflow_step The name of the step to retrieve. + def get_steps(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_flow_framework/workflow/_steps' + + Utils.validate_query_params args, GET_STEPS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + GET_STEPS_QUERY_PARAMS = Set.new(%w[ + workflow_step + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/flow_framework/provision.rb b/lib/opensearch/api/actions/flow_framework/provision.rb new file mode 100644 index 000000000..2a4776cab --- /dev/null +++ b/lib/opensearch/api/actions/flow_framework/provision.rb @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module FlowFramework + module Actions + # Provisioning a workflow. This API is also executed when the Create or Update Workflow API is called with the provision parameter set to true. + # + # @option args [String] :workflow_id *Required* + # @option args [Hash] :body Pass dynamic substitution expressions as key-value pairs, either as query parameters or in the request body. For example, if you specified a credential field in the template as `openai_key: '$'`, you can pass `openai_key` as a query parameter or in the request body. + def provision(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'workflow_id' missing" unless args['workflow_id'] + + _workflow_id = args.delete('workflow_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_flow_framework/workflow', _workflow_id, '_provision'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/flow_framework/search.rb b/lib/opensearch/api/actions/flow_framework/search.rb new file mode 100644 index 000000000..60083c868 --- /dev/null +++ b/lib/opensearch/api/actions/flow_framework/search.rb @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module FlowFramework + module Actions + # Search for workflows by using a query matching a field. + # + # @option args [Hash] :body *Required* + def search(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = '_plugins/_flow_framework/workflow/_search' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/flow_framework/search_state.rb b/lib/opensearch/api/actions/flow_framework/search_state.rb new file mode 100644 index 000000000..9e666ad79 --- /dev/null +++ b/lib/opensearch/api/actions/flow_framework/search_state.rb @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module FlowFramework + module Actions + # Search for workflows by using a query matching a field. + # + # @option args [Hash] :body *Required* + def search_state(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = '_plugins/_flow_framework/workflow/state/_search' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/flow_framework/update.rb b/lib/opensearch/api/actions/flow_framework/update.rb new file mode 100644 index 000000000..85e7f8197 --- /dev/null +++ b/lib/opensearch/api/actions/flow_framework/update.rb @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module FlowFramework + module Actions + # Update a workflow. You can only update a complete workflow if it has not yet been provisioned. + # + # @option args [String] :workflow_id *Required* + # @option args [Boolean] :provision Provision the workflow as part of the request. + # @option args [Boolean] :reprovision + # @option args [Boolean] :update_fields Update only the fields included in the request body. + # @option args [String] :use_case To use a workflow template, specify it in the `use_case` query parameter when creating a workflow. + # @option args [String] :validation Validate the workflow. Valid values are all (validate the template) and none (do not validate the template). Default is all. + # @option args [Hash] :body + def update(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'workflow_id' missing" unless args['workflow_id'] + + _workflow_id = args.delete('workflow_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_flow_framework/workflow', _workflow_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, UPDATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + UPDATE_QUERY_PARAMS = Set.new(%w[ + provision + reprovision + update_fields + use_case + validation + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/get.rb b/lib/opensearch/api/actions/get.rb index 00dcb6bed..86dc4b50b 100644 --- a/lib/opensearch/api/actions/get.rb +++ b/lib/opensearch/api/actions/get.rb @@ -3,91 +3,60 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Actions - # Returns a document. - # - # @option arguments [String] :id The document ID - # @option arguments [String] :index The name of the index - # @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response - # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) - # @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode - # @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation - # @option arguments [String] :routing Specific routing value - # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return - # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field - # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field - # @option arguments [Number] :version Explicit version number for concurrency control - # @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) - # @option arguments [Hash] :headers Custom HTTP headers - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def get(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - _id = arguments.delete(:id) - - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_GET - path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body } - else - perform_request(method, path, params, body, headers).body +module OpenSearch + module API + module Root + module Actions + # Returns a document. + # + # @option args [String] :id *Required* Unique identifier of the document. + # @option args [String] :index *Required* Name of the index that contains the document. + # @option args [Boolean, Enumerable, String] :_source Set to `true` or `false` to return the `_source` field or not, or a list of fields to return. + # @option args [Enumerable, String] :_source_excludes A comma-separated list of source fields to exclude in the response. + # @option args [Enumerable, String] :_source_includes A comma-separated list of source fields to include in the response. + # @option args [String] :preference Specifies the node or shard the operation should be performed on. Random by default. + # @option args [Boolean] :realtime If `true`, the request is real-time as opposed to near-real-time. + # @option args [Boolean, String] :refresh If `true`, OpenSearch refreshes the affected shards to make this operation visible to search. If `false`, do nothing with refreshes. + # @option args [Enumerable, String] :routing Target the specified primary shard. + # @option args [Enumerable, String] :stored_fields List of stored fields to return as part of a hit. If no fields are specified, no stored fields are included in the response. If this field is specified, the `_source` parameter defaults to false. + # @option args [Integer] :version Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed. + # @option args [String] :version_type Specific version type: `internal`, `external`, `external_gte`. + def get(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + + _id = args.delete('id') + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = [_index, '_doc', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, GET_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get, %i[ - stored_fields - preference - realtime - refresh - routing - _source - _source_excludes - _source_includes - version - version_type - ].freeze) + GET_QUERY_PARAMS = Set.new(%w[ + _source + _source_excludes + _source_includes + preference + realtime + refresh + routing + stored_fields + version + version_type + ]).freeze + end end end end diff --git a/lib/opensearch/api/actions/get_all_pits.rb b/lib/opensearch/api/actions/get_all_pits.rb index 47e83c4ed..0fc3a340a 100644 --- a/lib/opensearch/api/actions/get_all_pits.rb +++ b/lib/opensearch/api/actions/get_all_pits.rb @@ -3,24 +3,29 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Gets all PITs. - def get_all_pits(arguments = {}) - method = OpenSearch::API::HTTP_GET - path = '_search/point_in_time/_all' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - body = nil + module Root + module Actions + # Lists all active point in time searches. + # + def get_all_pits(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_search/point_in_time/_all' - perform_request(method, path, params, body).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end end - - ParamsRegistry.register(:get_all_pits, [].freeze) end end end diff --git a/lib/opensearch/api/actions/get_script.rb b/lib/opensearch/api/actions/get_script.rb index 72aa4157d..1539499d8 100644 --- a/lib/opensearch/api/actions/get_script.rb +++ b/lib/opensearch/api/actions/get_script.rb @@ -3,62 +3,41 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Returns a script. - # - # @option arguments [String] :id Script ID - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def get_script(arguments = {}) - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] + module Root + module Actions + # Returns a script. + # + # @option args [String] :id *Required* Identifier for the stored script or search template. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Specify timeout for connection to master + def get_script(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] - headers = arguments.delete(:headers) || {} + _id = args.delete('id') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_scripts', _id].filter(&:present?).join('/').squeeze('/') - _id = arguments.delete(:id) + Utils.validate_query_params args, GET_SCRIPT_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - method = OpenSearch::API::HTTP_GET - path = "_scripts/#{Utils.__listify(_id)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + GET_SCRIPT_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout + master_timeout + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_script, %i[ - master_timeout - cluster_manager_timeout - ].freeze) end end end diff --git a/lib/opensearch/api/actions/get_script_context.rb b/lib/opensearch/api/actions/get_script_context.rb index cf4b38d51..a506e3422 100644 --- a/lib/opensearch/api/actions/get_script_context.rb +++ b/lib/opensearch/api/actions/get_script_context.rb @@ -3,50 +3,28 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -module OpenSearch - module API - module Actions - # Returns all script contexts. - # This functionality is Experimental and may be changed or removed - # completely in a future release. OpenSearch will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. - # - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def get_script_context(arguments = {}) - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - method = OpenSearch::API::HTTP_GET - path = '_script_context' - params = {} +module OpenSearch + module API + module Root + module Actions + # Returns all script contexts. + # + def get_script_context(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_script_context' - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end end end end diff --git a/lib/opensearch/api/actions/get_script_languages.rb b/lib/opensearch/api/actions/get_script_languages.rb index ace30d290..cd15e0a83 100644 --- a/lib/opensearch/api/actions/get_script_languages.rb +++ b/lib/opensearch/api/actions/get_script_languages.rb @@ -3,50 +3,28 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -module OpenSearch - module API - module Actions - # Returns available script types, languages and contexts - # This functionality is Experimental and may be changed or removed - # completely in a future release. OpenSearch will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. - # - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def get_script_languages(arguments = {}) - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - method = OpenSearch::API::HTTP_GET - path = '_script_language' - params = {} +module OpenSearch + module API + module Root + module Actions + # Returns available script types, languages and contexts. + # + def get_script_languages(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_script_language' - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end end end end diff --git a/lib/opensearch/api/actions/get_source.rb b/lib/opensearch/api/actions/get_source.rb index c6a205377..0d12098cc 100644 --- a/lib/opensearch/api/actions/get_source.rb +++ b/lib/opensearch/api/actions/get_source.rb @@ -3,85 +3,58 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Actions - # Returns the source of a document. - # - # @option arguments [String] :id The document ID - # @option arguments [String] :index The name of the index - # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) - # @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode - # @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation - # @option arguments [String] :routing Specific routing value - # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return - # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field - # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field - # @option arguments [Number] :version Explicit version number for concurrency control - # @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) - # @option arguments [Hash] :headers Custom HTTP headers - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def get_source(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - _id = arguments.delete(:id) - - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_GET - path = "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body +module OpenSearch + module API + module Root + module Actions + # Returns the source of a document. + # + # @option args [String] :id *Required* Unique identifier of the document. + # @option args [String] :index *Required* Name of the index that contains the document. + # @option args [Boolean, Enumerable, String] :_source Set to `true` or `false` to return the `_source` field or not, or a list of fields to return. + # @option args [Enumerable, String] :_source_excludes A comma-separated list of source fields to exclude in the response. + # @option args [Enumerable, String] :_source_includes A comma-separated list of source fields to include in the response. + # @option args [String] :preference Specifies the node or shard the operation should be performed on. Random by default. + # @option args [Boolean] :realtime Boolean) If `true`, the request is real-time as opposed to near-real-time. + # @option args [Boolean, String] :refresh If `true`, OpenSearch refreshes the affected shards to make this operation visible to search. If `false`, do nothing with refreshes. + # @option args [Enumerable, String] :routing Target the specified primary shard. + # @option args [Integer] :version Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed. + # @option args [String] :version_type Specific version type. One of `internal`, `external`, `external_gte`. + def get_source(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + + _id = args.delete('id') + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = [_index, '_source', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, GET_SOURCE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + GET_SOURCE_QUERY_PARAMS = Set.new(%w[ + _source + _source_excludes + _source_includes + preference + realtime + refresh + routing + version + version_type + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_source, %i[ - preference - realtime - refresh - routing - _source - _source_excludes - _source_includes - version - version_type - ].freeze) end end end diff --git a/lib/opensearch/api/actions/http/connect.rb b/lib/opensearch/api/actions/http/connect.rb deleted file mode 100644 index 89c0c95ad..000000000 --- a/lib/opensearch/api/actions/http/connect.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module Http - module Actions - # Make a customized CONNECT request. - # - # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) - # @option arguments [Hash] :params Querystring parameters to be appended to the path - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [String | Hash | Array] :body The body of the request - def connect(url, headers: {}, body: nil, params: {}) - request('CONNECT', url, headers: headers, body: body, params: params) - end - end - end - end -end diff --git a/lib/opensearch/api/actions/http/delete.rb b/lib/opensearch/api/actions/http/delete.rb deleted file mode 100644 index ca9ba90f4..000000000 --- a/lib/opensearch/api/actions/http/delete.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module Http - module Actions - # Make a customized DELETE request. - # - # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) - # @option arguments [Hash] :params Querystring parameters to be appended to the path - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [String | Hash | Array] :body The body of the request - def delete(url, headers: {}, body: nil, params: {}) - request('DELETE', url, headers: headers, body: body, params: params) - end - end - end - end -end diff --git a/lib/opensearch/api/actions/http/get.rb b/lib/opensearch/api/actions/http/get.rb deleted file mode 100644 index d726dc024..000000000 --- a/lib/opensearch/api/actions/http/get.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module Http - module Actions - # Make a customized GET request. - # - # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) - # @option arguments [Hash] :params Querystring parameters to be appended to the path - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [String | Hash | Array] :body The body of the request - def get(url, headers: {}, body: nil, params: {}) - request('GET', url, headers: headers, body: body, params: params) - end - end - end - end -end diff --git a/lib/opensearch/api/actions/http/head.rb b/lib/opensearch/api/actions/http/head.rb deleted file mode 100644 index 2cf76fd12..000000000 --- a/lib/opensearch/api/actions/http/head.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module Http - module Actions - # Make a customized HEAD request. - # - # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) - # @option arguments [Hash] :params Querystring parameters to be appended to the path - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [String | Hash | Array] :body The body of the request - def head(url, headers: {}, body: nil, params: {}) - request('HEAD', url, headers: headers, body: body, params: params) - end - end - end - end -end diff --git a/lib/opensearch/api/actions/http/options.rb b/lib/opensearch/api/actions/http/options.rb deleted file mode 100644 index 03b963bfe..000000000 --- a/lib/opensearch/api/actions/http/options.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module Http - module Actions - # Make a customized OPTIONS request. - # - # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) - # @option arguments [Hash] :params Querystring parameters to be appended to the path - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [String | Hash | Array] :body The body of the request - def options(url, headers: {}, body: nil, params: {}) - request('OPTIONS', url, headers: headers, body: body, params: params) - end - end - end - end -end diff --git a/lib/opensearch/api/actions/http/patch.rb b/lib/opensearch/api/actions/http/patch.rb deleted file mode 100644 index 1d93d4eb1..000000000 --- a/lib/opensearch/api/actions/http/patch.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module Http - module Actions - # Make a customized PATCH request. - # - # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) - # @option arguments [Hash] :params Querystring parameters to be appended to the path - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [String | Hash | Array] :body The body of the request - def patch(url, headers: {}, body: nil, params: {}) - request('PATCH', url, headers: headers, body: body, params: params) - end - end - end - end -end diff --git a/lib/opensearch/api/actions/http/post.rb b/lib/opensearch/api/actions/http/post.rb deleted file mode 100644 index 60fc0015b..000000000 --- a/lib/opensearch/api/actions/http/post.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module Http - module Actions - # Make a customized POST request. - # - # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) - # @option arguments [Hash] :params Querystring parameters to be appended to the path - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [String | Hash | Array] :body The body of the request - def post(url, headers: {}, body: nil, params: {}) - request('POST', url, headers: headers, body: body, params: params) - end - end - end - end -end diff --git a/lib/opensearch/api/actions/http/put.rb b/lib/opensearch/api/actions/http/put.rb deleted file mode 100644 index f34346cdd..000000000 --- a/lib/opensearch/api/actions/http/put.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module Http - module Actions - # Make a customized PUT request. - # - # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) - # @option arguments [Hash] :params Querystring parameters to be appended to the path - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [String | Hash | Array] :body The body of the request - def put(url, headers: {}, body: nil, params: {}) - request('PUT', url, headers: headers, body: body, params: params) - end - end - end - end -end diff --git a/lib/opensearch/api/actions/http/request.rb b/lib/opensearch/api/actions/http/request.rb deleted file mode 100644 index e60eef75a..000000000 --- a/lib/opensearch/api/actions/http/request.rb +++ /dev/null @@ -1,27 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module Http - module Actions - private - - def request(method, url, headers: {}, body: nil, params: {}) - body = OpenSearch::API::Utils.__bulkify(body) if body.is_a?(Array) - headers.merge!('Content-Type' => 'application/x-ndjson') if body.is_a?(Array) - - perform_request(method, url, params, body, headers).body - end - end - end - end -end diff --git a/lib/opensearch/api/actions/http/trace.rb b/lib/opensearch/api/actions/http/trace.rb deleted file mode 100644 index b2f665478..000000000 --- a/lib/opensearch/api/actions/http/trace.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module Http - module Actions - # Make a customized TRACE request. - # - # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) - # @option arguments [Hash] :params Querystring parameters to be appended to the path - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [String | Hash | Array] :body The body of the request - def trace(url, headers: {}, body: nil, params: {}) - request('TRACE', url, headers: headers, body: body, params: params) - end - end - end - end -end diff --git a/lib/opensearch/api/actions/index.rb b/lib/opensearch/api/actions/index.rb index c482afbb4..630877858 100644 --- a/lib/opensearch/api/actions/index.rb +++ b/lib/opensearch/api/actions/index.rb @@ -3,94 +3,63 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -module OpenSearch - module API - module Actions - # Creates or updates a document in an index. - # - # @option arguments [String] :id Document ID - # @option arguments [String] :index The name of the index - # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - # @option arguments [String] :op_type Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID (options: index, create) - # @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for) - # @option arguments [String] :routing Specific routing value - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Number] :version Explicit version number for concurrency control - # @option arguments [String] :version_type Specific version type (options: internal, external, external_gte) - # @option arguments [Number] :if_seq_no only perform the index operation if the last operation that has changed the document has the specified sequence number - # @option arguments [Number] :if_primary_term only perform the index operation if the last operation that has changed the document has the specified primary term - # @option arguments [String] :pipeline The pipeline id to preprocess incoming documents with - # @option arguments [Boolean] :require_alias When true, requires destination to be an alias. Default is false - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The document (*Required*) - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def index(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - headers = arguments.delete(:headers) || {} +# frozen_string_literal: true - arguments = arguments.clone +module OpenSearch + module API + module Root + module Actions + # Creates or updates a document in an index. + # + # @option args [String] :index *Required* Name of the data stream or index to target. + # @option args [Integer] :if_primary_term Only perform the operation if the document has this primary term. + # @option args [Integer] :if_seq_no Only perform the operation if the document has this sequence number. + # @option args [String] :op_type Set to create to only index the document if it does not already exist (put if absent). If a document with the specified `_id` already exists, the indexing operation will fail. Same as using the `/_create` endpoint. Valid values: `index`, `create`. If document id is specified, it defaults to `index`. Otherwise, it defaults to `create`. + # @option args [String] :pipeline ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request. If a final pipeline is configured it will always run, regardless of the value of this parameter. + # @option args [Boolean, String] :refresh If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes. Valid values: `true`, `false`, `wait_for`. + # @option args [Boolean] :require_alias If `true`, the destination must be an index alias. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [String] :timeout Period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. + # @option args [Integer] :version Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed. + # @option args [String] :version_type Specific version type: `external`, `external_gte`. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + # @option args [String] :id Unique identifier for the document. + # @option args [Hash] :body *Required* The document + def index(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - _id = arguments.delete(:id) + _index = args.delete('index') + _id = args.delete('id') - _index = arguments.delete(:index) + headers = args.delete('headers') || {} + body = args.delete('body') + method = _id.present? ? 'PUT' : 'POST' + url = [_index, '_doc', _id].filter(&:present?).join('/').squeeze('/') - method = _id ? OpenSearch::API::HTTP_PUT : OpenSearch::API::HTTP_POST - path = if _index && _id - "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" - else - "#{Utils.__listify(_index)}/_doc" - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + Utils.validate_query_params args, INDEX_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - body = arguments[:body] - perform_request(method, path, params, body, headers).body + INDEX_QUERY_PARAMS = Set.new(%w[ + if_primary_term + if_seq_no + op_type + pipeline + refresh + require_alias + routing + timeout + version + version_type + wait_for_active_shards + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:index, %i[ - wait_for_active_shards - op_type - refresh - routing - timeout - version - version_type - if_seq_no - if_primary_term - pipeline - require_alias - ].freeze) end end end diff --git a/lib/opensearch/api/actions/indices/add_block.rb b/lib/opensearch/api/actions/indices/add_block.rb index 6510b0e52..c90461be1 100644 --- a/lib/opensearch/api/actions/indices/add_block.rb +++ b/lib/opensearch/api/actions/indices/add_block.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,48 +15,39 @@ module Indices module Actions # Adds a block to an index. # - # @option arguments [List] :index A comma separated list of indices to add a block to - # @option arguments [String] :block The block to add (one of read, write, read_only or metadata) - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def add_block(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'block' missing" unless arguments[:block] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) - - _block = arguments.delete(:block) - - method = OpenSearch::API::HTTP_PUT - path = "#{Utils.__listify(_index)}/_block/#{Utils.__listify(_block)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + # @option args [String] :block *Required* The block to add (one of `read`, `write`, `read_only` or `metadata`). + # @option args [Enumerable, String] :index *Required* A comma separated list of indexes to add a block to. + # @option args [Boolean] :allow_no_indices Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified). + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :expand_wildcards Whether to expand wildcard expression to concrete indexes that are open, closed or both. + # @option args [Boolean] :ignore_unavailable Whether specified concrete indexes should be ignored when unavailable (missing or closed). + # @option args [String] :master_timeout DEPRECATED Specify timeout for connection to cluster manager. + # @option args [String] :timeout Explicit operation timeout + def add_block(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'block' missing" unless args['block'] + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + + _block = args.delete('block') + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = [_index, '_block', _block].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, ADD_BLOCK_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:add_block, %i[ - timeout - master_timeout - cluster_manager_timeout - ignore_unavailable + ADD_BLOCK_QUERY_PARAMS = Set.new(%w[ allow_no_indices + cluster_manager_timeout expand_wildcards - ].freeze) + ignore_unavailable + master_timeout + timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/analyze.rb b/lib/opensearch/api/actions/indices/analyze.rb index d95cbd919..406c99986 100644 --- a/lib/opensearch/api/actions/indices/analyze.rb +++ b/lib/opensearch/api/actions/indices/analyze.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,41 +15,20 @@ module Indices module Actions # Performs the analysis process on a text and return the tokens breakdown of the text. # - # @option arguments [String] :index The name of the index to scope the operation - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Define analyzer/tokenizer parameters and the text on which the analysis should be performed - # - # - def analyze(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) + # @option args [String] :index The name of the index to scope the operation. + # @option args [Hash] :body Define analyzer/tokenizer parameters and the text on which the analysis should be performed + def analyze(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - method = if arguments[:body] - OpenSearch::API::HTTP_POST - else - OpenSearch::API::HTTP_GET - end + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = [_index, '_analyze'].filter(&:present?).join('/').squeeze('/') - path = if _index - "#{Utils.__listify(_index)}/_analyze" - else - '_analyze' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:analyze, [ - :index - ].freeze) end end end diff --git a/lib/opensearch/api/actions/indices/clear_cache.rb b/lib/opensearch/api/actions/indices/clear_cache.rb index 1aebd0771..64709e4c8 100644 --- a/lib/opensearch/api/actions/indices/clear_cache.rb +++ b/lib/opensearch/api/actions/indices/clear_cache.rb @@ -3,76 +3,50 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Indices module Actions - # Clears all or specific caches for one or more indices. - # - # @option arguments [List] :index A comma-separated list of index name to limit the operation - # @option arguments [Boolean] :fielddata Clear field data - # @option arguments [List] :fields A comma-separated list of fields to clear when using the `fielddata` parameter (default: all) - # @option arguments [Boolean] :query Clear query caches - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :request Clear request cache - # @option arguments [Hash] :headers Custom HTTP headers + # Clears all or specific caches for one or more indexes. # - # - def clear_cache(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :fielddata If `true`, clears the fields cache. Use the `fields` parameter to clear the cache of specific fields only. + # @option args [Enumerable, String] :fields Comma-separated list of field names used to limit the `fielddata` parameter. + # @option args [Boolean] :file If `true`, clears the unused entries from the file cache on nodes with the Search role. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Enumerable] :index Comma-separated list of indexes; use `_all` or empty string to perform the operation on all indexes. + # @option args [Boolean] :query If `true`, clears the query cache. + # @option args [Boolean] :request If `true`, clears the request cache. + def clear_cache(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - _index = arguments.delete(:index) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_index, '_cache/clear'].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_POST - path = if _index - "#{Utils.__listify(_index)}/_cache/clear" - else - '_cache/clear' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, CLEAR_CACHE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:clear_cache, %i[ + CLEAR_CACHE_QUERY_PARAMS = Set.new(%w[ + allow_no_indices + expand_wildcards fielddata fields - query + file ignore_unavailable - allow_no_indices - expand_wildcards - index + query request - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/clone.rb b/lib/opensearch/api/actions/indices/clone.rb index b28c97a66..b55da4e4b 100644 --- a/lib/opensearch/api/actions/indices/clone.rb +++ b/lib/opensearch/api/actions/indices/clone.rb @@ -3,72 +3,52 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Indices module Actions - # Clones an index - # - # @option arguments [String] :index The name of the source index to clone - # @option arguments [String] :target The name of the target index to clone into - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [String] :wait_for_active_shards Set the number of active shards to wait for on the cloned index before the operation returns. - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The configuration for the target index (`settings` and `aliases`) - # + # Clones an index. # - def clone(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'target' missing" unless arguments[:target] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) - - _target = arguments.delete(:target) - - method = OpenSearch::API::HTTP_PUT - path = "#{Utils.__listify(_index)}/_clone/#{Utils.__listify(_target)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + # @option args [String] :index *Required* Name of the source index to clone. + # @option args [String] :target *Required* Name of the target index to create. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :task_execution_timeout Explicit task execution timeout, only useful when `wait_for_completion` is false, defaults to `1h`. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + # @option args [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning. + # @option args [Hash] :body The configuration for the target index (`settings` and `aliases`) + def clone(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + raise ArgumentError, "Required argument 'target' missing" unless args['target'] + + _index = args.delete('index') + _target = args.delete('target') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_index, '_clone', _target].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, CLONE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:clone, %i[ - timeout - master_timeout + CLONE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + master_timeout + task_execution_timeout + timeout wait_for_active_shards - ].freeze) + wait_for_completion + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/close.rb b/lib/opensearch/api/actions/indices/close.rb index 66b892e60..02634d786 100644 --- a/lib/opensearch/api/actions/indices/close.rb +++ b/lib/opensearch/api/actions/indices/close.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,46 +15,38 @@ module Indices module Actions # Closes an index. # - # @option arguments [List] :index A comma separated list of indices to close - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [String] :wait_for_active_shards Sets the number of active shards to wait for before the operation returns. Set to `index-setting` to wait according to the index setting `index.write.wait_for_active_shards`, or `all` to wait for all shards, or an integer. Defaults to `0`. - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def close(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Enumerable, String] :index *Required* Comma-separated list or wildcard expression of index names used to limit the request. + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + def close(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] - _index = arguments.delete(:index) + _index = args.delete('index') - method = OpenSearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_close" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_index, '_close'].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, CLOSE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:close, %i[ - timeout - master_timeout - cluster_manager_timeout - ignore_unavailable + CLOSE_QUERY_PARAMS = Set.new(%w[ allow_no_indices + cluster_manager_timeout expand_wildcards + ignore_unavailable + master_timeout + timeout wait_for_active_shards - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/create.rb b/lib/opensearch/api/actions/indices/create.rb index 41d05841f..87aad172f 100644 --- a/lib/opensearch/api/actions/indices/create.rb +++ b/lib/opensearch/api/actions/indices/create.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,41 +15,33 @@ module Indices module Actions # Creates an index with optional settings and mappings. # - # @option arguments [String] :index The name of the index - # @option arguments [String] :wait_for_active_shards Set the number of active shards to wait for before the operation returns. - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The configuration for the index (`settings` and `mappings`) - # - # - def create(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - - headers = arguments.delete(:headers) || {} + # @option args [String] :index *Required* Name of the index you wish to create. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + # @option args [Hash] :body The configuration for the index (`settings` and `mappings`) + def create(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] - arguments = arguments.clone + _index = args.delete('index') - _index = arguments.delete(:index) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = [_index].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_PUT - path = Utils.__listify(_index).to_s - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, CREATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:create, %i[ - wait_for_active_shards - timeout - master_timeout + CREATE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout - ].freeze) + master_timeout + timeout + wait_for_active_shards + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/create_data_stream.rb b/lib/opensearch/api/actions/indices/create_data_stream.rb new file mode 100644 index 000000000..09165bcf9 --- /dev/null +++ b/lib/opensearch/api/actions/indices/create_data_stream.rb @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Indices + module Actions + # Creates or updates a data stream. + # + # @option args [String] :name *Required* Name of the data stream, which must meet the following criteria: Lowercase only; Cannot include `\`, `/`, `*`, `?`, `"`, `<`, `>`, `|`, `,`, `#`, `:`, or a space character; Cannot start with `-`, `_`, `+`, or `.ds-`; Cannot be `.` or `..`; Cannot be longer than 255 bytes. Multi-byte characters count towards this limit faster. + # @option args [Hash] :body The data stream definition + def create_data_stream(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] + + _name = args.delete('name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_data_stream', _name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/indices/data_streams_stats.rb b/lib/opensearch/api/actions/indices/data_streams_stats.rb new file mode 100644 index 000000000..5e41a8a0c --- /dev/null +++ b/lib/opensearch/api/actions/indices/data_streams_stats.rb @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Indices + module Actions + # Provides statistics on operations happening in a data stream. + # + # @option args [Enumerable, String] :name Comma-separated list of data streams used to limit the request. Wildcard expressions (`*`) are supported. To target all data streams in a cluster, omit this parameter or use `*`. + def data_streams_stats(args = {}) + args = Utils.normalize_arguments(args) + _name = args.delete('name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_data_stream', _name, '_stats'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/indices/delete.rb b/lib/opensearch/api/actions/indices/delete.rb index 2110934b5..a2414ae35 100644 --- a/lib/opensearch/api/actions/indices/delete.rb +++ b/lib/opensearch/api/actions/indices/delete.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,48 +15,38 @@ module Indices module Actions # Deletes an index. # - # @option arguments [List] :index A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Boolean] :ignore_unavailable Ignore unavailable indexes (default: false) - # @option arguments [Boolean] :allow_no_indices Ignore if a wildcard expression resolves to no concrete indices (default: false) - # @option arguments [String] :expand_wildcards Whether wildcard expressions should get expanded to open or closed indices (default: open) (options: open, closed, hidden, none, all) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def delete(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Enumerable, String] :index *Required* Comma-separated list of indexes to delete. You cannot specify index aliases. By default, this parameter does not support wildcards (`*`) or `_all`. To use wildcards or `_all`, set the `action.destructive_requires_name` cluster setting to `false`. + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] - _index = arguments.delete(:index) + _index = args.delete('index') - method = OpenSearch::API::HTTP_DELETE - path = Utils.__listify(_index).to_s - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = [_index].filter(&:present?).join('/').squeeze('/') - body = nil - if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body } - else - perform_request(method, path, params, body, headers).body - end + Utils.validate_query_params args, DELETE_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:delete, %i[ - timeout - master_timeout - cluster_manager_timeout - ignore_unavailable + DELETE_QUERY_PARAMS = Set.new(%w[ allow_no_indices + cluster_manager_timeout expand_wildcards - ].freeze) + ignore_unavailable + master_timeout + timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/delete_alias.rb b/lib/opensearch/api/actions/indices/delete_alias.rb index 44762e614..f048088aa 100644 --- a/lib/opensearch/api/actions/indices/delete_alias.rb +++ b/lib/opensearch/api/actions/indices/delete_alias.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,42 +15,35 @@ module Indices module Actions # Deletes an alias. # - # @option arguments [List] :index A comma-separated list of index names (supports wildcards); use `_all` for all indices - # @option arguments [List] :name A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices. - # @option arguments [Time] :timeout Explicit timestamp for the document - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def delete_alias(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) - - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_DELETE - path = ("#{Utils.__listify(_index)}/_aliases/#{Utils.__listify(_name)}" if _index && _name) - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + # @option args [Enumerable, String] :index *Required* Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (`*`). + # @option args [Enumerable, String] :name *Required* Comma-separated list of aliases to remove. Supports wildcards (`*`). To remove all aliases, use `*` or `_all`. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_alias(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + raise ArgumentError, "Required argument 'name' missing" unless args['name'] + + _index = args.delete('index') + _name = args.delete('name') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = [_index, '_aliases', _name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, DELETE_ALIAS_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:delete_alias, %i[ - timeout - master_timeout + DELETE_ALIAS_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout - ].freeze) + master_timeout + timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/delete_data_stream.rb b/lib/opensearch/api/actions/indices/delete_data_stream.rb new file mode 100644 index 000000000..7e89fee37 --- /dev/null +++ b/lib/opensearch/api/actions/indices/delete_data_stream.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Indices + module Actions + # Deletes a data stream. + # + # @option args [Enumerable, String] :name *Required* Comma-separated list of data streams to delete. Wildcard (`*`) expressions are supported. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_data_stream(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] + + _name = args.delete('name') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_data_stream', _name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/indices/delete_index_template.rb b/lib/opensearch/api/actions/indices/delete_index_template.rb index c08517a07..c0aac7063 100644 --- a/lib/opensearch/api/actions/indices/delete_index_template.rb +++ b/lib/opensearch/api/actions/indices/delete_index_template.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,38 +15,32 @@ module Indices module Actions # Deletes an index template. # - # @option arguments [String] :name The name of the template - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def delete_index_template(arguments = {}) - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] + # @option args [String] :name *Required* Name of the index template to delete. Wildcard (*) expressions are supported. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_index_template(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] - headers = arguments.delete(:headers) || {} + _name = args.delete('name') - arguments = arguments.clone + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_index_template', _name].filter(&:present?).join('/').squeeze('/') - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_DELETE - path = "_index_template/#{Utils.__listify(_name)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, DELETE_INDEX_TEMPLATE_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:delete_index_template, %i[ - timeout - master_timeout + DELETE_INDEX_TEMPLATE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout - ].freeze) + master_timeout + timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/delete_template.rb b/lib/opensearch/api/actions/indices/delete_template.rb index a4e0fb42b..699928eb4 100644 --- a/lib/opensearch/api/actions/indices/delete_template.rb +++ b/lib/opensearch/api/actions/indices/delete_template.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,42 +15,32 @@ module Indices module Actions # Deletes an index template. # - # @option arguments [String] :name The name of the template - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def delete_template(arguments = {}) - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] + # @option args [String] :name *Required* The name of the legacy index template to delete. Wildcard (`*`) expressions are supported. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_template(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] - headers = arguments.delete(:headers) || {} + _name = args.delete('name') - arguments = arguments.clone + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_template', _name].filter(&:present?).join('/').squeeze('/') - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_DELETE - path = "_template/#{Utils.__listify(_name)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body } - else - perform_request(method, path, params, body, headers).body - end + Utils.validate_query_params args, DELETE_TEMPLATE_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:delete_template, %i[ - timeout - master_timeout + DELETE_TEMPLATE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout - ].freeze) + master_timeout + timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/disk_usage.rb b/lib/opensearch/api/actions/indices/disk_usage.rb deleted file mode 100644 index 729f42a17..000000000 --- a/lib/opensearch/api/actions/indices/disk_usage.rb +++ /dev/null @@ -1,76 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Indices - module Actions - # Analyzes the disk usage of each field of an index or data stream - # This functionality is Experimental and may be changed or removed - # completely in a future release. OpenSearch will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. - # - # @option arguments [String] :index Comma-separated list of indices or data streams to analyze the disk usage - # @option arguments [Boolean] :run_expensive_tasks Must be set to [true] in order for the task to be performed. Defaults to false. - # @option arguments [Boolean] :flush Whether flush or not before analyzing the index disk usage. Defaults to true - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def disk_usage(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_disk_usage" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body - end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:disk_usage, %i[ - run_expensive_tasks - flush - ignore_unavailable - allow_no_indices - expand_wildcards - ].freeze) - end - end - end -end diff --git a/lib/opensearch/api/actions/indices/exists.rb b/lib/opensearch/api/actions/indices/exists.rb index 844eacd04..f7b9f3e7c 100644 --- a/lib/opensearch/api/actions/indices/exists.rb +++ b/lib/opensearch/api/actions/indices/exists.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,49 +15,38 @@ module Indices module Actions # Returns information about whether a particular index exists. # - # @option arguments [List] :index A comma-separated list of index names - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) - # @option arguments [Boolean] :ignore_unavailable Ignore unavailable indexes (default: false) - # @option arguments [Boolean] :allow_no_indices Ignore if a wildcard expression resolves to no concrete indices (default: false) - # @option arguments [String] :expand_wildcards Whether wildcard expressions should get expanded to open or closed indices (default: open) (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Boolean] :include_defaults Whether to return all default setting for each of the indices. - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def exists(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_HEAD - path = Utils.__listify(_index).to_s - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - - Utils.__rescue_from_not_found do - perform_request(method, path, params, body, headers).status == 200 - end + # @option args [Enumerable, String] :index *Required* Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :flat_settings If `true`, returns settings in flat format. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Boolean] :include_defaults If `true`, return all default settings in the response. + # @option args [Boolean] :local If `true`, the request retrieves information from the local node only. + def exists(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'HEAD' + url = [_index].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, EXISTS_QUERY_PARAMS + transport.perform_head_request method, url, args, body, headers end - alias exists? exists - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:exists, %i[ - local - ignore_unavailable + EXISTS_QUERY_PARAMS = Set.new(%w[ allow_no_indices + cluster_manager_timeout expand_wildcards flat_settings + ignore_unavailable include_defaults - ].freeze) + local + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/exists_alias.rb b/lib/opensearch/api/actions/indices/exists_alias.rb index 7af1de652..4a3f344e8 100644 --- a/lib/opensearch/api/actions/indices/exists_alias.rb +++ b/lib/opensearch/api/actions/indices/exists_alias.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,52 +15,34 @@ module Indices module Actions # Returns information about whether a particular alias exists. # - # @option arguments [List] :name A comma-separated list of alias names to return - # @option arguments [List] :index A comma-separated list of index names to filter aliases - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def exists_alias(arguments = {}) - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _name = arguments.delete(:name) - - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_HEAD - path = if _index && _name - "#{Utils.__listify(_index)}/_alias/#{Utils.__listify(_name)}" - else - "_alias/#{Utils.__listify(_name)}" - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - - Utils.__rescue_from_not_found do - perform_request(method, path, params, body, headers).status == 200 - end + # @option args [Enumerable, String] :name *Required* Comma-separated list of aliases to check. Supports wildcards (`*`). + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :ignore_unavailable If `false`, requests that include a missing data stream or index in the target indexes or data streams return an error. + # @option args [Boolean] :local If `true`, the request retrieves information from the local node only. + # @option args [Enumerable, String] :index Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + def exists_alias(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] + + _name = args.delete('name') + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'HEAD' + url = [_index, '_alias', _name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, EXISTS_ALIAS_QUERY_PARAMS + transport.perform_head_request method, url, args, body, headers end - alias exists_alias? exists_alias - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:exists_alias, %i[ - ignore_unavailable + EXISTS_ALIAS_QUERY_PARAMS = Set.new(%w[ allow_no_indices expand_wildcards + ignore_unavailable local - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/exists_index_template.rb b/lib/opensearch/api/actions/indices/exists_index_template.rb index fff274d67..67231fc7b 100644 --- a/lib/opensearch/api/actions/indices/exists_index_template.rb +++ b/lib/opensearch/api/actions/indices/exists_index_template.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,42 +15,32 @@ module Indices module Actions # Returns information about whether a particular index template exists. # - # @option arguments [String] :name The name of the template - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def exists_index_template(arguments = {}) - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_HEAD - path = "_index_template/#{Utils.__listify(_name)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + # @option args [String] :name *Required* Name of the index template to check existence of. Wildcard (*) expressions are supported. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :flat_settings Return settings in flat format. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + def exists_index_template(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] + + _name = args.delete('name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'HEAD' + url = ['_index_template', _name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, EXISTS_INDEX_TEMPLATE_QUERY_PARAMS + transport.perform_head_request method, url, args, body, headers end - alias exists_index_template? exists_index_template - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:exists_index_template, %i[ - flat_settings - master_timeout + EXISTS_INDEX_TEMPLATE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + flat_settings local - ].freeze) + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/exists_template.rb b/lib/opensearch/api/actions/indices/exists_template.rb index 2250ec355..39afc7e37 100644 --- a/lib/opensearch/api/actions/indices/exists_template.rb +++ b/lib/opensearch/api/actions/indices/exists_template.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,45 +15,32 @@ module Indices module Actions # Returns information about whether a particular index template exists. # - # @option arguments [List] :name The comma separated names of the index templates - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def exists_template(arguments = {}) - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_HEAD - path = "_template/#{Utils.__listify(_name)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - - Utils.__rescue_from_not_found do - perform_request(method, path, params, body, headers).status == 200 - end + # @option args [Enumerable, String] :name *Required* The comma separated names of the index templates + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :flat_settings Return settings in flat format. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Explicit operation timeout for connection to cluster-manager node + def exists_template(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] + + _name = args.delete('name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'HEAD' + url = ['_template', _name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, EXISTS_TEMPLATE_QUERY_PARAMS + transport.perform_head_request method, url, args, body, headers end - alias exists_template? exists_template - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:exists_template, %i[ - flat_settings - master_timeout + EXISTS_TEMPLATE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + flat_settings local - ].freeze) + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/field_usage_stats.rb b/lib/opensearch/api/actions/indices/field_usage_stats.rb deleted file mode 100644 index 3116001c4..000000000 --- a/lib/opensearch/api/actions/indices/field_usage_stats.rb +++ /dev/null @@ -1,74 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Indices - module Actions - # Returns the field usage stats for each field of an index - # This functionality is Experimental and may be changed or removed - # completely in a future release. OpenSearch will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. - # - # @option arguments [String] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - # @option arguments [List] :fields A comma-separated list of fields to include in the stats if only a subset of fields should be returned (supports wildcards) - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def field_usage_stats(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_GET - path = "#{Utils.__listify(_index)}/_field_usage_stats" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body - end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:field_usage_stats, %i[ - fields - ignore_unavailable - allow_no_indices - expand_wildcards - ].freeze) - end - end - end -end diff --git a/lib/opensearch/api/actions/indices/flush.rb b/lib/opensearch/api/actions/indices/flush.rb index 48b6603d2..a1d258b6a 100644 --- a/lib/opensearch/api/actions/indices/flush.rb +++ b/lib/opensearch/api/actions/indices/flush.rb @@ -3,71 +3,44 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Indices module Actions - # Performs the flush operation on one or more indices. - # - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string for all indices - # @option arguments [Boolean] :force Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal) - # @option arguments [Boolean] :wait_if_ongoing If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running. - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Hash] :headers Custom HTTP headers + # Performs the flush operation on one or more indexes. # - # - def flush(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :force If `true`, the request forces a flush even if there are no changes to commit to the index. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Boolean] :wait_if_ongoing If `true`, the flush operation blocks until execution when another flush operation is running. If `false`, OpenSearch returns an error if you request a flush when another flush operation is running. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases to flush. Supports wildcards (`*`). To flush all data streams and indexes, omit this parameter or use `*` or `_all`. + def flush(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - _index = arguments.delete(:index) + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = [_index, '_flush'].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_POST - path = if _index - "#{Utils.__listify(_index)}/_flush" - else - '_flush' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, FLUSH_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:flush, %i[ - force - wait_if_ongoing - ignore_unavailable + FLUSH_QUERY_PARAMS = Set.new(%w[ allow_no_indices expand_wildcards - ].freeze) + force + ignore_unavailable + wait_if_ongoing + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/forcemerge.rb b/lib/opensearch/api/actions/indices/forcemerge.rb index 83ebfff50..edacd1fbc 100644 --- a/lib/opensearch/api/actions/indices/forcemerge.rb +++ b/lib/opensearch/api/actions/indices/forcemerge.rb @@ -3,73 +3,50 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Indices module Actions - # Performs the force merge operation on one or more indices. - # - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - # @option arguments [Boolean] :flush Specify whether the index should be flushed after performing the operation (default: true) - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Number] :max_num_segments The number of segments the index should be merged into (default: dynamic) - # @option arguments [Boolean] :only_expunge_deletes Specify whether the operation should only expunge deleted documents - # @option arguments [Hash] :headers Custom HTTP headers - # + # Performs the force merge operation on one or more indexes. # - def forcemerge(arguments = {}) - headers = arguments.delete(:headers) || {} + # @option args [Boolean] :allow_no_indices Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified) + # @option args [Enumerable, String] :expand_wildcards Whether to expand wildcard expression to concrete indexes that are open, closed or both. + # @option args [Boolean] :flush Specify whether the index should be flushed after performing the operation. + # @option args [Boolean] :ignore_unavailable Whether specified concrete indexes should be ignored when unavailable (missing or closed) + # @option args [Float] :max_num_segments The number of larger segments into which smaller segments are merged. Set this parameter to 1 to merge all segments into one segment. The default behavior is to perform the merge as necessary. + # @option args [Boolean] :only_expunge_deletes Specify whether the operation should only expunge deleted documents + # @option args [Boolean] :primary_only Specify whether the operation should only perform on primary shards. Defaults to false. + # @option args [Boolean] :wait_for_completion Should the request wait until the force merge is completed. + # @option args [Enumerable, String] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indexes + def forcemerge(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_index, '_forcemerge'].filter(&:present?).join('/').squeeze('/') - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_POST - path = if _index - "#{Utils.__listify(_index)}/_forcemerge" - else - '_forcemerge' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, FORCEMERGE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:forcemerge, %i[ - flush - ignore_unavailable + FORCEMERGE_QUERY_PARAMS = Set.new(%w[ allow_no_indices expand_wildcards + flush + ignore_unavailable max_num_segments only_expunge_deletes - ].freeze) + primary_only + wait_for_completion + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/get.rb b/lib/opensearch/api/actions/indices/get.rb index 1c147ced2..93ea7d5fe 100644 --- a/lib/opensearch/api/actions/indices/get.rb +++ b/lib/opensearch/api/actions/indices/get.rb @@ -3,75 +3,52 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Indices module Actions - # Returns information about one or more indices. - # - # @option arguments [List] :index A comma-separated list of index names - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) - # @option arguments [Boolean] :ignore_unavailable Ignore unavailable indexes (default: false) - # @option arguments [Boolean] :allow_no_indices Ignore if a wildcard expression resolves to no concrete indices (default: false) - # @option arguments [String] :expand_wildcards Whether wildcard expressions should get expanded to open or closed indices (default: open) (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Boolean] :include_defaults Whether to return all default setting for each of the indices. - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers + # Returns information about one or more indexes. # - # - def get(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - - headers = arguments.delete(:headers) || {} + # @option args [Enumerable, String] :index *Required* Comma-separated list of data streams, indexes, and index aliases used to limit the request. Wildcard expressions (*) are supported. + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard expressions can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. + # @option args [Boolean] :flat_settings If `true`, returns settings in flat format. + # @option args [Boolean] :ignore_unavailable If `false`, requests that target a missing index return an error. + # @option args [Boolean] :include_defaults If `true`, return all default settings in the response. + # @option args [Boolean] :local If `true`, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + def get(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] - arguments = arguments.clone + _index = args.delete('index') - _index = arguments.delete(:index) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = [_index].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_GET - path = Utils.__listify(_index).to_s - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, GET_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get, %i[ - local - ignore_unavailable + GET_QUERY_PARAMS = Set.new(%w[ allow_no_indices + cluster_manager_timeout expand_wildcards flat_settings + ignore_unavailable include_defaults + local master_timeout - cluster_manager_timeout - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/get_alias.rb b/lib/opensearch/api/actions/indices/get_alias.rb index 49edd5372..f329fe644 100644 --- a/lib/opensearch/api/actions/indices/get_alias.rb +++ b/lib/opensearch/api/actions/indices/get_alias.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,49 +15,32 @@ module Indices module Actions # Returns an alias. # - # @option arguments [List] :name A comma-separated list of alias names to return - # @option arguments [List] :index A comma-separated list of index names to filter aliases - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def get_alias(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _name = arguments.delete(:name) - - _index = arguments.delete(:index) + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Boolean] :local If `true`, the request retrieves information from the local node only. + # @option args [Enumerable, String] :name Comma-separated list of aliases to retrieve. Supports wildcards (`*`). To retrieve all aliases, omit this parameter or use `*` or `_all`. + # @option args [Enumerable, String] :index Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + def get_alias(args = {}) + args = Utils.normalize_arguments(args) + _name = args.delete('name') + _index = args.delete('index') - method = OpenSearch::API::HTTP_GET - path = if _index && _name - "#{Utils.__listify(_index)}/_alias/#{Utils.__listify(_name)}" - elsif _index - "#{Utils.__listify(_index)}/_alias" - elsif _name - "_alias/#{Utils.__listify(_name)}" - else - '_alias' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = [_index, '_alias', _name].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, GET_ALIAS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_alias, %i[ - ignore_unavailable + GET_ALIAS_QUERY_PARAMS = Set.new(%w[ allow_no_indices expand_wildcards + ignore_unavailable local - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/get_data_stream.rb b/lib/opensearch/api/actions/indices/get_data_stream.rb new file mode 100644 index 000000000..72670b113 --- /dev/null +++ b/lib/opensearch/api/actions/indices/get_data_stream.rb @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Indices + module Actions + # Returns data streams. + # + # @option args [Enumerable, String] :name Comma-separated list of data stream names used to limit the request. Wildcard (`*`) expressions are supported. If omitted, all data streams are returned. + def get_data_stream(args = {}) + args = Utils.normalize_arguments(args) + _name = args.delete('name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_data_stream', _name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/indices/get_field_mapping.rb b/lib/opensearch/api/actions/indices/get_field_mapping.rb index b263a4452..bac24c53b 100644 --- a/lib/opensearch/api/actions/indices/get_field_mapping.rb +++ b/lib/opensearch/api/actions/indices/get_field_mapping.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,53 +15,36 @@ module Indices module Actions # Returns mapping for one or more fields. # - # @option arguments [List] :fields A comma-separated list of fields - # @option arguments [List] :index A comma-separated list of index names - # @option arguments [Boolean] :include_defaults Whether the default mapping values should be returned as well - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) - # @option arguments [Hash] :headers Custom HTTP headers - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def get_field_mapping(arguments = {}) - _fields = arguments.delete(:field) || arguments.delete(:fields) - raise ArgumentError, "Required argument 'field' missing" unless _fields - - headers = arguments.delete(:headers) || {} + # @option args [Enumerable, String] :fields *Required* Comma-separated list or wildcard expression of fields used to limit returned information. + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Boolean] :include_defaults If `true`, return all default settings in the response. + # @option args [Boolean] :local If `true`, the request retrieves information from the local node only. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + def get_field_mapping(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'fields' missing" unless args['fields'] - arguments = arguments.clone + _fields = args.delete('fields') + _index = args.delete('index') - _index = arguments.delete(:index) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = [_index, '_mapping/field', _fields].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_GET - path = if _index && _fields - "#{Utils.__listify(_index)}/_mapping/field/#{Utils.__listify(_fields)}" - else - "_mapping/field/#{Utils.__listify(_fields)}" - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, GET_FIELD_MAPPING_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_field_mapping, %i[ - include_defaults - ignore_unavailable + GET_FIELD_MAPPING_QUERY_PARAMS = Set.new(%w[ allow_no_indices expand_wildcards + ignore_unavailable + include_defaults local - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/get_index_template.rb b/lib/opensearch/api/actions/indices/get_index_template.rb index f735d59cf..337fc0884 100644 --- a/lib/opensearch/api/actions/indices/get_index_template.rb +++ b/lib/opensearch/api/actions/indices/get_index_template.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,42 +15,30 @@ module Indices module Actions # Returns an index template. # - # @option arguments [List] :name The comma separated names of the index templates - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def get_index_template(arguments = {}) - headers = arguments.delete(:headers) || {} + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :flat_settings If `true`, returns settings in flat format. + # @option args [Boolean] :local If `true`, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :name Name of the index template to retrieve. Wildcard (*) expressions are supported. + def get_index_template(args = {}) + args = Utils.normalize_arguments(args) + _name = args.delete('name') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_index_template', _name].filter(&:present?).join('/').squeeze('/') - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_GET - path = if _name - "_index_template/#{Utils.__listify(_name)}" - else - '_index_template' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, GET_INDEX_TEMPLATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_index_template, %i[ - flat_settings - master_timeout + GET_INDEX_TEMPLATE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + flat_settings local - ].freeze) + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/get_mapping.rb b/lib/opensearch/api/actions/indices/get_mapping.rb index da1633d54..d4724ce8b 100644 --- a/lib/opensearch/api/actions/indices/get_mapping.rb +++ b/lib/opensearch/api/actions/indices/get_mapping.rb @@ -3,78 +3,46 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Indices module Actions - # Returns mappings for one or more indices. - # - # @option arguments [List] :index A comma-separated list of index names - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) *Deprecated* - # @option arguments [Hash] :headers Custom HTTP headers - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # + # Returns mappings for one or more indexes. # - def get_mapping(arguments = {}) - headers = arguments.delete(:headers) || {} + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + # @option args [Boolean] :local If `true`, the request retrieves information from the local node only. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + def get_mapping(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = [_index, '_mapping'].filter(&:present?).join('/').squeeze('/') - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_GET - path = if _index - "#{Utils.__listify(_index)}/_mapping" - else - '_mapping' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, GET_MAPPING_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_mapping, %i[ - ignore_unavailable + GET_MAPPING_QUERY_PARAMS = Set.new(%w[ allow_no_indices - expand_wildcards - master_timeout cluster_manager_timeout + expand_wildcards + ignore_unavailable local - ].freeze) + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/get_settings.rb b/lib/opensearch/api/actions/indices/get_settings.rb index 8bd90d91d..80df1881f 100644 --- a/lib/opensearch/api/actions/indices/get_settings.rb +++ b/lib/opensearch/api/actions/indices/get_settings.rb @@ -3,84 +3,52 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Indices module Actions - # Returns settings for one or more indices. - # - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - # @option arguments [List] :name The name of the settings that should be included - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) - # @option arguments [Boolean] :include_defaults Whether to return all default setting for each of the indices. - # @option arguments [Hash] :headers Custom HTTP headers - # + # Returns settings for one or more indexes. # - def get_settings(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting `foo*,bar*` returns an error if an index starts with foo but no index starts with `bar`. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. + # @option args [Boolean] :flat_settings If `true`, returns settings in flat format. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Boolean] :include_defaults If `true`, return all default settings in the response. + # @option args [Boolean] :local If `true`, the request retrieves information from the local node only. If `false`, information is retrieved from the cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Enumerable, String] :name Comma-separated list or wildcard expression of settings to retrieve. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + def get_settings(args = {}) + args = Utils.normalize_arguments(args) + _name = args.delete('name') + _index = args.delete('index') - _name = arguments.delete(:name) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = [_index, '_settings', _name].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_GET - path = if _index && _name - "#{Utils.__listify(_index)}/_settings/#{Utils.__listify(_name)}" - elsif _index - "#{Utils.__listify(_index)}/_settings" - elsif _name - "_settings/#{Utils.__listify(_name)}" - else - '_settings' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, GET_SETTINGS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_settings, %i[ - master_timeout - cluster_manager_timeout - ignore_unavailable + GET_SETTINGS_QUERY_PARAMS = Set.new(%w[ allow_no_indices + cluster_manager_timeout expand_wildcards flat_settings - local + ignore_unavailable include_defaults - ].freeze) + local + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/get_template.rb b/lib/opensearch/api/actions/indices/get_template.rb index ce6c6e6d1..1e0e05914 100644 --- a/lib/opensearch/api/actions/indices/get_template.rb +++ b/lib/opensearch/api/actions/indices/get_template.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,42 +15,30 @@ module Indices module Actions # Returns an index template. # - # @option arguments [List] :name The comma separated names of the index templates - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def get_template(arguments = {}) - headers = arguments.delete(:headers) || {} + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :flat_settings If `true`, returns settings in flat format. + # @option args [Boolean] :local If `true`, the request retrieves information from the local node only. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Enumerable, String] :name Comma-separated list of index template names used to limit the request. Wildcard (`*`) expressions are supported. To return all index templates, omit this parameter or use a value of `_all` or `*`. + def get_template(args = {}) + args = Utils.normalize_arguments(args) + _name = args.delete('name') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_template', _name].filter(&:present?).join('/').squeeze('/') - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_GET - path = if _name - "_template/#{Utils.__listify(_name)}" - else - '_template' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, GET_TEMPLATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_template, %i[ - flat_settings - master_timeout + GET_TEMPLATE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + flat_settings local - ].freeze) + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/get_upgrade.rb b/lib/opensearch/api/actions/indices/get_upgrade.rb index 89d249d69..a8aa53de2 100644 --- a/lib/opensearch/api/actions/indices/get_upgrade.rb +++ b/lib/opensearch/api/actions/indices/get_upgrade.rb @@ -3,72 +3,40 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Indices module Actions - # DEPRECATED Returns a progress status of current upgrade. - # - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Hash] :headers Custom HTTP headers - # - # *Deprecation notice*: - # The _upgrade API is no longer useful and will be removed. Instead, see _reindex API. - # Deprecated since version 8.0.0 + # The `_upgrade` API is no longer useful and will be removed. # - # - # - def get_upgrade(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) + # @option args [Boolean] :allow_no_indices Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified). + # @option args [Enumerable, String] :expand_wildcards Whether to expand wildcard expression to concrete indexes that are open, closed or both. + # @option args [Boolean] :ignore_unavailable Whether specified concrete indexes should be ignored when unavailable (missing or closed). + # @option args [Enumerable] :index Comma-separated list of indexes; use `_all` or empty string to perform the operation on all indexes. + def get_upgrade(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - method = OpenSearch::API::HTTP_GET - path = if _index - "#{Utils.__listify(_index)}/_upgrade" - else - '_upgrade' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = [_index, '_upgrade'].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, GET_UPGRADE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_upgrade, %i[ - ignore_unavailable + GET_UPGRADE_QUERY_PARAMS = Set.new(%w[ allow_no_indices expand_wildcards - ].freeze) + ignore_unavailable + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/open.rb b/lib/opensearch/api/actions/indices/open.rb index 0b61d52e5..e8f5ac8b8 100644 --- a/lib/opensearch/api/actions/indices/open.rb +++ b/lib/opensearch/api/actions/indices/open.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,46 +15,42 @@ module Indices module Actions # Opens an index. # - # @option arguments [List] :index A comma separated list of indices to open - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [String] :wait_for_active_shards Sets the number of active shards to wait for before the operation returns. - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def open(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Enumerable, String] :index *Required* Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). By default, you must explicitly name the indexes you using to limit the request. To limit a request using `_all`, `*`, or other wildcard expressions, change the `action.destructive_requires_name` setting to false. You can update this setting in the `opensearch.yml` file or using the cluster update settings API. + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :task_execution_timeout Explicit task execution timeout, only useful when `wait_for_completion` is false, defaults to `1h`. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + # @option args [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning. + def open(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] - _index = arguments.delete(:index) + _index = args.delete('index') - method = OpenSearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_open" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_index, '_open'].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, OPEN_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:open, %i[ - timeout - master_timeout - cluster_manager_timeout - ignore_unavailable + OPEN_QUERY_PARAMS = Set.new(%w[ allow_no_indices + cluster_manager_timeout expand_wildcards + ignore_unavailable + master_timeout + task_execution_timeout + timeout wait_for_active_shards - ].freeze) + wait_for_completion + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/params_registry.rb b/lib/opensearch/api/actions/indices/params_registry.rb deleted file mode 100644 index f2bea4304..000000000 --- a/lib/opensearch/api/actions/indices/params_registry.rb +++ /dev/null @@ -1,69 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Indices - module Actions - module ParamsRegistry - extend self - - # A Mapping of all the actions to their list of valid params. - # - # @since 6.1.1 - PARAMS = {} - - # Register an action with its list of valid params. - # - # @example Register the action. - # ParamsRegistry.register(:benchmark, [ :verbose ]) - # - # @param [ Symbol ] action The action to register. - # @param [ Array[Symbol] ] valid_params The list of valid params. - # - # @since 6.1.1 - def register(action, valid_params) - PARAMS[action.to_sym] = valid_params - end - - # Get the list of valid params for a given action. - # - # @example Get the list of valid params. - # ParamsRegistry.get(:benchmark) - # - # @param [ Symbol ] action The action. - # - # @return [ Array ] The list of valid params for the action. - # - # @since 6.1.1 - def get(action) - PARAMS.fetch(action, []) - end - end - end - end - end -end diff --git a/lib/opensearch/api/actions/indices/put_alias.rb b/lib/opensearch/api/actions/indices/put_alias.rb index 16581c305..c43fda118 100644 --- a/lib/opensearch/api/actions/indices/put_alias.rb +++ b/lib/opensearch/api/actions/indices/put_alias.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,43 +15,31 @@ module Indices module Actions # Creates or updates an alias. # - # @option arguments [List] :index A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. - # @option arguments [String] :name The name of the alias to be created or updated - # @option arguments [Time] :timeout Explicit timestamp for the document - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The settings for the alias, such as `routing` or `filter` - # - # - def put_alias(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) - - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_PUT - path = ("#{Utils.__listify(_index)}/_aliases/#{Utils.__listify(_name)}" if _index && _name) - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :name Alias to update. If the alias doesn't exist, the request creates it. Index alias names support date math. + # @option args [Enumerable, String] :index Comma-separated list of data streams or indexes to add. Supports wildcards (`*`). Wildcard patterns that match both data streams and indexes return an error. + # @option args [Hash] :body The settings for the alias, such as `routing` or `filter` + def put_alias(args = {}) + args = Utils.normalize_arguments(args) + _name = args.delete('name') + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = _name.present? ? 'PUT' : 'POST' + url = [_index, '_aliases', _name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, PUT_ALIAS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:put_alias, %i[ - timeout - master_timeout + PUT_ALIAS_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout - ].freeze) + master_timeout + timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/put_index_template.rb b/lib/opensearch/api/actions/indices/put_index_template.rb index 69ce5dd09..75f92fa06 100644 --- a/lib/opensearch/api/actions/indices/put_index_template.rb +++ b/lib/opensearch/api/actions/indices/put_index_template.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,42 +15,34 @@ module Indices module Actions # Creates or updates an index template. # - # @option arguments [String] :name The name of the template - # @option arguments [Boolean] :create Whether the index template should only be added if new or can also replace an existing one - # @option arguments [String] :cause User defined reason for creating/updating the index template - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The template definition (*Required*) - # - # - def put_index_template(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] + # @option args [String] :name *Required* Index or template name + # @option args [String] :cause User defined reason for creating/updating the index template. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :create If `true`, this request cannot replace or update existing index templates. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Hash] :body *Required* The template definition + def put_index_template(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - headers = arguments.delete(:headers) || {} + _name = args.delete('name') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_index_template', _name].filter(&:present?).join('/').squeeze('/') - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_PUT - path = "_index_template/#{Utils.__listify(_name)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, PUT_INDEX_TEMPLATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:put_index_template, %i[ - create + PUT_INDEX_TEMPLATE_QUERY_PARAMS = Set.new(%w[ cause - master_timeout cluster_manager_timeout - ].freeze) + create + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/put_mapping.rb b/lib/opensearch/api/actions/indices/put_mapping.rb index fbe555ebd..d57b216a6 100644 --- a/lib/opensearch/api/actions/indices/put_mapping.rb +++ b/lib/opensearch/api/actions/indices/put_mapping.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,52 +15,40 @@ module Indices module Actions # Updates the index mappings. # - # @option arguments [List] :index A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :write_index_only When true, applies mappings only to the write index of an alias or data stream - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The mapping definition (*Required*) - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def put_mapping(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - - headers = arguments.delete(:headers) || {} + # @option args [Enumerable, String] :index *Required* A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indexes. + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Boolean] :write_index_only If `true`, the mappings are applied only to the current write index for the target. + # @option args [Hash] :body *Required* The mapping definition + def put_mapping(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone + _index = args.delete('index') - _index = arguments.delete(:index) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_index, '_mapping'].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_PUT - path = "#{Utils.__listify(_index)}/_mappings" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, PUT_MAPPING_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:put_mapping, %i[ - timeout - master_timeout - cluster_manager_timeout - ignore_unavailable + PUT_MAPPING_QUERY_PARAMS = Set.new(%w[ allow_no_indices + cluster_manager_timeout expand_wildcards + ignore_unavailable + master_timeout + timeout write_index_only - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/put_settings.rb b/lib/opensearch/api/actions/indices/put_settings.rb index ab5047704..b7e0a5db8 100644 --- a/lib/opensearch/api/actions/indices/put_settings.rb +++ b/lib/opensearch/api/actions/indices/put_settings.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,53 +15,41 @@ module Indices module Actions # Updates the index settings. # - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Boolean] :preserve_existing Whether to update existing settings. If set to `true` existing settings on an index remain unchanged, the default is `false` - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The index settings to be updated (*Required*) - # - # - def put_settings(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - - headers = arguments.delete(:headers) || {} + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. + # @option args [Boolean] :flat_settings If `true`, returns settings in flat format. + # @option args [Boolean] :ignore_unavailable Whether specified concrete indexes should be ignored when unavailable (missing or closed). + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Boolean] :preserve_existing If `true`, existing index settings remain unchanged. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + # @option args [Hash] :body *Required* The index settings to be updated. + def put_settings(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone + _index = args.delete('index') - _index = arguments.delete(:index) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = [_index, '_settings'].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_PUT - path = if _index - "#{Utils.__listify(_index)}/_settings" - else - '_settings' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, PUT_SETTINGS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:put_settings, %i[ - master_timeout - cluster_manager_timeout - timeout - preserve_existing - ignore_unavailable + PUT_SETTINGS_QUERY_PARAMS = Set.new(%w[ allow_no_indices + cluster_manager_timeout expand_wildcards flat_settings - ].freeze) + ignore_unavailable + master_timeout + preserve_existing + timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/put_template.rb b/lib/opensearch/api/actions/indices/put_template.rb index 9c3b091d8..8bc991e65 100644 --- a/lib/opensearch/api/actions/indices/put_template.rb +++ b/lib/opensearch/api/actions/indices/put_template.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,42 +15,34 @@ module Indices module Actions # Creates or updates an index template. # - # @option arguments [String] :name The name of the template - # @option arguments [Number] :order The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) - # @option arguments [Boolean] :create Whether the index template should only be added if new or can also replace an existing one - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The template definition (*Required*) - # - # - def put_template(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] + # @option args [String] :name *Required* The name of the template + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :create If `true`, this request cannot replace or update existing index templates. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Float] :order Order in which OpenSearch applies this template if index matches multiple templates. Templates with lower 'order' values are merged first. Templates with higher 'order' values are merged later, overriding templates with lower values. + # @option args [Hash] :body *Required* The template definition + def put_template(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - headers = arguments.delete(:headers) || {} + _name = args.delete('name') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_template', _name].filter(&:present?).join('/').squeeze('/') - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_PUT - path = "_template/#{Utils.__listify(_name)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, PUT_TEMPLATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:put_template, %i[ - order + PUT_TEMPLATE_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout create master_timeout - cluster_manager_timeout - ].freeze) + order + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/recovery.rb b/lib/opensearch/api/actions/indices/recovery.rb index dae9dcd8c..3dcfafb18 100644 --- a/lib/opensearch/api/actions/indices/recovery.rb +++ b/lib/opensearch/api/actions/indices/recovery.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,38 +15,26 @@ module Indices module Actions # Returns information about ongoing index shard recoveries. # - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - # @option arguments [Boolean] :detailed Whether to display detailed information about shard recovery - # @option arguments [Boolean] :active_only Display only those recoveries that are currently on-going - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def recovery(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) + # @option args [Boolean] :active_only If `true`, the response only includes ongoing shard recoveries. + # @option args [Boolean] :detailed If `true`, the response includes detailed information about shard recoveries. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + def recovery(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - method = OpenSearch::API::HTTP_GET - path = if _index - "#{Utils.__listify(_index)}/_recovery" - else - '_recovery' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = [_index, '_recovery'].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, RECOVERY_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:recovery, %i[ - detailed + RECOVERY_QUERY_PARAMS = Set.new(%w[ active_only - ].freeze) + detailed + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/refresh.rb b/lib/opensearch/api/actions/indices/refresh.rb index a94156497..02ab2c2a8 100644 --- a/lib/opensearch/api/actions/indices/refresh.rb +++ b/lib/opensearch/api/actions/indices/refresh.rb @@ -3,67 +3,40 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Indices module Actions - # Performs the refresh operation in one or more indices. - # - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Hash] :headers Custom HTTP headers + # Performs the refresh operation in one or more indexes. # - # - def refresh(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + def refresh(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - method = OpenSearch::API::HTTP_POST - path = if _index - "#{Utils.__listify(_index)}/_refresh" - else - '_refresh' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = [_index, '_refresh'].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, REFRESH_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:refresh, %i[ - ignore_unavailable + REFRESH_QUERY_PARAMS = Set.new(%w[ allow_no_indices expand_wildcards - ].freeze) + ignore_unavailable + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/resolve_index.rb b/lib/opensearch/api/actions/indices/resolve_index.rb index 29b09c8c9..aa3af3e91 100644 --- a/lib/opensearch/api/actions/indices/resolve_index.rb +++ b/lib/opensearch/api/actions/indices/resolve_index.rb @@ -3,65 +3,38 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Indices module Actions - # Returns information about any matching indices, aliases, and data streams - # This functionality is Experimental and may be changed or removed - # completely in a future release. OpenSearch will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. + # Returns information about any matching indexes, aliases, and data streams. # - # @option arguments [List] :name A comma-separated list of names or wildcard expressions - # @option arguments [String] :expand_wildcards Whether wildcard expressions should get expanded to open or closed indices (default: open) (options: open, closed, hidden, none, all) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def resolve_index(arguments = {}) - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] - - headers = arguments.delete(:headers) || {} + # @option args [Enumerable, String] :name *Required* Comma-separated name(s) or index pattern(s) of the indexes, aliases, and data streams to resolve. Resources on remote clusters can be specified using the ``:`` syntax. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + def resolve_index(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] - arguments = arguments.clone + _name = args.delete('name') - _name = arguments.delete(:name) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_resolve/index', _name].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_GET - path = "_resolve/index/#{Utils.__listify(_name)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, RESOLVE_INDEX_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:resolve_index, [ - :expand_wildcards - ].freeze) + RESOLVE_INDEX_QUERY_PARAMS = Set.new(%w[ + expand_wildcards + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/rollover.rb b/lib/opensearch/api/actions/indices/rollover.rb index 937bdc9a5..5479a3c5d 100644 --- a/lib/opensearch/api/actions/indices/rollover.rb +++ b/lib/opensearch/api/actions/indices/rollover.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -31,50 +16,37 @@ module Actions # Updates an alias to point to a new index when the existing index # is considered to be too large or too old. # - # @option arguments [String] :alias The name of the alias to rollover - # @option arguments [String] :new_index The name of the rollover index - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Boolean] :dry_run If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [String] :wait_for_active_shards Set the number of active shards to wait for on the newly created rollover index before the operation returns. - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The conditions that needs to be met for executing rollover - # - # - def rollover(arguments = {}) - raise ArgumentError, "Required argument 'alias' missing" unless arguments[:alias] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _alias = arguments.delete(:alias) - - _new_index = arguments.delete(:new_index) - - method = OpenSearch::API::HTTP_POST - path = if _alias && _new_index - "#{Utils.__listify(_alias)}/_rollover/#{Utils.__listify(_new_index)}" - else - "#{Utils.__listify(_alias)}/_rollover" - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + # @option args [String] :alias *Required* Name of the data stream or index alias to roll over. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :dry_run If `true`, checks whether the current index satisfies the specified conditions but does not perform a rollover. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + # @option args [String] :new_index Name of the index to create. Supports date math. Data streams do not support this parameter. + # @option args [Hash] :body The conditions that needs to be met for executing rollover + def rollover(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'alias' missing" unless args['alias'] + + _alias = args.delete('alias') + _new_index = args.delete('new_index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_alias, '_rollover', _new_index].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, ROLLOVER_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:rollover, %i[ - timeout + ROLLOVER_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout dry_run master_timeout - cluster_manager_timeout + timeout wait_for_active_shards - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/segments.rb b/lib/opensearch/api/actions/indices/segments.rb index 4f60577ac..f2f9493a5 100644 --- a/lib/opensearch/api/actions/indices/segments.rb +++ b/lib/opensearch/api/actions/indices/segments.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,42 +15,30 @@ module Indices module Actions # Provides low-level information about segments in a Lucene index. # - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :verbose Includes detailed memory usage by Lucene. - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def segments(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Boolean] :verbose If `true`, the request returns a verbose response. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + def segments(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - method = OpenSearch::API::HTTP_GET - path = if _index - "#{Utils.__listify(_index)}/_segments" - else - '_segments' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = [_index, '_segments'].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, SEGMENTS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:segments, %i[ - ignore_unavailable + SEGMENTS_QUERY_PARAMS = Set.new(%w[ allow_no_indices expand_wildcards + ignore_unavailable verbose - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/shard_stores.rb b/lib/opensearch/api/actions/indices/shard_stores.rb index 225936a68..84a169c59 100644 --- a/lib/opensearch/api/actions/indices/shard_stores.rb +++ b/lib/opensearch/api/actions/indices/shard_stores.rb @@ -3,69 +3,42 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Indices module Actions - # Provides store information for shard copies of indices. - # - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - # @option arguments [List] :status A comma-separated list of statuses used to filter on shards to get store information for (options: green, yellow, red, all) - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Hash] :headers Custom HTTP headers - # + # Provides store information for shard copies of indexes. # - def shard_stores(arguments = {}) - headers = arguments.delete(:headers) || {} + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. + # @option args [Boolean] :ignore_unavailable If `true`, missing or closed indexes are not included in the response. + # @option args [Enumerable, String] :status List of shard health statuses used to limit the request. + # @option args [Enumerable, String] :index List of data streams, indexes, and aliases used to limit the request. + def shard_stores(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = [_index, '_shard_stores'].filter(&:present?).join('/').squeeze('/') - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_GET - path = if _index - "#{Utils.__listify(_index)}/_shard_stores" - else - '_shard_stores' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, SHARD_STORES_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:shard_stores, %i[ - status - ignore_unavailable + SHARD_STORES_QUERY_PARAMS = Set.new(%w[ allow_no_indices expand_wildcards - ].freeze) + ignore_unavailable + status + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/shrink.rb b/lib/opensearch/api/actions/indices/shrink.rb index 75d5a0f3b..5bf33f8d0 100644 --- a/lib/opensearch/api/actions/indices/shrink.rb +++ b/lib/opensearch/api/actions/indices/shrink.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,47 +15,42 @@ module Indices module Actions # Allow to shrink an existing index into a new index with fewer primary shards. # - # @option arguments [String] :index The name of the source index to shrink - # @option arguments [String] :target The name of the target index to shrink into - # @option arguments [Boolean] :copy_settings whether or not to copy settings from the source index (defaults to false) - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [String] :wait_for_active_shards Set the number of active shards to wait for on the shrunken index before the operation returns. - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The configuration for the target index (`settings` and `aliases`) - # - # - def shrink(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'target' missing" unless arguments[:target] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) - - _target = arguments.delete(:target) - - method = OpenSearch::API::HTTP_PUT - path = "#{Utils.__listify(_index)}/_shrink/#{Utils.__listify(_target)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + # @option args [String] :index *Required* Name of the source index to shrink. + # @option args [String] :target *Required* Name of the target index to create. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :copy_settings whether or not to copy settings from the source index. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :task_execution_timeout Explicit task execution timeout, only useful when `wait_for_completion` is false, defaults to `1h`. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + # @option args [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning. + # @option args [Hash] :body The configuration for the target index (`settings` and `aliases`) + def shrink(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + raise ArgumentError, "Required argument 'target' missing" unless args['target'] + + _index = args.delete('index') + _target = args.delete('target') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_index, '_shrink', _target].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, SHRINK_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:shrink, %i[ + SHRINK_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout copy_settings - timeout master_timeout - cluster_manager_timeout + task_execution_timeout + timeout wait_for_active_shards - ].freeze) + wait_for_completion + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/simulate_index_template.rb b/lib/opensearch/api/actions/indices/simulate_index_template.rb index fb3a77c71..e5d334a1e 100644 --- a/lib/opensearch/api/actions/indices/simulate_index_template.rb +++ b/lib/opensearch/api/actions/indices/simulate_index_template.rb @@ -3,68 +3,41 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Indices module Actions - # Simulate matching the given index name against the index templates in the system - # - # @option arguments [String] :name The name of the index (it must be a concrete index name) - # @option arguments [Boolean] :create Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one - # @option arguments [String] :cause User defined reason for dry-run creating the new template for simulation purposes - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body New index template definition, which will be included in the simulation, as if it already exists in the system + # Simulate matching the given index name against the index templates in the system. # - # - def simulate_index_template(arguments = {}) - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :name *Required* Index or template name to simulate + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Hash] :body New index template definition, which will be included in the simulation, as if it already exists in the system + def simulate_index_template(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] - _name = arguments.delete(:name) + _name = args.delete('name') - method = OpenSearch::API::HTTP_POST - path = "_index_template/_simulate_index/#{Utils.__listify(_name)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_index_template/_simulate_index', _name].filter(&:present?).join('/').squeeze('/') - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, SIMULATE_INDEX_TEMPLATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:simulate_index_template, %i[ - create - cause - master_timeout + SIMULATE_INDEX_TEMPLATE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout - ].freeze) + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/simulate_template.rb b/lib/opensearch/api/actions/indices/simulate_template.rb index 44727e555..d11395e9f 100644 --- a/lib/opensearch/api/actions/indices/simulate_template.rb +++ b/lib/opensearch/api/actions/indices/simulate_template.rb @@ -3,70 +3,43 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Indices module Actions - # Simulate resolving the given template name or body - # - # @option arguments [String] :name The name of the index template - # @option arguments [Boolean] :create Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one - # @option arguments [String] :cause User defined reason for dry-run creating the new template for simulation purposes - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body New index template definition to be simulated, if no index template name is specified - # + # Simulate resolving the given template name or body. # - def simulate_template(arguments = {}) - headers = arguments.delete(:headers) || {} + # @option args [String] :cause User defined reason for dry-run creating the new template for simulation purposes. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :create If `true`, the template passed in the body is only used if no existing templates match the same index patterns. If `false`, the simulation uses the template with the highest priority. Note that the template is not permanently added or updated in either case; it is only used for the simulation. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :name Name of the index template to simulate. To test a template configuration before you add it to the cluster, omit this parameter and specify the template configuration in the request body. + # @option args [Hash] :body New index template definition to be simulated, if no index template name is specified. + def simulate_template(args = {}) + args = Utils.normalize_arguments(args) + _name = args.delete('name') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_index_template/_simulate', _name].filter(&:present?).join('/').squeeze('/') - _name = arguments.delete(:name) - - method = OpenSearch::API::HTTP_POST - path = if _name - "_index_template/_simulate/#{Utils.__listify(_name)}" - else - '_index_template/_simulate' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, SIMULATE_TEMPLATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:simulate_template, %i[ - create + SIMULATE_TEMPLATE_QUERY_PARAMS = Set.new(%w[ cause - master_timeout cluster_manager_timeout - ].freeze) + create + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/split.rb b/lib/opensearch/api/actions/indices/split.rb index b75cf6f22..7cb74fe58 100644 --- a/lib/opensearch/api/actions/indices/split.rb +++ b/lib/opensearch/api/actions/indices/split.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,47 +15,42 @@ module Indices module Actions # Allows you to split an existing index into a new index with more primary shards. # - # @option arguments [String] :index The name of the source index to split - # @option arguments [String] :target The name of the target index to split into - # @option arguments [Boolean] :copy_settings whether or not to copy settings from the source index (defaults to false) - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [String] :wait_for_active_shards Set the number of active shards to wait for on the shrunken index before the operation returns. - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The configuration for the target index (`settings` and `aliases`) - # - # - def split(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'target' missing" unless arguments[:target] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) - - _target = arguments.delete(:target) - - method = OpenSearch::API::HTTP_PUT - path = "#{Utils.__listify(_index)}/_split/#{Utils.__listify(_target)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + # @option args [String] :index *Required* Name of the source index to split. + # @option args [String] :target *Required* Name of the target index to create. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :copy_settings whether or not to copy settings from the source index. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :task_execution_timeout Explicit task execution timeout, only useful when `wait_for_completion` is false, defaults to `1h`. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + # @option args [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning. + # @option args [Hash] :body The configuration for the target index (`settings` and `aliases`) + def split(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + raise ArgumentError, "Required argument 'target' missing" unless args['target'] + + _index = args.delete('index') + _target = args.delete('target') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_index, '_split', _target].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, SPLIT_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:split, %i[ + SPLIT_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout copy_settings - timeout master_timeout - cluster_manager_timeout + task_execution_timeout + timeout wait_for_active_shards - ].freeze) + wait_for_completion + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/stats.rb b/lib/opensearch/api/actions/indices/stats.rb index 41156485c..2fb16a3b0 100644 --- a/lib/opensearch/api/actions/indices/stats.rb +++ b/lib/opensearch/api/actions/indices/stats.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,70 +15,42 @@ module Indices module Actions # Provides statistics on operations happening in an index. # - # @option arguments [List] :metric Limit the information returned the specific metrics. (options: _all, completion, docs, fielddata, query_cache, flush, get, indexing, merge, request_cache, refresh, search, segments, store, warmer, suggest) - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - # @option arguments [List] :completion_fields A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) - # @option arguments [List] :fielddata_fields A comma-separated list of fields for `fielddata` index metric (supports wildcards) - # @option arguments [List] :fields A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) - # @option arguments [List] :groups A comma-separated list of search groups for `search` index metric - # @option arguments [String] :level Return stats aggregated at cluster, index or shard level (options: cluster, indices, shards) - # @option arguments [List] :types A comma-separated list of document types for the `indexing` index metric - # @option arguments [Boolean] :include_segment_file_sizes Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) - # @option arguments [Boolean] :include_unloaded_segments If set to true segment stats will include stats for segments that are not currently loaded into memory - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :forbid_closed_indices If set to false stats will also collected from closed indices if explicitly specified or if expand_wildcards expands to closed indices - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def stats(arguments = {}) - headers = arguments.delete(:headers) || {} + # @option args [Enumerable, String] :completion_fields Comma-separated list or wildcard expressions of fields to include in field data and suggest statistics. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. + # @option args [Enumerable, String] :fielddata_fields Comma-separated list or wildcard expressions of fields to include in field data statistics. + # @option args [Enumerable, String] :fields Comma-separated list or wildcard expressions of fields to include in the statistics. + # @option args [Boolean] :forbid_closed_indices If `true`, statistics are not collected from closed indexes. + # @option args [Enumerable, String] :groups Comma-separated list of search groups to include in the search statistics. + # @option args [Boolean] :include_segment_file_sizes If `true`, the call reports the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested). + # @option args [Boolean] :include_unloaded_segments If `true`, the response includes information from segments that are not loaded into memory. + # @option args [String] :level Indicates whether statistics are aggregated at the cluster, index, or shard level. + # @option args [Enumerable, String] :metric Limit the information returned the specific metrics. + # @option args [Enumerable, String] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indexes + def stats(args = {}) + args = Utils.normalize_arguments(args) + _metric = args.delete('metric') + _index = args.delete('index') - method = HTTP_GET - parts = Utils.__extract_parts arguments, ParamsRegistry.get(:stats_parts) - path = Utils.__pathify Utils.__listify(arguments[:index]), '_stats', Utils.__listify(parts) - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(:stats_params) - params[:fields] = Utils.__listify(params[:fields], escape: false) if params[:fields] - params[:groups] = Utils.__listify(params[:groups], escape: false) if params[:groups] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = [_index, '_stats', _metric].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, STATS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:stats_params, %i[ + STATS_QUERY_PARAMS = Set.new(%w[ completion_fields + expand_wildcards fielddata_fields fields + forbid_closed_indices groups - level - types include_segment_file_sizes include_unloaded_segments - expand_wildcards - forbid_closed_indices - ].freeze) - - ParamsRegistry.register(:stats_parts, %i[ - _all - completion - docs - fielddata - query_cache - flush - get - indexing - merge - request_cache - refresh - search - segments - store - warmer - suggest - metric - ].freeze) + level + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/update_aliases.rb b/lib/opensearch/api/actions/indices/update_aliases.rb index 47b7397ff..8213a9a92 100644 --- a/lib/opensearch/api/actions/indices/update_aliases.rb +++ b/lib/opensearch/api/actions/indices/update_aliases.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,36 +15,28 @@ module Indices module Actions # Updates index aliases. # - # @option arguments [Time] :timeout Request timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The definition of `actions` to perform (*Required*) - # - # - def update_aliases(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Hash] :body *Required* The definition of `actions` to perform + def update_aliases(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - headers = arguments.delete(:headers) || {} + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_aliases' - arguments = arguments.clone - - method = OpenSearch::API::HTTP_POST - path = '_aliases' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, UPDATE_ALIASES_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:update_aliases, %i[ - timeout - master_timeout + UPDATE_ALIASES_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout - ].freeze) + master_timeout + timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/upgrade.rb b/lib/opensearch/api/actions/indices/upgrade.rb index a1ac37130..daec3da42 100644 --- a/lib/opensearch/api/actions/indices/upgrade.rb +++ b/lib/opensearch/api/actions/indices/upgrade.rb @@ -3,76 +3,45 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Indices module Actions - # DEPRECATED Upgrades to the current version of Lucene. - # - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :wait_for_completion Specify whether the request should block until the all segments are upgraded (default: false) - # @option arguments [Boolean] :only_ancient_segments If true, only ancient (an older Lucene major release) segments will be upgraded - # @option arguments [Hash] :headers Custom HTTP headers - # - # *Deprecation notice*: - # The _upgrade API is no longer useful and will be removed. Instead, see _reindex API. - # Deprecated since version 8.0.0 + # The `_upgrade` API is no longer useful and will be removed. # - # - # - def upgrade(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) + # @option args [Boolean] :allow_no_indices Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified). + # @option args [Enumerable, String] :expand_wildcards Whether to expand wildcard expression to concrete indexes that are open, closed or both. + # @option args [Boolean] :ignore_unavailable Whether specified concrete indexes should be ignored when unavailable (missing or closed). + # @option args [Boolean] :only_ancient_segments If `true`, only ancient (an older Lucene major release) segments will be upgraded. + # @option args [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning. + # @option args [Enumerable] :index Comma-separated list of indexes; use `_all` or empty string to perform the operation on all indexes. + # @option args [Hash] :body + def upgrade(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - method = OpenSearch::API::HTTP_POST - path = if _index - "#{Utils.__listify(_index)}/_upgrade" - else - '_upgrade' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_index, '_upgrade'].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, UPGRADE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:upgrade, %i[ + UPGRADE_QUERY_PARAMS = Set.new(%w[ allow_no_indices expand_wildcards ignore_unavailable - wait_for_completion only_ancient_segments - ].freeze) + wait_for_completion + ]).freeze end end end diff --git a/lib/opensearch/api/actions/indices/validate_query.rb b/lib/opensearch/api/actions/indices/validate_query.rb index 88525c0e9..74ec58cdc 100644 --- a/lib/opensearch/api/actions/indices/validate_query.rb +++ b/lib/opensearch/api/actions/indices/validate_query.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,69 +15,47 @@ module Indices module Actions # Allows a user to validate a potentially expensive query without executing it. # - # @option arguments [List] :index A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices - # @option arguments [Boolean] :explain Return detailed information about the error - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [String] :q Query in the Lucene query string syntax - # @option arguments [String] :analyzer The analyzer to use for the query string - # @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false) - # @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR) - # @option arguments [String] :df The field to use as default where no field prefix is given in the query string - # @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - # @option arguments [Boolean] :rewrite Provide a more detailed explanation showing the actual Lucene query that will be executed. - # @option arguments [Boolean] :all_shards Execute validation on all shards instead of one random shard per index - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The query definition specified with the Query DSL - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def validate_query(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) - - method = if arguments[:body] - OpenSearch::API::HTTP_POST - else - OpenSearch::API::HTTP_GET - end + # @option args [Boolean] :all_shards If `true`, the validation is executed on all shards instead of one random shard per index. + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. + # @option args [Boolean] :analyze_wildcard If `true`, wildcard and prefix queries are analyzed. + # @option args [String] :analyzer Analyzer to use for the query string. This parameter can only be used when the `q` query string parameter is specified. + # @option args [String] :default_operator The default operator for query string query: `AND` or `OR`. + # @option args [String] :df Field to use as default where no field prefix is given in the query string. This parameter can only be used when the `q` query string parameter is specified. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :explain If `true`, the response returns detailed information if an error has occurred. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Boolean] :lenient If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. + # @option args [String] :q Query in the Lucene query string syntax. + # @option args [Boolean] :rewrite If `true`, returns a more detailed explanation showing the actual Lucene query that will be executed. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams or indexes, omit this parameter or use `*` or `_all`. + # @option args [Hash] :body The query definition specified with the Query DSL + def validate_query(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - path = if _index - "#{Utils.__listify(_index)}/_validate/query" - else - '_validate/query' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = [_index, '_validate/query'].filter(&:present?).join('/').squeeze('/') - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, VALIDATE_QUERY_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:validate_query, %i[ - explain - ignore_unavailable + VALIDATE_QUERY_QUERY_PARAMS = Set.new(%w[ + all_shards allow_no_indices - expand_wildcards - q - analyzer analyze_wildcard + analyzer default_operator df + expand_wildcards + explain + ignore_unavailable lenient + q rewrite - all_shards - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/info.rb b/lib/opensearch/api/actions/info.rb index 0e2190f0a..6d6893479 100644 --- a/lib/opensearch/api/actions/info.rb +++ b/lib/opensearch/api/actions/info.rb @@ -3,46 +3,28 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -module OpenSearch - module API - module Actions - # Returns basic information about the cluster. - # - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def info(arguments = {}) - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - method = OpenSearch::API::HTTP_GET - path = '' - params = {} +module OpenSearch + module API + module Root + module Actions + # Returns basic information about the cluster. + # + def info(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '/' - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end end end end diff --git a/lib/opensearch/api/actions/ingest/delete_pipeline.rb b/lib/opensearch/api/actions/ingest/delete_pipeline.rb index f5bd6c852..3f690eb25 100644 --- a/lib/opensearch/api/actions/ingest/delete_pipeline.rb +++ b/lib/opensearch/api/actions/ingest/delete_pipeline.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,38 +15,32 @@ module Ingest module Actions # Deletes a pipeline. # - # @option arguments [String] :id Pipeline ID - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def delete_pipeline(arguments = {}) - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :id *Required* Pipeline ID or wildcard expression of pipeline IDs used to limit the request. To delete all ingest pipelines in a cluster, use a value of `*`. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_pipeline(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] - _id = arguments.delete(:id) + _id = args.delete('id') - method = OpenSearch::API::HTTP_DELETE - path = "_ingest/pipeline/#{Utils.__listify(_id)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_ingest/pipeline', _id].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, DELETE_PIPELINE_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:delete_pipeline, %i[ - master_timeout + DELETE_PIPELINE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + master_timeout timeout - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/ingest/geo_ip_stats.rb b/lib/opensearch/api/actions/ingest/geo_ip_stats.rb deleted file mode 100644 index ae55c2c85..000000000 --- a/lib/opensearch/api/actions/ingest/geo_ip_stats.rb +++ /dev/null @@ -1,51 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Ingest - module Actions - # Returns statistical information about geoip databases - # - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def geo_ip_stats(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - method = OpenSearch::API::HTTP_GET - path = '_ingest/geoip/stats' - params = {} - - body = nil - perform_request(method, path, params, body, headers).body - end - end - end - end -end diff --git a/lib/opensearch/api/actions/ingest/get_pipeline.rb b/lib/opensearch/api/actions/ingest/get_pipeline.rb index 326435517..3a646e41a 100644 --- a/lib/opensearch/api/actions/ingest/get_pipeline.rb +++ b/lib/opensearch/api/actions/ingest/get_pipeline.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,40 +15,26 @@ module Ingest module Actions # Returns a pipeline. # - # @option arguments [String] :id Comma separated list of pipeline ids. Wildcards supported - # @option arguments [Boolean] :summary Return pipelines without their definitions (default: false) - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def get_pipeline(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _id = arguments.delete(:id) + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :id Comma-separated list of pipeline IDs to retrieve. Wildcard (`*`) expressions are supported. To get all ingest pipelines, omit this parameter or use `*`. + def get_pipeline(args = {}) + args = Utils.normalize_arguments(args) + _id = args.delete('id') - method = OpenSearch::API::HTTP_GET - path = if _id - "_ingest/pipeline/#{Utils.__listify(_id)}" - else - '_ingest/pipeline' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_ingest/pipeline', _id].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, GET_PIPELINE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_pipeline, %i[ - summary - master_timeout + GET_PIPELINE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout - ].freeze) + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/ingest/params_registry.rb b/lib/opensearch/api/actions/ingest/params_registry.rb deleted file mode 100644 index 4b27396df..000000000 --- a/lib/opensearch/api/actions/ingest/params_registry.rb +++ /dev/null @@ -1,69 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Ingest - module Actions - module ParamsRegistry - extend self - - # A Mapping of all the actions to their list of valid params. - # - # @since 6.1.1 - PARAMS = {} - - # Register an action with its list of valid params. - # - # @example Register the action. - # ParamsRegistry.register(:benchmark, [ :verbose ]) - # - # @param [ Symbol ] action The action to register. - # @param [ Array[Symbol] ] valid_params The list of valid params. - # - # @since 6.1.1 - def register(action, valid_params) - PARAMS[action.to_sym] = valid_params - end - - # Get the list of valid params for a given action. - # - # @example Get the list of valid params. - # ParamsRegistry.get(:benchmark) - # - # @param [ Symbol ] action The action. - # - # @return [ Array ] The list of valid params for the action. - # - # @since 6.1.1 - def get(action) - PARAMS.fetch(action, []) - end - end - end - end - end -end diff --git a/lib/opensearch/api/actions/ingest/processor_grok.rb b/lib/opensearch/api/actions/ingest/processor_grok.rb index 6dd0a50b6..8d5c6c7de 100644 --- a/lib/opensearch/api/actions/ingest/processor_grok.rb +++ b/lib/opensearch/api/actions/ingest/processor_grok.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,21 +15,21 @@ module Ingest module Actions # Returns a list of the built-in patterns. # - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def processor_grok(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Boolean] :s Sort returned patterns by key name. + def processor_grok(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_ingest/processor/grok' - method = OpenSearch::API::HTTP_GET - path = '_ingest/processor/grok' - params = {} - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, PROCESSOR_GROK_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end + + PROCESSOR_GROK_QUERY_PARAMS = Set.new(%w[ + s + ]).freeze end end end diff --git a/lib/opensearch/api/actions/ingest/put_pipeline.rb b/lib/opensearch/api/actions/ingest/put_pipeline.rb index e336b01c3..5b9a85004 100644 --- a/lib/opensearch/api/actions/ingest/put_pipeline.rb +++ b/lib/opensearch/api/actions/ingest/put_pipeline.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,40 +15,32 @@ module Ingest module Actions # Creates or updates a pipeline. # - # @option arguments [String] :id Pipeline ID - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The ingest definition (*Required*) - # - # - def put_pipeline(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :id *Required* ID of the ingest pipeline to create or update. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Hash] :body *Required* The ingest definition + def put_pipeline(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - _id = arguments.delete(:id) + _id = args.delete('id') - method = OpenSearch::API::HTTP_PUT - path = "_ingest/pipeline/#{Utils.__listify(_id)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_ingest/pipeline', _id].filter(&:present?).join('/').squeeze('/') - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, PUT_PIPELINE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:put_pipeline, %i[ - master_timeout + PUT_PIPELINE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + master_timeout timeout - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/ingest/simulate.rb b/lib/opensearch/api/actions/ingest/simulate.rb index 7202b8b6c..0cb4c4ae7 100644 --- a/lib/opensearch/api/actions/ingest/simulate.rb +++ b/lib/opensearch/api/actions/ingest/simulate.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,39 +15,27 @@ module Ingest module Actions # Allows to simulate a pipeline with example documents. # - # @option arguments [String] :id Pipeline ID - # @option arguments [Boolean] :verbose Verbose mode. Display data output for each processor in executed pipeline - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The simulate definition (*Required*) - # - # - def simulate(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - - headers = arguments.delete(:headers) || {} + # @option args [Boolean] :verbose If `true`, the response includes output data for each processor in the executed pipeline. + # @option args [String] :id Pipeline to test. If you don't specify a `pipeline` in the request body, this parameter is required. + # @option args [Hash] :body *Required* The simulate definition + def simulate(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone + _id = args.delete('id') - _id = arguments.delete(:id) + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = ['_ingest/pipeline', _id, '_simulate'].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_POST - path = if _id - "_ingest/pipeline/#{Utils.__listify(_id)}/_simulate" - else - '_ingest/pipeline/_simulate' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, SIMULATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:simulate, [ - :verbose - ].freeze) + SIMULATE_QUERY_PARAMS = Set.new(%w[ + verbose + ]).freeze end end end diff --git a/lib/opensearch/api/actions/insights/top_queries.rb b/lib/opensearch/api/actions/insights/top_queries.rb new file mode 100644 index 000000000..887ea6c19 --- /dev/null +++ b/lib/opensearch/api/actions/insights/top_queries.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Insights + module Actions + # Retrieves the top queries based on the given metric type (latency, CPU, or memory). + # + # @option args [String] :type *Required* Get top n queries by a specific metric. + def top_queries(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'type' missing" unless args['type'] + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_insights/top_queries' + + Utils.validate_query_params args, TOP_QUERIES_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + TOP_QUERIES_QUERY_PARAMS = Set.new(%w[ + type + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/ism/add_policy.rb b/lib/opensearch/api/actions/ism/add_policy.rb new file mode 100644 index 000000000..b8140e85f --- /dev/null +++ b/lib/opensearch/api/actions/ism/add_policy.rb @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ism + module Actions + # Adds a policy to an index. + # + # @option args [String] :index *Required* Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). + # @option args [Hash] :body + def add_policy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_ism/add', _index].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ism/change_policy.rb b/lib/opensearch/api/actions/ism/change_policy.rb new file mode 100644 index 000000000..2780051c8 --- /dev/null +++ b/lib/opensearch/api/actions/ism/change_policy.rb @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ism + module Actions + # Updates the managed index policy to a new policy. + # + # @option args [String] :index *Required* Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). + # @option args [Hash] :body + def change_policy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_ism/change_policy', _index].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ism/delete_policy.rb b/lib/opensearch/api/actions/ism/delete_policy.rb new file mode 100644 index 000000000..f7d056ccb --- /dev/null +++ b/lib/opensearch/api/actions/ism/delete_policy.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ism + module Actions + # Deletes a policy. + # + # @option args [String] :policy_id *Required* + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_policy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'policy_id' missing" unless args['policy_id'] + + _policy_id = args.delete('policy_id') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_ism/policies', _policy_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ism/exists_policy.rb b/lib/opensearch/api/actions/ism/exists_policy.rb new file mode 100644 index 000000000..138a5ba72 --- /dev/null +++ b/lib/opensearch/api/actions/ism/exists_policy.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ism + module Actions + # Checks whether the policy exists. + # + # @option args [String] :policy_id *Required* + def exists_policy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'policy_id' missing" unless args['policy_id'] + + _policy_id = args.delete('policy_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'HEAD' + url = ['_plugins/_ism/policies', _policy_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_head_request method, url, args, body, headers + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ism/explain_policy.rb b/lib/opensearch/api/actions/ism/explain_policy.rb new file mode 100644 index 000000000..1fe573b4b --- /dev/null +++ b/lib/opensearch/api/actions/ism/explain_policy.rb @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ism + module Actions + # Gets the currently applied policy on indexes. + # + # @option args [String] :index Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). + # @option args [Hash] :body + def explain_policy(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = ['_plugins/_ism/explain', _index].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ism/get_policies.rb b/lib/opensearch/api/actions/ism/get_policies.rb new file mode 100644 index 000000000..545c9b64a --- /dev/null +++ b/lib/opensearch/api/actions/ism/get_policies.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ism + module Actions + # Gets the policies. + # + def get_policies(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_ism/policies' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ism/get_policy.rb b/lib/opensearch/api/actions/ism/get_policy.rb new file mode 100644 index 000000000..6bf8c3a5a --- /dev/null +++ b/lib/opensearch/api/actions/ism/get_policy.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ism + module Actions + # Gets a policy. + # + # @option args [String] :policy_id *Required* + def get_policy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'policy_id' missing" unless args['policy_id'] + + _policy_id = args.delete('policy_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_ism/policies', _policy_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ism/put_policies.rb b/lib/opensearch/api/actions/ism/put_policies.rb new file mode 100644 index 000000000..f1a335461 --- /dev/null +++ b/lib/opensearch/api/actions/ism/put_policies.rb @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ism + module Actions + # Gets the policies. + # + # @option args [Float] :if_primary_term Only perform the operation if the document has this primary term. + # @option args [Integer] :if_seq_no Only perform the operation if the document has this sequence number. + # @option args [String] :policyID *Required* + # @option args [Hash] :body + def put_policies(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'policyID' missing" unless args['policyID'] + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = '_plugins/_ism/policies' + + Utils.validate_query_params args, PUT_POLICIES_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + PUT_POLICIES_QUERY_PARAMS = Set.new(%w[ + if_primary_term + if_seq_no + policyID + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/ism/put_policy.rb b/lib/opensearch/api/actions/ism/put_policy.rb new file mode 100644 index 000000000..15ba3066a --- /dev/null +++ b/lib/opensearch/api/actions/ism/put_policy.rb @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ism + module Actions + # Creates or updates a policy. + # + # @option args [String] :policy_id *Required* + # @option args [Float] :if_primary_term Only perform the operation if the document has this primary term. + # @option args [Integer] :if_seq_no Only perform the operation if the document has this sequence number. + # @option args [Hash] :body + def put_policy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'policy_id' missing" unless args['policy_id'] + + _policy_id = args.delete('policy_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_ism/policies', _policy_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, PUT_POLICY_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + PUT_POLICY_QUERY_PARAMS = Set.new(%w[ + if_primary_term + if_seq_no + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/ism/refresh_search_analyzers.rb b/lib/opensearch/api/actions/ism/refresh_search_analyzers.rb new file mode 100644 index 000000000..48ab5f669 --- /dev/null +++ b/lib/opensearch/api/actions/ism/refresh_search_analyzers.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ism + module Actions + # Refresh search analyzers in real time. + # + # @option args [String] :index *Required* Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). + def refresh_search_analyzers(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_refresh_search_analyzers', _index].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ism/remove_policy.rb b/lib/opensearch/api/actions/ism/remove_policy.rb new file mode 100644 index 000000000..31ce05042 --- /dev/null +++ b/lib/opensearch/api/actions/ism/remove_policy.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ism + module Actions + # Removes a policy from an index. + # + # @option args [String] :index *Required* Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). + def remove_policy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_ism/remove', _index].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ism/retry_index.rb b/lib/opensearch/api/actions/ism/retry_index.rb new file mode 100644 index 000000000..946744f56 --- /dev/null +++ b/lib/opensearch/api/actions/ism/retry_index.rb @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ism + module Actions + # Retry the failed action for an index. + # + # @option args [String] :index *Required* Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). + # @option args [Hash] :body + def retry_index(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_ism/retry', _index].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/knn/delete_model.rb b/lib/opensearch/api/actions/knn/delete_model.rb new file mode 100644 index 000000000..c5966be79 --- /dev/null +++ b/lib/opensearch/api/actions/knn/delete_model.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Knn + module Actions + # Used to delete a particular model in the cluster. + # + # @option args [String] :model_id *Required* The id of the model. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_model(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'model_id' missing" unless args['model_id'] + + _model_id = args.delete('model_id') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_knn/models', _model_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/knn/get_model.rb b/lib/opensearch/api/actions/knn/get_model.rb new file mode 100644 index 000000000..f67278bd4 --- /dev/null +++ b/lib/opensearch/api/actions/knn/get_model.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Knn + module Actions + # Used to retrieve information about models present in the cluster. + # + # @option args [String] :model_id *Required* The id of the model. + def get_model(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'model_id' missing" unless args['model_id'] + + _model_id = args.delete('model_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_knn/models', _model_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/knn/search_models.rb b/lib/opensearch/api/actions/knn/search_models.rb new file mode 100644 index 000000000..c44249d3d --- /dev/null +++ b/lib/opensearch/api/actions/knn/search_models.rb @@ -0,0 +1,119 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Knn + module Actions + # Use an OpenSearch query to search for models in the index. + # + # @option args [Enumerable] :_source Set to `true` or `false` to return the `_source` field or not, or a list of fields to return. + # @option args [Enumerable] :_source_excludes List of fields to exclude from the returned `_source` field. + # @option args [Enumerable] :_source_includes List of fields to extract and return from the `_source` field. + # @option args [Boolean] :allow_no_indices Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified). + # @option args [Boolean] :allow_partial_search_results Indicate if an error should be returned if there is a partial search failure or timeout. + # @option args [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed. + # @option args [String] :analyzer The analyzer to use for the query string. + # @option args [Integer] :batched_reduce_size The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. + # @option args [Boolean] :ccs_minimize_roundtrips Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution. + # @option args [String] :default_operator The default operator for query string query (AND or OR). + # @option args [String] :df The field to use as default where no field prefix is given in the query string. + # @option args [Enumerable] :docvalue_fields Comma-separated list of fields to return as the docvalue representation of a field for each hit. + # @option args [Enumerable, String] :expand_wildcards Whether to expand wildcard expression to concrete indexes that are open, closed or both. + # @option args [Boolean] :explain Specify whether to return detailed information about score computation as part of a hit. + # @option args [Integer] :from Starting offset. + # @option args [Boolean] :ignore_throttled Whether specified concrete, expanded or aliased indexes should be ignored when throttled. + # @option args [Boolean] :ignore_unavailable Whether specified concrete indexes should be ignored when unavailable (missing or closed). + # @option args [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored. + # @option args [Integer] :max_concurrent_shard_requests The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests. + # @option args [Integer] :pre_filter_shard_size Threshold that enforces a pre-filter round-trip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter round-trip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method, that is if date filters are mandatory to match but the shard bounds and the query are disjoint. + # @option args [String] :preference Specify the node or shard the operation should be performed on. + # @option args [String] :q Query in the Lucene query string syntax. + # @option args [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting. + # @option args [Boolean] :rest_total_hits_as_int Indicates whether `hits.total` should be rendered as an integer or an object in the rest search response. + # @option args [Enumerable, String] :routing Comma-separated list of specific routing values. + # @option args [String] :scroll Specify how long a consistent view of the index should be maintained for scrolled search. + # @option args [String] :search_type Search operation type. + # @option args [Boolean] :seq_no_primary_term Specify whether to return sequence number and primary term of the last modification of each hit. + # @option args [Integer] :size Number of hits to return. + # @option args [Enumerable] :sort Comma-separated list of : pairs. + # @option args [Enumerable] :stats Specific 'tag' of the request for logging and statistical purposes. + # @option args [Enumerable] :stored_fields Comma-separated list of stored fields to return. + # @option args [String] :suggest_field Specify which field to use for suggestions. + # @option args [String] :suggest_mode Specify suggest mode. + # @option args [Integer] :suggest_size How many suggestions to return in response. + # @option args [String] :suggest_text The source text for which the suggestions should be returned. + # @option args [Integer] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + # @option args [String] :timeout Operation timeout. + # @option args [Boolean] :track_scores Whether to calculate and return scores even if they are not used for sorting. + # @option args [Boolean] :track_total_hits Indicate if the number of documents that match the query should be tracked. + # @option args [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response. + # @option args [Boolean] :version Whether to return document version as part of a hit. + # @option args [Hash] :body + def search_models(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = '_plugins/_knn/models/_search' + + Utils.validate_query_params args, SEARCH_MODELS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + SEARCH_MODELS_QUERY_PARAMS = Set.new(%w[ + _source + _source_excludes + _source_includes + allow_no_indices + allow_partial_search_results + analyze_wildcard + analyzer + batched_reduce_size + ccs_minimize_roundtrips + default_operator + df + docvalue_fields + expand_wildcards + explain + from + ignore_throttled + ignore_unavailable + lenient + max_concurrent_shard_requests + pre_filter_shard_size + preference + q + request_cache + rest_total_hits_as_int + routing + scroll + search_type + seq_no_primary_term + size + sort + stats + stored_fields + suggest_field + suggest_mode + suggest_size + suggest_text + terminate_after + timeout + track_scores + track_total_hits + typed_keys + version + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/knn/stats.rb b/lib/opensearch/api/actions/knn/stats.rb new file mode 100644 index 000000000..a27fe5f3a --- /dev/null +++ b/lib/opensearch/api/actions/knn/stats.rb @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Knn + module Actions + # Provides information about the current status of the k-NN plugin. + # + # @option args [Enumerable] :node_id Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes. + # @option args [String] :timeout Operation timeout. + # @option args [Enumerable] :stat Comma-separated list of stats to retrieve; use `_all` or empty string to retrieve all stats. + def stats(args = {}) + args = Utils.normalize_arguments(args) + _node_id = args.delete('node_id') + _stat = args.delete('stat') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_knn', _node_id, 'stats', _stat].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, STATS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + STATS_QUERY_PARAMS = Set.new(%w[ + timeout + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/knn/train_model.rb b/lib/opensearch/api/actions/knn/train_model.rb new file mode 100644 index 000000000..4d78a9acb --- /dev/null +++ b/lib/opensearch/api/actions/knn/train_model.rb @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Knn + module Actions + # Create and train a model that can be used for initializing k-NN native library indexes during indexing. + # + # @option args [String] :preference Preferred node to execute training. + # @option args [String] :model_id The id of the model. + # @option args [Hash] :body + def train_model(args = {}) + args = Utils.normalize_arguments(args) + _model_id = args.delete('model_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_knn/models', _model_id, '_train'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, TRAIN_MODEL_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + TRAIN_MODEL_QUERY_PARAMS = Set.new(%w[ + preference + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/knn/warmup.rb b/lib/opensearch/api/actions/knn/warmup.rb new file mode 100644 index 000000000..47e807124 --- /dev/null +++ b/lib/opensearch/api/actions/knn/warmup.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Knn + module Actions + # Preloads native library files into memory, reducing initial search latency for specified indexes. + # + # @option args [Enumerable] :index *Required* Comma-separated list of indexes; use `_all` or empty string to perform the operation on all indexes. + def warmup(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_knn/warmup', _index].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/list/help.rb b/lib/opensearch/api/actions/list/help.rb new file mode 100644 index 000000000..39daf1ffa --- /dev/null +++ b/lib/opensearch/api/actions/list/help.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module List + module Actions + # Returns help for the List APIs. + # + def help(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_list' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/list/indices.rb b/lib/opensearch/api/actions/list/indices.rb new file mode 100644 index 000000000..3021ee76f --- /dev/null +++ b/lib/opensearch/api/actions/list/indices.rb @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module List + module Actions + # Returns paginated information about indexes including number of primaries and replicas, document counts, disk size. + # + # @option args [String] :bytes The unit used to display byte values. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Enumerable, String] :expand_wildcards The type of index that wildcard patterns can match. + # @option args [String] :format A short version of the Accept header, such as `JSON`, `YAML`. + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [String] :health The health status used to limit returned indexes. By default, the response includes indexes of any health status. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :include_unloaded_segments If `true`, the response includes information from segments that are not loaded into memory. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Hash] :next_token Token to retrieve next page of indexes. + # @option args [Boolean] :pri If `true`, the response only includes information from primary shards. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Integer] :size Maximum number of indexes to be displayed in a page. + # @option args [String] :sort Defines order in which indexes will be displayed. Accepted values are `asc` and `desc`. If `desc`, most recently created indexes would be displayed first. + # @option args [String] :time The unit used to display time values. + # @option args [Boolean] :v Verbose mode. Display column headers. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + def indices(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_list/indices', _index].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, INDICES_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + INDICES_QUERY_PARAMS = Set.new(%w[ + bytes + cluster_manager_timeout + expand_wildcards + format + h + health + help + include_unloaded_segments + local + master_timeout + next_token + pri + s + size + sort + time + v + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/list/shards.rb b/lib/opensearch/api/actions/list/shards.rb new file mode 100644 index 000000000..34dfbcb37 --- /dev/null +++ b/lib/opensearch/api/actions/list/shards.rb @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module List + module Actions + # Returns paginated details of shard allocation on nodes. + # + # @option args [String] :bytes The unit used to display byte values. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :format A short version of the Accept header, such as `JSON`, `YAML`. + # @option args [Enumerable] :h Comma-separated list of column names to display. + # @option args [Boolean] :help Return help information. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Operation timeout for connection to cluster-manager node. + # @option args [Hash] :next_token Token to retrieve next page of shards. + # @option args [Enumerable] :s Comma-separated list of column names or column aliases to sort by. + # @option args [Integer] :size Maximum number of shards to be displayed in a page. + # @option args [String] :sort Defines order in which shards will be displayed. Accepted values are `asc` and `desc`. If `desc`, most recently created shards would be displayed first. + # @option args [String] :time The unit in which to display time values. + # @option args [Boolean] :v Verbose mode. Display column headers. + # @option args [Enumerable, String] :index A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + def shards(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_list/shards', _index].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, SHARDS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + SHARDS_QUERY_PARAMS = Set.new(%w[ + bytes + cluster_manager_timeout + format + h + help + local + master_timeout + next_token + s + size + sort + time + v + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/mget.rb b/lib/opensearch/api/actions/mget.rb index 6aca51dc1..3868ca76b 100644 --- a/lib/opensearch/api/actions/mget.rb +++ b/lib/opensearch/api/actions/mget.rb @@ -3,84 +3,54 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Allows to get multiple documents in one request. - # - # @option arguments [String] :index The name of the index - # @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response - # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) - # @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode - # @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation - # @option arguments [String] :routing Specific routing value - # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return - # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field - # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Document identifiers; can be either `docs` (containing full document information) or `ids` (when index is provided in the URL. (*Required*) - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def mget(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + module Root + module Actions + # Allows to get multiple documents in one request. + # + # @option args [Boolean, Enumerable, String] :_source Set to `true` or `false` to return the `_source` field or not, or a list of fields to return. + # @option args [Enumerable, String] :_source_excludes A comma-separated list of source fields to exclude from the response. You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter. + # @option args [Enumerable, String] :_source_includes A comma-separated list of source fields to include in the response. If this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the `_source_excludes` query parameter. If the `_source` parameter is `false`, this parameter is ignored. + # @option args [String] :preference Specifies the node or shard the operation should be performed on. Random by default. + # @option args [Boolean] :realtime If `true`, the request is real-time as opposed to near-real-time. + # @option args [Boolean, String] :refresh If `true`, the request refreshes relevant shards before retrieving documents. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [Enumerable, String] :stored_fields If `true`, retrieves the document fields stored in the index rather than the document `_source`. + # @option args [String] :index Name of the index to retrieve documents from when `ids` are specified, or when a document in the `docs` array does not specify an index. + # @option args [Hash] :body *Required* Document identifiers; can be either `docs` (containing full document information) or `ids` (when index is provided in the URL. + def mget(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - headers = arguments.delete(:headers) || {} + _index = args.delete('index') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = [_index, '_mget'].filter(&:present?).join('/').squeeze('/') - _index = arguments.delete(:index) + Utils.validate_query_params args, MGET_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - method = OpenSearch::API::HTTP_POST - path = if _index - "#{Utils.__listify(_index)}/_mget" - else - '_mget' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + MGET_QUERY_PARAMS = Set.new(%w[ + _source + _source_excludes + _source_includes + preference + realtime + refresh + routing + stored_fields + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:mget, %i[ - stored_fields - preference - realtime - refresh - routing - _source - _source_excludes - _source_includes - ].freeze) end end end diff --git a/lib/opensearch/api/actions/ml/create_connector.rb b/lib/opensearch/api/actions/ml/create_connector.rb new file mode 100644 index 000000000..b3134a8cf --- /dev/null +++ b/lib/opensearch/api/actions/ml/create_connector.rb @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ml + module Actions + # Creates a standalone connector. + # + # @option args [Hash] :body + def create_connector(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_ml/connectors/_create' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ml/delete_agent.rb b/lib/opensearch/api/actions/ml/delete_agent.rb new file mode 100644 index 000000000..a91b2e7ef --- /dev/null +++ b/lib/opensearch/api/actions/ml/delete_agent.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ml + module Actions + # Delete an agent. + # + # @option args [String] :agent_id *Required* + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_agent(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'agent_id' missing" unless args['agent_id'] + + _agent_id = args.delete('agent_id') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_ml/agents', _agent_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ml/delete_connector.rb b/lib/opensearch/api/actions/ml/delete_connector.rb new file mode 100644 index 000000000..a53a96d08 --- /dev/null +++ b/lib/opensearch/api/actions/ml/delete_connector.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ml + module Actions + # Deletes a standalone connector. + # + # @option args [String] :connector_id *Required* + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_connector(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'connector_id' missing" unless args['connector_id'] + + _connector_id = args.delete('connector_id') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_ml/connectors', _connector_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ml/delete_model.rb b/lib/opensearch/api/actions/ml/delete_model.rb new file mode 100644 index 000000000..f0e9a4f5a --- /dev/null +++ b/lib/opensearch/api/actions/ml/delete_model.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ml + module Actions + # Deletes a model. + # + # @option args [String] :model_id *Required* + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_model(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'model_id' missing" unless args['model_id'] + + _model_id = args.delete('model_id') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_ml/models', _model_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ml/delete_model_group.rb b/lib/opensearch/api/actions/ml/delete_model_group.rb new file mode 100644 index 000000000..e2df59500 --- /dev/null +++ b/lib/opensearch/api/actions/ml/delete_model_group.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ml + module Actions + # Deletes a model group. + # + # @option args [String] :model_group_id *Required* + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_model_group(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'model_group_id' missing" unless args['model_group_id'] + + _model_group_id = args.delete('model_group_id') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_ml/model_groups', _model_group_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ml/delete_task.rb b/lib/opensearch/api/actions/ml/delete_task.rb new file mode 100644 index 000000000..7f17fb5e6 --- /dev/null +++ b/lib/opensearch/api/actions/ml/delete_task.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ml + module Actions + # Deletes a task. + # + # @option args [String] :task_id *Required* + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_task(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'task_id' missing" unless args['task_id'] + + _task_id = args.delete('task_id') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_ml/tasks', _task_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ml/deploy_model.rb b/lib/opensearch/api/actions/ml/deploy_model.rb new file mode 100644 index 000000000..0eb6efa0b --- /dev/null +++ b/lib/opensearch/api/actions/ml/deploy_model.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ml + module Actions + # Deploys a model. + # + # @option args [String] :model_id *Required* + def deploy_model(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'model_id' missing" unless args['model_id'] + + _model_id = args.delete('model_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_ml/models', _model_id, '_deploy'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ml/get_model_group.rb b/lib/opensearch/api/actions/ml/get_model_group.rb new file mode 100644 index 000000000..7790dd648 --- /dev/null +++ b/lib/opensearch/api/actions/ml/get_model_group.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ml + module Actions + # Retrieves a model group. + # + # @option args [String] :model_group_id *Required* + def get_model_group(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'model_group_id' missing" unless args['model_group_id'] + + _model_group_id = args.delete('model_group_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_ml/model_groups', _model_group_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ml/get_task.rb b/lib/opensearch/api/actions/ml/get_task.rb new file mode 100644 index 000000000..5b8a722a4 --- /dev/null +++ b/lib/opensearch/api/actions/ml/get_task.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ml + module Actions + # Retrieves a task. + # + # @option args [String] :task_id *Required* + def get_task(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'task_id' missing" unless args['task_id'] + + _task_id = args.delete('task_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_ml/tasks', _task_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ml/register_agents.rb b/lib/opensearch/api/actions/ml/register_agents.rb new file mode 100644 index 000000000..4e2cb92cd --- /dev/null +++ b/lib/opensearch/api/actions/ml/register_agents.rb @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ml + module Actions + # Register an agent. + # + # @option args [Hash] :body + def register_agents(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_ml/agents/_register' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ml/register_model.rb b/lib/opensearch/api/actions/ml/register_model.rb new file mode 100644 index 000000000..db71b3596 --- /dev/null +++ b/lib/opensearch/api/actions/ml/register_model.rb @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ml + module Actions + # Registers a model. + # + # @option args [Hash] :body + def register_model(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_ml/models/_register' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ml/register_model_group.rb b/lib/opensearch/api/actions/ml/register_model_group.rb new file mode 100644 index 000000000..9436202b0 --- /dev/null +++ b/lib/opensearch/api/actions/ml/register_model_group.rb @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ml + module Actions + # Registers a model group. + # + # @option args [Hash] :body + def register_model_group(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_ml/model_groups/_register' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ml/search_models.rb b/lib/opensearch/api/actions/ml/search_models.rb new file mode 100644 index 000000000..f4a8e4e61 --- /dev/null +++ b/lib/opensearch/api/actions/ml/search_models.rb @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ml + module Actions + # Searches for models. + # + # @option args [Hash] :body + def search_models(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_ml/models/_search' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/ml/undeploy_model.rb b/lib/opensearch/api/actions/ml/undeploy_model.rb new file mode 100644 index 000000000..12f1fa17f --- /dev/null +++ b/lib/opensearch/api/actions/ml/undeploy_model.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ml + module Actions + # Undeploys a model. + # + # @option args [String] :model_id *Required* + def undeploy_model(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'model_id' missing" unless args['model_id'] + + _model_id = args.delete('model_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_ml/models', _model_id, '_undeploy'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/msearch.rb b/lib/opensearch/api/actions/msearch.rb index 56eb94058..e3d83522c 100644 --- a/lib/opensearch/api/actions/msearch.rb +++ b/lib/opensearch/api/actions/msearch.rb @@ -3,103 +3,52 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Actions - # Allows to execute several search operations in one request. - # - # @option arguments [List] :index A comma-separated list of index names to use as default - # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) - # @option arguments [Number] :max_concurrent_searches Controls the maximum number of concurrent searches the multi search api will execute - # @option arguments [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response - # @option arguments [Number] :pre_filter_shard_size A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. - # @option arguments [Number] :max_concurrent_shard_requests The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests - # @option arguments [Boolean] :rest_total_hits_as_int Indicates whether hits.total should be rendered as an integer or an object in the rest search response - # @option arguments [Boolean] :ccs_minimize_roundtrips Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The request definitions (metadata-search request definition pairs), separated by newlines (*Required*) - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def msearch(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_POST - path = if _index - "#{Utils.__listify(_index)}/_msearch" - else - '_msearch' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - if body.is_a?(Array) && body.any? { |d| d.key? :search } - payload = body - .each_with_object([]) do |item, sum| - meta = item - data = meta.delete(:search) - - sum << meta - sum << data - end - payload = payload.map { |item| OpenSearch::API.serializer.dump(item) } - payload << '' unless payload.empty? - payload = payload.join("\n") - elsif body.is_a?(Array) - payload = body.map { |d| d.is_a?(String) ? d : OpenSearch::API.serializer.dump(d) } - payload << '' unless payload.empty? - payload = payload.join("\n") - else - payload = body +module OpenSearch + module API + module Root + module Actions + # Allows to execute several search operations in one request. + # + # @option args [Boolean] :ccs_minimize_roundtrips If `true`, network round-trips between the coordinating node and remote clusters are minimized for cross-cluster search requests. + # @option args [Integer] :max_concurrent_searches Maximum number of concurrent searches the multi search API can execute. + # @option args [Integer] :max_concurrent_shard_requests Maximum number of concurrent shard requests that each sub-search request executes per node. + # @option args [Integer] :pre_filter_shard_size Defines a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method i.e., if date filters are mandatory to match but the shard bounds and the query are disjoint. + # @option args [Boolean] :rest_total_hits_as_int If `true`, `hits.total` are returned as an integer in the response. Defaults to false, which returns an object. + # @option args [String] :search_type Indicates whether global term and document frequencies should be used when scoring returned documents. + # @option args [Boolean] :typed_keys Specifies whether aggregation and suggester names should be prefixed by their respective types in the response. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and index aliases to search. + # @option args [Enumerable] :body *Required* The request definitions (metadata-search request definition pairs), separated by newlines + def msearch(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _index = args.delete('index') + + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = body ? 'POST' : 'GET' + url = [_index, '_msearch'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, MSEARCH_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - headers.merge!('Content-Type' => 'application/x-ndjson') - perform_request(method, path, params, payload, headers).body + MSEARCH_QUERY_PARAMS = Set.new(%w[ + ccs_minimize_roundtrips + max_concurrent_searches + max_concurrent_shard_requests + pre_filter_shard_size + rest_total_hits_as_int + search_type + typed_keys + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:msearch, %i[ - search_type - max_concurrent_searches - typed_keys - pre_filter_shard_size - max_concurrent_shard_requests - rest_total_hits_as_int - ccs_minimize_roundtrips - ].freeze) end end end diff --git a/lib/opensearch/api/actions/msearch_template.rb b/lib/opensearch/api/actions/msearch_template.rb index c00b2d5b6..8d66d038b 100644 --- a/lib/opensearch/api/actions/msearch_template.rb +++ b/lib/opensearch/api/actions/msearch_template.rb @@ -3,87 +3,48 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Actions - # Allows to execute several search template operations in one request. - # - # @option arguments [List] :index A comma-separated list of index names to use as default - # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) - # @option arguments [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response - # @option arguments [Number] :max_concurrent_searches Controls the maximum number of concurrent searches the multi search api will execute - # @option arguments [Boolean] :rest_total_hits_as_int Indicates whether hits.total should be rendered as an integer or an object in the rest search response - # @option arguments [Boolean] :ccs_minimize_roundtrips Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The request definitions (metadata-search request definition pairs), separated by newlines (*Required*) - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def msearch_template(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - _index = arguments.delete(:index) +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - method = OpenSearch::API::HTTP_POST - path = if _index - "#{Utils.__listify(_index)}/_msearch/template" - else - '_msearch/template' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) +# frozen_string_literal: true - body = arguments[:body] - if body.is_a?(Array) - payload = body.map { |d| d.is_a?(String) ? d : OpenSearch::API.serializer.dump(d) } - payload << '' unless payload.empty? - payload = payload.join("\n") - else - payload = body +module OpenSearch + module API + module Root + module Actions + # Allows to execute several search template operations in one request. + # + # @option args [Boolean] :ccs_minimize_roundtrips If `true`, network round-trips are minimized for cross-cluster search requests. + # @option args [Integer] :max_concurrent_searches Maximum number of concurrent searches the API can run. + # @option args [Boolean] :rest_total_hits_as_int If `true`, the response returns `hits.total` as an integer. If `false`, it returns `hits.total` as an object. + # @option args [String] :search_type The type of the search operation. Available options: `query_then_fetch`, `dfs_query_then_fetch`. + # @option args [Boolean] :typed_keys If `true`, the response prefixes aggregation and suggester names with their respective types. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams and indexes, omit this parameter or use `*`. + # @option args [Enumerable] :body *Required* The request definitions (metadata-search request definition pairs), separated by newlines + def msearch_template(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _index = args.delete('index') + + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = body ? 'POST' : 'GET' + url = [_index, '_msearch/template'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, MSEARCH_TEMPLATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - headers.merge!('Content-Type' => 'application/x-ndjson') - perform_request(method, path, params, payload, headers).body + MSEARCH_TEMPLATE_QUERY_PARAMS = Set.new(%w[ + ccs_minimize_roundtrips + max_concurrent_searches + rest_total_hits_as_int + search_type + typed_keys + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:msearch_template, %i[ - search_type - typed_keys - max_concurrent_searches - rest_total_hits_as_int - ccs_minimize_roundtrips - ].freeze) end end end diff --git a/lib/opensearch/api/actions/mtermvectors.rb b/lib/opensearch/api/actions/mtermvectors.rb index 43149fa93..057d3678d 100644 --- a/lib/opensearch/api/actions/mtermvectors.rb +++ b/lib/opensearch/api/actions/mtermvectors.rb @@ -3,100 +3,60 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -module OpenSearch - module API - module Actions - # Returns multiple termvectors in one request. - # - # @option arguments [String] :index The index in which the document resides. - # @option arguments [List] :ids A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body - # @option arguments [Boolean] :term_statistics Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". - # @option arguments [Boolean] :field_statistics Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". - # @option arguments [List] :fields A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". - # @option arguments [Boolean] :offsets Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". - # @option arguments [Boolean] :positions Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". - # @option arguments [Boolean] :payloads Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". - # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". - # @option arguments [String] :routing Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs". - # @option arguments [Boolean] :realtime Specifies if requests are real-time as opposed to near-real-time (default: true). - # @option arguments [Number] :version Explicit version number for concurrency control - # @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation. - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def mtermvectors(arguments = {}) - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone - ids = arguments.delete(:ids) +# frozen_string_literal: true - _index = arguments.delete(:index) +module OpenSearch + module API + module Root + module Actions + # Returns multiple termvectors in one request. + # + # @option args [Boolean] :field_statistics If `true`, the response includes the document count, sum of document frequencies, and sum of total term frequencies. + # @option args [Enumerable, String] :fields Comma-separated list or wildcard expressions of fields to include in the statistics. Used as the default list unless a specific field list is provided in the `completion_fields` or `fielddata_fields` parameters. + # @option args [Enumerable] :ids A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body + # @option args [Boolean] :offsets If `true`, the response includes term offsets. + # @option args [Boolean] :payloads If `true`, the response includes term payloads. + # @option args [Boolean] :positions If `true`, the response includes term positions. + # @option args [String] :preference Specifies the node or shard the operation should be performed on. Random by default. + # @option args [Boolean] :realtime If `true`, the request is real-time as opposed to near-real-time. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [Boolean] :term_statistics If `true`, the response includes term frequency and document frequency. + # @option args [Integer] :version If `true`, returns the document version as part of a hit. + # @option args [String] :version_type Specific version type. + # @option args [String] :index Name of the index that contains the documents. + # @option args [Hash] :body Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation. + def mtermvectors(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - method = if arguments[:body] - OpenSearch::API::HTTP_POST - else - OpenSearch::API::HTTP_GET - end + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = [_index, '_mtermvectors'].filter(&:present?).join('/').squeeze('/') - path = if _index - "#{Utils.__listify(_index)}/_mtermvectors" - else - '_mtermvectors' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + Utils.validate_query_params args, MTERMVECTORS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - body = if ids - { ids: ids } - else - arguments[:body] - end - perform_request(method, path, params, body, headers).body + MTERMVECTORS_QUERY_PARAMS = Set.new(%w[ + field_statistics + fields + ids + offsets + payloads + positions + preference + realtime + routing + term_statistics + version + version_type + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:mtermvectors, %i[ - ids - term_statistics - field_statistics - fields - offsets - positions - payloads - preference - routing - realtime - version - version_type - ].freeze) end end end diff --git a/lib/opensearch/api/actions/nodes/hot_threads.rb b/lib/opensearch/api/actions/nodes/hot_threads.rb index 23e11e862..d540bb236 100644 --- a/lib/opensearch/api/actions/nodes/hot_threads.rb +++ b/lib/opensearch/api/actions/nodes/hot_threads.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,51 +15,34 @@ module Nodes module Actions # Returns information about hot threads on each node in the cluster. # - # @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - # @option arguments [Time] :interval The interval for the second sampling of threads - # @option arguments [Number] :snapshots Number of samples of thread stacktrace (default: 10) - # @option arguments [Number] :threads Specify the number of threads to provide information for (default: 3) - # @option arguments [Boolean] :ignore_idle_threads Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) - # @option arguments [String] :type The type to sample (default: cpu) (options: cpu, wait, block) - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers - # - # *Deprecation notice*: - # The hot accepts /_cluster/nodes as prefix for backwards compatibility reasons - # Deprecated since version 7.0.0 - # - # - # - def hot_threads(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Enumerable] :node_id Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes. + # @option args [Boolean] :ignore_idle_threads Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue. + # @option args [String] :interval The interval for the second sampling of threads. + # @option args [Integer] :snapshots Number of samples of thread stack trace. + # @option args [Integer] :threads Specify the number of threads to provide information for. + # @option args [String] :timeout Operation timeout. + # @option args [String] :type The type to sample. + def hot_threads(args = {}) + args = Utils.normalize_arguments(args) + _node_id = args.delete('node_id') - _node_id = arguments.delete(:node_id) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_nodes', _node_id, 'hot_threads'].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_GET - path = if _node_id - "_cluster/nodes/#{Utils.__listify(_node_id)}/hot_threads" - else - '_cluster/nodes/hot_threads' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, HOT_THREADS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:hot_threads, %i[ + HOT_THREADS_QUERY_PARAMS = Set.new(%w[ + ignore_idle_threads interval snapshots threads - ignore_idle_threads - type timeout - ].freeze) + type + ]).freeze end end end diff --git a/lib/opensearch/api/actions/nodes/info.rb b/lib/opensearch/api/actions/nodes/info.rb index 3f6317247..de0240cc5 100644 --- a/lib/opensearch/api/actions/nodes/info.rb +++ b/lib/opensearch/api/actions/nodes/info.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,45 +15,30 @@ module Nodes module Actions # Returns information about nodes in the cluster. # - # @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - # @option arguments [List] :metric A comma-separated list of metrics you wish returned. Leave empty to return all. (options: settings, os, process, jvm, thread_pool, transport, http, plugins, ingest) - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def info(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Boolean] :flat_settings If `true`, returns settings in flat format. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Enumerable, Enumerable, String] :node_id_or_metric Limits the information returned to a list of node IDs or specific metrics. Supports a comma-separated list, such as `node1,node2` or `http,ingest`. + # @option args [Enumerable] :metric Limits the information returned to the specific metrics. Supports a comma-separated list, such as `http,ingest`. + # @option args [Enumerable, String] :node_id Comma-separated list of node IDs or names used to limit returned information. + def info(args = {}) + args = Utils.normalize_arguments(args) + _node_id_or_metric = args.delete('node_id_or_metric') + _metric = args.delete('metric') + _node_id = args.delete('node_id') - _node_id = arguments.delete(:node_id) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_nodes', _node_id_or_metric].filter(&:present?).join('/').squeeze('/') - _metric = arguments.delete(:metric) - - method = OpenSearch::API::HTTP_GET - path = if _node_id && _metric - "_nodes/#{Utils.__listify(_node_id)}/#{Utils.__listify(_metric)}" - elsif _node_id - "_nodes/#{Utils.__listify(_node_id)}" - elsif _metric - "_nodes/#{Utils.__listify(_metric)}" - else - '_nodes' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, INFO_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:info, %i[ + INFO_QUERY_PARAMS = Set.new(%w[ flat_settings timeout - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/nodes/params_registry.rb b/lib/opensearch/api/actions/nodes/params_registry.rb deleted file mode 100644 index cd701692d..000000000 --- a/lib/opensearch/api/actions/nodes/params_registry.rb +++ /dev/null @@ -1,69 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Nodes - module Actions - module ParamsRegistry - extend self - - # A Mapping of all the actions to their list of valid params. - # - # @since 6.1.1 - PARAMS = {} - - # Register an action with its list of valid params. - # - # @example Register the action. - # ParamsRegistry.register(:benchmark, [ :verbose ]) - # - # @param [ Symbol ] action The action to register. - # @param [ Array[Symbol] ] valid_params The list of valid params. - # - # @since 6.1.1 - def register(action, valid_params) - PARAMS[action.to_sym] = valid_params - end - - # Get the list of valid params for a given action. - # - # @example Get the list of valid params. - # ParamsRegistry.get(:benchmark) - # - # @param [ Symbol ] action The action. - # - # @return [ Array ] The list of valid params for the action. - # - # @since 6.1.1 - def get(action) - PARAMS.fetch(action, []) - end - end - end - end - end -end diff --git a/lib/opensearch/api/actions/nodes/reload_secure_settings.rb b/lib/opensearch/api/actions/nodes/reload_secure_settings.rb index 83e9809bd..57423c717 100644 --- a/lib/opensearch/api/actions/nodes/reload_secure_settings.rb +++ b/lib/opensearch/api/actions/nodes/reload_secure_settings.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,37 +15,25 @@ module Nodes module Actions # Reloads secure settings. # - # @option arguments [List] :node_id A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body An object containing the password for the opensearch keystore - # - # - def reload_secure_settings(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Enumerable, String] :node_id The names of particular nodes in the cluster to target. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Hash] :body An object containing the password for the OpenSearch keystore. + def reload_secure_settings(args = {}) + args = Utils.normalize_arguments(args) + _node_id = args.delete('node_id') - _node_id = arguments.delete(:node_id) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_nodes', _node_id, 'reload_secure_settings'].filter(&:present?).join('/').squeeze('/') - method = OpenSearch::API::HTTP_POST - path = if _node_id - "_nodes/#{Utils.__listify(_node_id)}/reload_secure_settings" - else - '_nodes/reload_secure_settings' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, RELOAD_SECURE_SETTINGS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:reload_secure_settings, [ - :timeout - ].freeze) + RELOAD_SECURE_SETTINGS_QUERY_PARAMS = Set.new(%w[ + timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/nodes/shutdown.rb b/lib/opensearch/api/actions/nodes/shutdown.rb deleted file mode 100644 index f8836aa00..000000000 --- a/lib/opensearch/api/actions/nodes/shutdown.rb +++ /dev/null @@ -1,65 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Nodes - module Actions - # Shutdown one or all nodes - # - # @example Shut down node named _Bloke_ - # - # client.nodes.shutdown node_id: 'Bloke' - # - # @option arguments [List] :node_id A comma-separated list of node IDs or names to perform the operation on; use - # `_local` to shutdown the node you're connected to, leave empty to - # shutdown all nodes - # @option arguments [Time] :delay Set the delay for the operation (default: 1s) - # @option arguments [Boolean] :exit Exit the JVM as well (default: true) - # - # @see http://opensearch.org/guide/reference/api/admin-cluster-nodes-shutdown/ - # - def shutdown(arguments = {}) - method = HTTP_POST - path = Utils.__pathify '_cluster/nodes', Utils.__listify(arguments[:node_id]), '_shutdown' - - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - body = nil - - perform_request(method, path, params, body).body - end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.1.1 - ParamsRegistry.register(:shutdown, %i[ - delay - exit - ].freeze) - end - end - end -end diff --git a/lib/opensearch/api/actions/nodes/stats.rb b/lib/opensearch/api/actions/nodes/stats.rb index 6645bc1fd..5847ca02f 100644 --- a/lib/opensearch/api/actions/nodes/stats.rb +++ b/lib/opensearch/api/actions/nodes/stats.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,66 +15,42 @@ module Nodes module Actions # Returns statistical information about nodes in the cluster. # - # @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - # @option arguments [List] :metric Limit the information returned to the specified metrics (options: _all, breaker, fs, http, indices, jvm, os, process, thread_pool, transport, discovery, indexing_pressure) - # @option arguments [List] :index_metric Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. (options: _all, completion, docs, fielddata, query_cache, flush, get, indexing, merge, request_cache, refresh, search, segments, store, warmer, suggest) - # @option arguments [List] :completion_fields A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) - # @option arguments [List] :fielddata_fields A comma-separated list of fields for `fielddata` index metric (supports wildcards) - # @option arguments [List] :fields A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) - # @option arguments [Boolean] :groups A comma-separated list of search groups for `search` index metric - # @option arguments [String] :level Return indices stats aggregated at index, node or shard level (options: indices, node, shards) - # @option arguments [List] :types A comma-separated list of document types for the `indexing` index metric - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Boolean] :include_segment_file_sizes Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) - # @option arguments [Boolean] :include_unloaded_segments If set to true segment stats will include stats for segments that are not currently loaded into memory - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def stats(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _node_id = arguments.delete(:node_id) - - _metric = arguments.delete(:metric) - - _index_metric = arguments.delete(:index_metric) - - method = OpenSearch::API::HTTP_GET - path = if _node_id && _metric && _index_metric - "_nodes/#{Utils.__listify(_node_id)}/stats/#{Utils.__listify(_metric)}/#{Utils.__listify(_index_metric)}" - elsif _metric && _index_metric - "_nodes/stats/#{Utils.__listify(_metric)}/#{Utils.__listify(_index_metric)}" - elsif _node_id && _metric - "_nodes/#{Utils.__listify(_node_id)}/stats/#{Utils.__listify(_metric)}" - elsif _node_id - "_nodes/#{Utils.__listify(_node_id)}/stats" - elsif _metric - "_nodes/stats/#{Utils.__listify(_metric)}" - else - '_nodes/stats' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + # @option args [Enumerable, String] :node_id Comma-separated list of node IDs or names used to limit returned information. + # @option args [Enumerable, String] :completion_fields Comma-separated list or wildcard expressions of fields to include in field data and suggest statistics. + # @option args [Enumerable, String] :fielddata_fields Comma-separated list or wildcard expressions of fields to include in field data statistics. + # @option args [Enumerable, String] :fields Comma-separated list or wildcard expressions of fields to include in the statistics. + # @option args [Enumerable] :groups Comma-separated list of search groups to include in the search statistics. + # @option args [Boolean] :include_segment_file_sizes If `true`, the call reports the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested). + # @option args [String] :level Indicates whether statistics are aggregated at the cluster, index, or shard level. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Enumerable] :types A comma-separated list of document types for the indexing index metric. + # @option args [Enumerable] :metric Limit the information returned to the specified metrics + # @option args [Enumerable] :index_metric Limit the information returned for indexes metric to the specific index metrics. It can be used only if indexes (or all) metric is specified. + def stats(args = {}) + args = Utils.normalize_arguments(args) + _node_id = args.delete('node_id') + _metric = args.delete('metric') + _index_metric = args.delete('index_metric') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_nodes', _node_id, 'stats', _metric, _index_metric].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, STATS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:stats, %i[ + STATS_QUERY_PARAMS = Set.new(%w[ completion_fields fielddata_fields fields groups + include_segment_file_sizes level - types timeout - include_segment_file_sizes - include_unloaded_segments - ].freeze) + types + ]).freeze end end end diff --git a/lib/opensearch/api/actions/nodes/usage.rb b/lib/opensearch/api/actions/nodes/usage.rb index 0aa00c81e..81d45478a 100644 --- a/lib/opensearch/api/actions/nodes/usage.rb +++ b/lib/opensearch/api/actions/nodes/usage.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,43 +15,26 @@ module Nodes module Actions # Returns low-level information about REST actions usage on nodes. # - # @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - # @option arguments [List] :metric Limit the information returned to the specified metrics (options: _all, rest_actions) - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def usage(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Enumerable, String] :node_id A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Enumerable] :metric Limits the information returned to the specific metrics. A comma-separated list of the following options: `_all`, `rest_actions`. + def usage(args = {}) + args = Utils.normalize_arguments(args) + _node_id = args.delete('node_id') + _metric = args.delete('metric') - _node_id = arguments.delete(:node_id) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_nodes', _node_id, 'usage', _metric].filter(&:present?).join('/').squeeze('/') - _metric = arguments.delete(:metric) - - method = OpenSearch::API::HTTP_GET - path = if _node_id && _metric - "_nodes/#{Utils.__listify(_node_id)}/usage/#{Utils.__listify(_metric)}" - elsif _node_id - "_nodes/#{Utils.__listify(_node_id)}/usage" - elsif _metric - "_nodes/usage/#{Utils.__listify(_metric)}" - else - '_nodes/usage' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, USAGE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:usage, [ - :timeout - ].freeze) + USAGE_QUERY_PARAMS = Set.new(%w[ + timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/notifications/create_config.rb b/lib/opensearch/api/actions/notifications/create_config.rb new file mode 100644 index 000000000..e24a1c8ae --- /dev/null +++ b/lib/opensearch/api/actions/notifications/create_config.rb @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Notifications + module Actions + # Create channel configuration. + # + # @option args [Hash] :body *Required* + def create_config(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_notifications/configs' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/notifications/delete_config.rb b/lib/opensearch/api/actions/notifications/delete_config.rb new file mode 100644 index 000000000..d7190d229 --- /dev/null +++ b/lib/opensearch/api/actions/notifications/delete_config.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Notifications + module Actions + # Delete a channel configuration. + # + # @option args [String] :config_id *Required* The ID of the channel configuration to delete. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_config(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'config_id' missing" unless args['config_id'] + + _config_id = args.delete('config_id') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_notifications/configs', _config_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/notifications/delete_configs.rb b/lib/opensearch/api/actions/notifications/delete_configs.rb new file mode 100644 index 000000000..6cd7244b2 --- /dev/null +++ b/lib/opensearch/api/actions/notifications/delete_configs.rb @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Notifications + module Actions + # Delete multiple channel configurations. + # + # @option args [String] :config_id *Required* The ID of the channel configuration to delete. + # @option args [String] :config_id_list A comma-separated list of channel IDs to delete. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_configs(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'config_id' missing" unless args['config_id'] + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = '_plugins/_notifications/configs' + + Utils.validate_query_params args, DELETE_CONFIGS_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + + DELETE_CONFIGS_QUERY_PARAMS = Set.new(%w[ + config_id + config_id_list + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/notifications/get_config.rb b/lib/opensearch/api/actions/notifications/get_config.rb new file mode 100644 index 000000000..046cbf384 --- /dev/null +++ b/lib/opensearch/api/actions/notifications/get_config.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Notifications + module Actions + # Get a specific channel configuration. + # + # @option args [String] :config_id *Required* + def get_config(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'config_id' missing" unless args['config_id'] + + _config_id = args.delete('config_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_notifications/configs', _config_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/notifications/get_configs.rb b/lib/opensearch/api/actions/notifications/get_configs.rb new file mode 100644 index 000000000..9fd70ee3b --- /dev/null +++ b/lib/opensearch/api/actions/notifications/get_configs.rb @@ -0,0 +1,115 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Notifications + module Actions + # Get multiple channel configurations with filtering. + # + # @option args [String] :chime.url + # @option args [String] :chime.url.keyword + # @option args [String] :config_id Notification configuration ID. + # @option args [Enumerable] :config_id_list Notification configuration IDs. + # @option args [String] :config_type Type of notification configuration. + # @option args [Integer] :created_time_ms + # @option args [String] :description + # @option args [String] :description.keyword + # @option args [String] :email.email_account_id + # @option args [String] :email.email_group_id_list + # @option args [String] :email.recipient_list.recipient + # @option args [String] :email.recipient_list.recipient.keyword + # @option args [String] :email_group.recipient_list.recipient + # @option args [String] :email_group.recipient_list.recipient.keyword + # @option args [Boolean] :is_enabled + # @option args [Integer] :last_updated_time_ms + # @option args [String] :microsoft_teams.url + # @option args [String] :microsoft_teams.url.keyword + # @option args [String] :name + # @option args [String] :name.keyword + # @option args [String] :query + # @option args [String] :ses_account.from_address + # @option args [String] :ses_account.from_address.keyword + # @option args [String] :ses_account.region + # @option args [String] :ses_account.role_arn + # @option args [String] :ses_account.role_arn.keyword + # @option args [String] :slack.url + # @option args [String] :slack.url.keyword + # @option args [String] :smtp_account.from_address + # @option args [String] :smtp_account.from_address.keyword + # @option args [String] :smtp_account.host + # @option args [String] :smtp_account.host.keyword + # @option args [String] :smtp_account.method + # @option args [String] :sns.role_arn + # @option args [String] :sns.role_arn.keyword + # @option args [String] :sns.topic_arn + # @option args [String] :sns.topic_arn.keyword + # @option args [String] :text_query + # @option args [String] :webhook.url + # @option args [String] :webhook.url.keyword + # @option args [Hash] :body + def get_configs(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_notifications/configs' + + Utils.validate_query_params args, GET_CONFIGS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + GET_CONFIGS_QUERY_PARAMS = Set.new(%w[ + chime.url + chime.url.keyword + config_id + config_id_list + config_type + created_time_ms + description + description.keyword + email.email_account_id + email.email_group_id_list + email.recipient_list.recipient + email.recipient_list.recipient.keyword + email_group.recipient_list.recipient + email_group.recipient_list.recipient.keyword + is_enabled + last_updated_time_ms + microsoft_teams.url + microsoft_teams.url.keyword + name + name.keyword + query + ses_account.from_address + ses_account.from_address.keyword + ses_account.region + ses_account.role_arn + ses_account.role_arn.keyword + slack.url + slack.url.keyword + smtp_account.from_address + smtp_account.from_address.keyword + smtp_account.host + smtp_account.host.keyword + smtp_account.method + sns.role_arn + sns.role_arn.keyword + sns.topic_arn + sns.topic_arn.keyword + text_query + webhook.url + webhook.url.keyword + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/notifications/list_channels.rb b/lib/opensearch/api/actions/notifications/list_channels.rb new file mode 100644 index 000000000..ecff3a4d3 --- /dev/null +++ b/lib/opensearch/api/actions/notifications/list_channels.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Notifications + module Actions + # List created notification channels. + # + def list_channels(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_notifications/channels' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/notifications/list_features.rb b/lib/opensearch/api/actions/notifications/list_features.rb new file mode 100644 index 000000000..8c5b7c6ed --- /dev/null +++ b/lib/opensearch/api/actions/notifications/list_features.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Notifications + module Actions + # List supported channel configurations. + # + def list_features(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_notifications/features' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/notifications/send_test.rb b/lib/opensearch/api/actions/notifications/send_test.rb new file mode 100644 index 000000000..686b39902 --- /dev/null +++ b/lib/opensearch/api/actions/notifications/send_test.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Notifications + module Actions + # Send a test notification. + # + # @option args [String] :config_id *Required* + def send_test(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'config_id' missing" unless args['config_id'] + + _config_id = args.delete('config_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = ['_plugins/_notifications/feature/test', _config_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/notifications/update_config.rb b/lib/opensearch/api/actions/notifications/update_config.rb new file mode 100644 index 000000000..0ed1b027e --- /dev/null +++ b/lib/opensearch/api/actions/notifications/update_config.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Notifications + module Actions + # Update channel configuration. + # + # @option args [String] :config_id *Required* + # @option args [Hash] :body *Required* + def update_config(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'config_id' missing" unless args['config_id'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _config_id = args.delete('config_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_notifications/configs', _config_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/observability/create_object.rb b/lib/opensearch/api/actions/observability/create_object.rb new file mode 100644 index 000000000..020e19a38 --- /dev/null +++ b/lib/opensearch/api/actions/observability/create_object.rb @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Observability + module Actions + # Creates a new observability object. + # + # @option args [Hash] :body + def create_object(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_observability/object' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/observability/delete_object.rb b/lib/opensearch/api/actions/observability/delete_object.rb new file mode 100644 index 000000000..6b82d0dc8 --- /dev/null +++ b/lib/opensearch/api/actions/observability/delete_object.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Observability + module Actions + # Deletes specific observability object specified by ID. + # + # @option args [String] :object_id *Required* The ID of the Observability Object. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_object(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'object_id' missing" unless args['object_id'] + + _object_id = args.delete('object_id') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_observability/object', _object_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/observability/delete_objects.rb b/lib/opensearch/api/actions/observability/delete_objects.rb new file mode 100644 index 000000000..28775e562 --- /dev/null +++ b/lib/opensearch/api/actions/observability/delete_objects.rb @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Observability + module Actions + # Deletes specific observability objects specified by ID or a list of IDs. + # + # @option args [String] :objectId The ID of a single Observability Object to delete. + # @option args [String] :objectIdList A comma-separated list of Observability Object IDs to delete. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_objects(args = {}) + args = Utils.normalize_arguments(args) + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = '_plugins/_observability/object' + + Utils.validate_query_params args, DELETE_OBJECTS_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + + DELETE_OBJECTS_QUERY_PARAMS = Set.new(%w[ + objectId + objectIdList + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/observability/get_localstats.rb b/lib/opensearch/api/actions/observability/get_localstats.rb new file mode 100644 index 000000000..fc51fbb6b --- /dev/null +++ b/lib/opensearch/api/actions/observability/get_localstats.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Observability + module Actions + # Retrieves local stats of all observability objects. + # + def get_localstats(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_observability/_local/stats' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/observability/get_object.rb b/lib/opensearch/api/actions/observability/get_object.rb new file mode 100644 index 000000000..32c80fe29 --- /dev/null +++ b/lib/opensearch/api/actions/observability/get_object.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Observability + module Actions + # Retrieves specific observability object specified by ID. + # + # @option args [String] :object_id *Required* The ID of the Observability Object. + def get_object(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'object_id' missing" unless args['object_id'] + + _object_id = args.delete('object_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_observability/object', _object_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/observability/list_objects.rb b/lib/opensearch/api/actions/observability/list_objects.rb new file mode 100644 index 000000000..254de715f --- /dev/null +++ b/lib/opensearch/api/actions/observability/list_objects.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Observability + module Actions + # Retrieves list of all observability objects. + # + def list_objects(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_observability/object' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/observability/update_object.rb b/lib/opensearch/api/actions/observability/update_object.rb new file mode 100644 index 000000000..86dc04fe2 --- /dev/null +++ b/lib/opensearch/api/actions/observability/update_object.rb @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Observability + module Actions + # Updates an existing observability object. + # + # @option args [String] :object_id *Required* The ID of the Observability Object. + # @option args [Hash] :body + def update_object(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'object_id' missing" unless args['object_id'] + + _object_id = args.delete('object_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_observability/object', _object_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/params_registry.rb b/lib/opensearch/api/actions/params_registry.rb deleted file mode 100644 index 357a29f39..000000000 --- a/lib/opensearch/api/actions/params_registry.rb +++ /dev/null @@ -1,67 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Actions - module ParamsRegistry - extend self - - # A Mapping of all the actions to their list of valid params. - # - # @since 6.1.1 - PARAMS = {} - - # Register an action with its list of valid params. - # - # @example Register the action. - # ParamsRegistry.register(:benchmark, [ :verbose ]) - # - # @param [ Symbol ] action The action to register. - # @param [ Array[Symbol] ] valid_params The list of valid params. - # - # @since 6.1.1 - def register(action, valid_params) - PARAMS[action.to_sym] = valid_params - end - - # Get the list of valid params for a given action. - # - # @example Get the list of valid params. - # ParamsRegistry.get(:benchmark) - # - # @param [ Symbol ] action The action. - # - # @return [ Array ] The list of valid params for the action. - # - # @since 6.1.1 - def get(action) - PARAMS.fetch(action, []) - end - end - end - end -end diff --git a/lib/opensearch/api/actions/ping.rb b/lib/opensearch/api/actions/ping.rb index a8f54acae..6d12cb73e 100644 --- a/lib/opensearch/api/actions/ping.rb +++ b/lib/opensearch/api/actions/ping.rb @@ -3,50 +3,27 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -module OpenSearch - module API - module Actions - # Returns whether the cluster is running. - # - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def ping(arguments = {}) - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - method = OpenSearch::API::HTTP_HEAD - path = '' - params = {} +module OpenSearch + module API + module Root + module Actions + # Returns whether the cluster is running. + # + def ping(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'HEAD' + url = '/' - body = nil - begin - perform_request(method, path, params, body, headers).status == 200 - rescue StandardError => e - raise e unless e.class.to_s =~ /NotFound|ConnectionFailed/ || e.message =~ /Not *Found|404|ConnectionFailed/i - false + Utils.validate_query_params args + transport.perform_ping_request method, url, args, body, headers end end end diff --git a/lib/opensearch/api/actions/ppl/explain.rb b/lib/opensearch/api/actions/ppl/explain.rb new file mode 100644 index 000000000..f471e86b7 --- /dev/null +++ b/lib/opensearch/api/actions/ppl/explain.rb @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ppl + module Actions + # Shows how a query is executed against OpenSearch. + # + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Boolean] :sanitize Specifies whether to escape special characters in the results. + # @option args [Hash] :body *Required* + def explain(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_ppl/_explain' + + Utils.validate_query_params args, EXPLAIN_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + EXPLAIN_QUERY_PARAMS = Set.new(%w[ + format + sanitize + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/ppl/get_stats.rb b/lib/opensearch/api/actions/ppl/get_stats.rb new file mode 100644 index 000000000..de58fa6c2 --- /dev/null +++ b/lib/opensearch/api/actions/ppl/get_stats.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ppl + module Actions + # Collect metrics for the plugin within the interval. + # + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Boolean] :sanitize Specifies whether to escape special characters in the results. + def get_stats(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_ppl/stats' + + Utils.validate_query_params args, GET_STATS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + GET_STATS_QUERY_PARAMS = Set.new(%w[ + format + sanitize + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/ppl/post_stats.rb b/lib/opensearch/api/actions/ppl/post_stats.rb new file mode 100644 index 000000000..b94c75581 --- /dev/null +++ b/lib/opensearch/api/actions/ppl/post_stats.rb @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ppl + module Actions + # By a stats endpoint, you are able to collect metrics for the plugin within the interval. + # + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Boolean] :sanitize Specifies whether to escape special characters in the results. + # @option args [Hash] :body *Required* + def post_stats(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_ppl/stats' + + Utils.validate_query_params args, POST_STATS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + POST_STATS_QUERY_PARAMS = Set.new(%w[ + format + sanitize + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/ppl/query.rb b/lib/opensearch/api/actions/ppl/query.rb new file mode 100644 index 000000000..a34ce3568 --- /dev/null +++ b/lib/opensearch/api/actions/ppl/query.rb @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Ppl + module Actions + # Send a PPL query to the PPL plugin. + # + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Boolean] :sanitize Specifies whether to escape special characters in the results. + # @option args [Hash] :body *Required* + def query(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_ppl' + + Utils.validate_query_params args, QUERY_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + QUERY_QUERY_PARAMS = Set.new(%w[ + format + sanitize + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/put_script.rb b/lib/opensearch/api/actions/put_script.rb index eb48bf5f2..328c199c4 100644 --- a/lib/opensearch/api/actions/put_script.rb +++ b/lib/opensearch/api/actions/put_script.rb @@ -3,74 +3,47 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Actions - # Creates or updates a script. - # - # @option arguments [String] :id Script ID - # @option arguments [String] :context Script context - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Specify timeout for connection to master - # @option arguments [Time] :cluster_manager_timeout Specify timeout for connection to cluster_manager - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The document (*Required*) - # - # - def put_script(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - _id = arguments.delete(:id) - - _context = arguments.delete(:context) - - method = OpenSearch::API::HTTP_PUT - path = if _id && _context - "_scripts/#{Utils.__listify(_id)}/#{Utils.__listify(_context)}" - else - "_scripts/#{Utils.__listify(_id)}" - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body +module OpenSearch + module API + module Root + module Actions + # Creates or updates a script. + # + # @option args [String] :id *Required* Identifier for the stored script or search template. Must be unique within the cluster. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :context Context in which the script or search template should run. To prevent errors, the API immediately compiles the script or template in this context. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Hash] :body *Required* The document + def put_script(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _id = args.delete('id') + _context = args.delete('context') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = _context.present? ? 'PUT' : 'POST' + url = ['_scripts', _id, _context].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, PUT_SCRIPT_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + PUT_SCRIPT_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout + master_timeout + timeout + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:put_script, %i[ - timeout - master_timeout - cluster_manager_timeout - context - ].freeze) end end end diff --git a/lib/opensearch/api/actions/query/datasource_delete.rb b/lib/opensearch/api/actions/query/datasource_delete.rb new file mode 100644 index 000000000..74582a1a2 --- /dev/null +++ b/lib/opensearch/api/actions/query/datasource_delete.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Query + module Actions + # Deletes specific datasource specified by name. + # + # @option args [String] :datasource_name *Required* The Name of the DataSource to delete. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def datasource_delete(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'datasource_name' missing" unless args['datasource_name'] + + _datasource_name = args.delete('datasource_name') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_query/_datasources', _datasource_name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/query/datasource_retrieve.rb b/lib/opensearch/api/actions/query/datasource_retrieve.rb new file mode 100644 index 000000000..232225e8d --- /dev/null +++ b/lib/opensearch/api/actions/query/datasource_retrieve.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Query + module Actions + # Retrieves specific datasource specified by name. + # + # @option args [String] :datasource_name *Required* The Name of the DataSource to retrieve. + def datasource_retrieve(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'datasource_name' missing" unless args['datasource_name'] + + _datasource_name = args.delete('datasource_name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_query/_datasources', _datasource_name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/query/datasources_create.rb b/lib/opensearch/api/actions/query/datasources_create.rb new file mode 100644 index 000000000..8c7a62caf --- /dev/null +++ b/lib/opensearch/api/actions/query/datasources_create.rb @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Query + module Actions + # Creates a new query datasource. + # + # @option args [Hash] :body + def datasources_create(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_query/_datasources' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/query/datasources_list.rb b/lib/opensearch/api/actions/query/datasources_list.rb new file mode 100644 index 000000000..635658276 --- /dev/null +++ b/lib/opensearch/api/actions/query/datasources_list.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Query + module Actions + # Retrieves list of all datasources. + # + def datasources_list(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_query/_datasources' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/query/datasources_update.rb b/lib/opensearch/api/actions/query/datasources_update.rb new file mode 100644 index 000000000..1a9a743a5 --- /dev/null +++ b/lib/opensearch/api/actions/query/datasources_update.rb @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Query + module Actions + # Updates an existing query datasource. + # + # @option args [Hash] :body + def datasources_update(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = '_plugins/_query/_datasources' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/rank_eval.rb b/lib/opensearch/api/actions/rank_eval.rb index d5cb91ddc..4560f681d 100644 --- a/lib/opensearch/api/actions/rank_eval.rb +++ b/lib/opensearch/api/actions/rank_eval.rb @@ -3,75 +3,46 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Allows to evaluate the quality of ranked search results over a set of typical search queries - # This functionality is Experimental and may be changed or removed - # completely in a future release. OpenSearch will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. - # - # @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. (*Required*) - # - # - def rank_eval(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + module Root + module Actions + # Allows to evaluate the quality of ranked search results over a set of typical search queries. + # + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. + # @option args [Enumerable, String] :expand_wildcards Whether to expand wildcard expression to concrete indexes that are open, closed or both. + # @option args [Boolean] :ignore_unavailable If `true`, missing or closed indexes are not included in the response. + # @option args [String] :search_type Search operation type + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and index aliases used to limit the request. Wildcard (`*`) expressions are supported. To target all data streams and indexes in a cluster, omit this parameter or use `_all` or `*`. + # @option args [Hash] :body *Required* The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. + def rank_eval(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - headers = arguments.delete(:headers) || {} + _index = args.delete('index') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = [_index, '_rank_eval'].filter(&:present?).join('/').squeeze('/') - _index = arguments.delete(:index) + Utils.validate_query_params args, RANK_EVAL_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - method = OpenSearch::API::HTTP_POST - path = if _index - "#{Utils.__listify(_index)}/_rank_eval" - else - '_rank_eval' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + RANK_EVAL_QUERY_PARAMS = Set.new(%w[ + allow_no_indices + expand_wildcards + ignore_unavailable + search_type + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:rank_eval, %i[ - ignore_unavailable - allow_no_indices - expand_wildcards - search_type - ].freeze) end end end diff --git a/lib/opensearch/api/actions/reindex.rb b/lib/opensearch/api/actions/reindex.rb index bdc4a50a0..c69054481 100644 --- a/lib/opensearch/api/actions/reindex.rb +++ b/lib/opensearch/api/actions/reindex.rb @@ -3,74 +3,53 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Allows to copy documents from one index to another, optionally filtering the source - # documents by a query, changing the destination index settings, or fetching the - # documents from a remote cluster. - # - # @option arguments [Boolean] :refresh Should the affected indexes be refreshed? - # @option arguments [Time] :timeout Time each individual bulk request should wait for shards that are unavailable. - # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - # @option arguments [Boolean] :wait_for_completion Should the request should block until the reindex is complete. - # @option arguments [Number] :requests_per_second The throttle to set on this request in sub-requests per second. -1 means no throttle. - # @option arguments [Time] :scroll Control how long to keep the search context alive - # @option arguments [Number|string] :slices The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. - # @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents) - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search definition using the Query DSL and the prototype for the index request. (*Required*) - # - # - def reindex(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + module Root + module Actions + # Allows to copy documents from one index to another, optionally filtering the source + # documents by a query, changing the destination index settings, or fetching the + # documents from a remote cluster. + # + # @option args [Integer] :max_docs Maximum number of documents to process. By default, all documents. + # @option args [Boolean, String] :refresh If `true`, the request refreshes affected shards to make this operation visible to search. + # @option args [Float] :requests_per_second The throttle for this request in sub-requests per second. Defaults to no throttle. + # @option args [String] :scroll Specifies how long a consistent view of the index should be maintained for scrolled search. + # @option args [Float, String] :slices The number of slices this task should be divided into. Defaults to 1 slice, meaning the task isn't sliced into subtasks. + # @option args [String] :timeout Period each indexing waits for automatic index creation, dynamic mapping updates, and waiting for active shards. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + # @option args [Boolean] :wait_for_completion If `true`, the request blocks until the operation is complete. + # @option args [Hash] :body *Required* The search definition using the Query DSL and the prototype for the index request. + def reindex(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - headers = arguments.delete(:headers) || {} + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_reindex' - arguments = arguments.clone + Utils.validate_query_params args, REINDEX_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - method = OpenSearch::API::HTTP_POST - path = '_reindex' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + REINDEX_QUERY_PARAMS = Set.new(%w[ + max_docs + refresh + requests_per_second + scroll + slices + timeout + wait_for_active_shards + wait_for_completion + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:reindex, %i[ - refresh - timeout - wait_for_active_shards - wait_for_completion - requests_per_second - scroll - slices - max_docs - ].freeze) end end end diff --git a/lib/opensearch/api/actions/reindex_rethrottle.rb b/lib/opensearch/api/actions/reindex_rethrottle.rb index b3977bae0..bda97d349 100644 --- a/lib/opensearch/api/actions/reindex_rethrottle.rb +++ b/lib/opensearch/api/actions/reindex_rethrottle.rb @@ -3,60 +3,39 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Changes the number of requests per second for a particular Reindex operation. - # - # @option arguments [String] :task_id The task id to rethrottle - # @option arguments [Number] :requests_per_second The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. (*Required*) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def reindex_rethrottle(arguments = {}) - raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id] + module Root + module Actions + # Changes the number of requests per second for a particular Reindex operation. + # + # @option args [String] :task_id *Required* Identifier for the task. + # @option args [Float] :requests_per_second The throttle for this request in sub-requests per second. + def reindex_rethrottle(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'task_id' missing" unless args['task_id'] - headers = arguments.delete(:headers) || {} + _task_id = args.delete('task_id') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_reindex', _task_id, '_rethrottle'].filter(&:present?).join('/').squeeze('/') - _task_id = arguments.delete(:task_id) + Utils.validate_query_params args, REINDEX_RETHROTTLE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - method = OpenSearch::API::HTTP_POST - path = "_reindex/#{Utils.__listify(_task_id)}/_rethrottle" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + REINDEX_RETHROTTLE_QUERY_PARAMS = Set.new(%w[ + requests_per_second + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:reindex_rethrottle, [ - :requests_per_second - ].freeze) end end end diff --git a/lib/opensearch/api/actions/remote/info.rb b/lib/opensearch/api/actions/remote/info.rb deleted file mode 100644 index e46a390e2..000000000 --- a/lib/opensearch/api/actions/remote/info.rb +++ /dev/null @@ -1,45 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Remote - module Actions - # Returns all of the configured remote cluster information - # - # - def info(_arguments = {}) - method = HTTP_GET - path = '_remote/info' - params = {} - body = nil - - perform_request(method, path, params, body).body - end - end - end - end -end diff --git a/lib/opensearch/api/actions/remote_store/restore.rb b/lib/opensearch/api/actions/remote_store/restore.rb index 6513d2397..e7cc4f9fd 100644 --- a/lib/opensearch/api/actions/remote_store/restore.rb +++ b/lib/opensearch/api/actions/remote_store/restore.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,30 +13,28 @@ module OpenSearch module API module RemoteStore module Actions - RESTORE_QUERY_PARAMS = Set.new(%i[ - cluster_manager_timeout - wait_for_completion - ]).freeze - # Restores from remote store. # - # @option arguments [Time] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. - # @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning. - # @option arguments [Hash] :body *Required* Comma-separated list of index IDs - # - # {API Reference}[https://opensearch.org/docs/latest/opensearch/remote/#restoring-from-a-backup] - def restore(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning. + # @option args [Hash] :body *Required* Comma-separated list of index IDs + def restore(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_remotestore', '_restore' - method = OpenSearch::API::HTTP_POST - params = Utils.__validate_and_extract_params arguments, RESTORE_QUERY_PARAMS + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_remotestore/_restore' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args, RESTORE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end + + RESTORE_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout + wait_for_completion + ]).freeze end end end diff --git a/lib/opensearch/api/actions/render_search_template.rb b/lib/opensearch/api/actions/render_search_template.rb index 1dd57ce1c..cb2ff8fb5 100644 --- a/lib/opensearch/api/actions/render_search_template.rb +++ b/lib/opensearch/api/actions/render_search_template.rb @@ -3,59 +3,32 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -module OpenSearch - module API - module Actions - # Allows to use the Mustache language to pre-render a search definition. - # - # @option arguments [String] :id The id of the stored search template - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search definition template and its params - # - # - def render_search_template(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - _id = arguments.delete(:id) +# frozen_string_literal: true - method = if arguments[:body] - OpenSearch::API::HTTP_POST - else - OpenSearch::API::HTTP_GET - end +module OpenSearch + module API + module Root + module Actions + # Allows to use the Mustache language to pre-render a search definition. + # + # @option args [String] :id ID of the search template to render. If no `source` is specified, this or the `id` request body parameter is required. + # @option args [Hash] :body The search definition template and its parameters. + def render_search_template(args = {}) + args = Utils.normalize_arguments(args) + _id = args.delete('id') - path = if _id - "_render/template/#{Utils.__listify(_id)}" - else - '_render/template' - end - params = {} + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = ['_render/template', _id].filter(&:present?).join('/').squeeze('/') - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end end end end diff --git a/lib/opensearch/api/actions/replication/autofollow_stats.rb b/lib/opensearch/api/actions/replication/autofollow_stats.rb new file mode 100644 index 000000000..8c13bea36 --- /dev/null +++ b/lib/opensearch/api/actions/replication/autofollow_stats.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Replication + module Actions + # Gets information about auto-follow activity and any replication rules configured on the specified cluster. + # + def autofollow_stats(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_replication/autofollow_stats' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/replication/create_replication_rule.rb b/lib/opensearch/api/actions/replication/create_replication_rule.rb new file mode 100644 index 000000000..744fd54cc --- /dev/null +++ b/lib/opensearch/api/actions/replication/create_replication_rule.rb @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Replication + module Actions + # Automatically starts replication on indexes matching a specified pattern. + # + # @option args [Hash] :body *Required* + def create_replication_rule(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_replication/_autofollow' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/replication/delete_replication_rule.rb b/lib/opensearch/api/actions/replication/delete_replication_rule.rb new file mode 100644 index 000000000..507990da0 --- /dev/null +++ b/lib/opensearch/api/actions/replication/delete_replication_rule.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Replication + module Actions + # Deletes the specified replication rule. + # + # @option args [Hash] :body *Required* + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_replication_rule(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = '_plugins/_replication/_autofollow' + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/replication/follower_stats.rb b/lib/opensearch/api/actions/replication/follower_stats.rb new file mode 100644 index 000000000..f8aee3ac4 --- /dev/null +++ b/lib/opensearch/api/actions/replication/follower_stats.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Replication + module Actions + # Gets information about follower (syncing) indexes on a specified cluster. + # + def follower_stats(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_replication/follower_stats' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/replication/leader_stats.rb b/lib/opensearch/api/actions/replication/leader_stats.rb new file mode 100644 index 000000000..b37dda039 --- /dev/null +++ b/lib/opensearch/api/actions/replication/leader_stats.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Replication + module Actions + # Gets information about replicated leader indexes on a specified cluster. + # + def leader_stats(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_replication/leader_stats' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/replication/pause.rb b/lib/opensearch/api/actions/replication/pause.rb new file mode 100644 index 000000000..18fd6e997 --- /dev/null +++ b/lib/opensearch/api/actions/replication/pause.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Replication + module Actions + # Pauses replication of the leader index. + # + # @option args [String] :index *Required* Name of the data stream, index, or index alias to perform bulk actions on. + # @option args [Hash] :body *Required* + def pause(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_replication', _index, '_pause'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/replication/resume.rb b/lib/opensearch/api/actions/replication/resume.rb new file mode 100644 index 000000000..3c9bdccf5 --- /dev/null +++ b/lib/opensearch/api/actions/replication/resume.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Replication + module Actions + # Resumes replication of the leader index. + # + # @option args [String] :index *Required* Name of the data stream, index, or index alias to perform bulk actions on. + # @option args [Hash] :body *Required* + def resume(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_replication', _index, '_resume'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/replication/start.rb b/lib/opensearch/api/actions/replication/start.rb new file mode 100644 index 000000000..38b672b9c --- /dev/null +++ b/lib/opensearch/api/actions/replication/start.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Replication + module Actions + # Initiate replication of an index from the leader cluster to the follower cluster. + # + # @option args [String] :index *Required* Name of the data stream, index, or index alias to perform bulk actions on. + # @option args [Hash] :body *Required* + def start(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_replication', _index, '_start'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/replication/status.rb b/lib/opensearch/api/actions/replication/status.rb new file mode 100644 index 000000000..2bc1acdf2 --- /dev/null +++ b/lib/opensearch/api/actions/replication/status.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Replication + module Actions + # Gets the status of index replication. + # + # @option args [String] :index *Required* Name of the data stream, index, or index alias to perform bulk actions on. + def status(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_replication', _index, '_status'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/replication/stop.rb b/lib/opensearch/api/actions/replication/stop.rb new file mode 100644 index 000000000..689eef165 --- /dev/null +++ b/lib/opensearch/api/actions/replication/stop.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Replication + module Actions + # Terminates replication and converts the follower index to a standard index. + # + # @option args [String] :index *Required* Name of the data stream, index, or index alias to perform bulk actions on. + # @option args [Hash] :body *Required* + def stop(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_replication', _index, '_stop'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/replication/update_settings.rb b/lib/opensearch/api/actions/replication/update_settings.rb new file mode 100644 index 000000000..92825d098 --- /dev/null +++ b/lib/opensearch/api/actions/replication/update_settings.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Replication + module Actions + # Updates settings on the follower index. + # + # @option args [String] :index *Required* Name of the data stream, index, or index alias to perform bulk actions on. + # @option args [Hash] :body *Required* + def update_settings(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _index = args.delete('index') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_replication', _index, '_update'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/rollups/delete.rb b/lib/opensearch/api/actions/rollups/delete.rb new file mode 100644 index 000000000..a42973082 --- /dev/null +++ b/lib/opensearch/api/actions/rollups/delete.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Rollups + module Actions + # Delete index rollup. + # + # @option args [String] :id *Required* Rollup to access + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_rollup/jobs', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/rollups/explain.rb b/lib/opensearch/api/actions/rollups/explain.rb new file mode 100644 index 000000000..ef5711049 --- /dev/null +++ b/lib/opensearch/api/actions/rollups/explain.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Rollups + module Actions + # Get a rollup's current status. + # + # @option args [String] :id *Required* Rollup to access + def explain(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_rollup/jobs', _id, '_explain'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/rollups/get.rb b/lib/opensearch/api/actions/rollups/get.rb new file mode 100644 index 000000000..76db91e22 --- /dev/null +++ b/lib/opensearch/api/actions/rollups/get.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Rollups + module Actions + # Get an index rollup. + # + # @option args [String] :id *Required* Rollup to access + def get(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_rollup/jobs', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/rollups/put.rb b/lib/opensearch/api/actions/rollups/put.rb new file mode 100644 index 000000000..df9e47764 --- /dev/null +++ b/lib/opensearch/api/actions/rollups/put.rb @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Rollups + module Actions + # Create or update index rollup. + # + # @option args [String] :id *Required* Rollup to access + # @option args [Float] :if_primary_term Only perform the operation if the document has this primary term. + # @option args [Integer] :if_seq_no Only perform the operation if the document has this sequence number. + # @option args [Hash] :body + def put(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_rollup/jobs', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, PUT_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + PUT_QUERY_PARAMS = Set.new(%w[ + if_primary_term + if_seq_no + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/rollups/start.rb b/lib/opensearch/api/actions/rollups/start.rb new file mode 100644 index 000000000..4bae7cdf4 --- /dev/null +++ b/lib/opensearch/api/actions/rollups/start.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Rollups + module Actions + # Start rollup. + # + # @option args [String] :id *Required* Rollup to access + def start(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_rollup/jobs', _id, '_start'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/rollups/stop.rb b/lib/opensearch/api/actions/rollups/stop.rb new file mode 100644 index 000000000..a00b67771 --- /dev/null +++ b/lib/opensearch/api/actions/rollups/stop.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Rollups + module Actions + # Stop rollup. + # + # @option args [String] :id *Required* Rollup to access + def stop(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_rollup/jobs', _id, '_stop'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/scripts_painless_execute.rb b/lib/opensearch/api/actions/scripts_painless_execute.rb index 86c5c4cef..8c25eeb62 100644 --- a/lib/opensearch/api/actions/scripts_painless_execute.rb +++ b/lib/opensearch/api/actions/scripts_painless_execute.rb @@ -3,56 +3,29 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -module OpenSearch - module API - module Actions - # Allows an arbitrary script to be executed and a result to be returned - # This functionality is Experimental and may be changed or removed - # completely in a future release. OpenSearch will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. - # - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The script to execute - # - # - def scripts_painless_execute(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - method = if arguments[:body] - OpenSearch::API::HTTP_POST - else - OpenSearch::API::HTTP_GET - end +# frozen_string_literal: true - path = '_scripts/painless/_execute' - params = {} +module OpenSearch + module API + module Root + module Actions + # Allows an arbitrary script to be executed and a result to be returned. + # + # @option args [Hash] :body The script to execute + def scripts_painless_execute(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = '_scripts/painless/_execute' - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end end end end diff --git a/lib/opensearch/api/actions/scroll.rb b/lib/opensearch/api/actions/scroll.rb index 3ec06a84e..d95a71e32 100644 --- a/lib/opensearch/api/actions/scroll.rb +++ b/lib/opensearch/api/actions/scroll.rb @@ -3,76 +3,40 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -module OpenSearch - module API - module Actions - # Allows to retrieve a large numbers of results from a single search request. - # - # @option arguments [String] :scroll_id The scroll ID *Deprecated* - # @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search - # @option arguments [Boolean] :rest_total_hits_as_int Indicates whether hits.total should be rendered as an integer or an object in the rest search response - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The scroll ID if not passed by URL or query parameter. - # - # *Deprecation notice*: - # A scroll id can be quite large and should be specified as part of the body - # Deprecated since version 7.0.0 - # - # - # - def scroll(arguments = {}) - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - _scroll_id = arguments.delete(:scroll_id) +module OpenSearch + module API + module Root + module Actions + # Allows to retrieve a large numbers of results from a single search request. + # + # @option args [Boolean] :rest_total_hits_as_int If `true`, the API response's `hit.total` property is returned as an integer. If `false`, the API response's `hit.total` property is returned as an object. + # @option args [String] :scroll Period to retain the search context for scrolling. + # @option args [String] :scroll_id DEPRECATED The scroll ID for scrolled search + # @option args [Hash] :body The scroll ID if not passed by URL or query parameter. + def scroll(args = {}) + args = Utils.normalize_arguments(args) + _scroll_id = args.delete('scroll_id') - method = if arguments[:body] - OpenSearch::API::HTTP_POST - else - OpenSearch::API::HTTP_GET - end + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = ['_search/scroll', _scroll_id].filter(&:present?).join('/').squeeze('/') - path = if _scroll_id - "_search/scroll/#{Utils.__listify(_scroll_id)}" - else - '_search/scroll' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + Utils.validate_query_params args, SCROLL_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - body = arguments[:body] - perform_request(method, path, params, body, headers).body + SCROLL_QUERY_PARAMS = Set.new(%w[ + rest_total_hits_as_int + scroll + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:scroll, %i[ - scroll - scroll_id - rest_total_hits_as_int - ].freeze) end end end diff --git a/lib/opensearch/api/actions/search.rb b/lib/opensearch/api/actions/search.rb index d639cffd1..e6c865562 100644 --- a/lib/opensearch/api/actions/search.rb +++ b/lib/opensearch/api/actions/search.rb @@ -3,159 +3,128 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -module OpenSearch - module API - module Actions - # Returns results matching a query. - # - # @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - # @option arguments [String] :analyzer The analyzer to use for the query string - # @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false) - # @option arguments [Boolean] :ccs_minimize_roundtrips Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution - # @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR) - # @option arguments [String] :df The field to use as default where no field prefix is given in the query string - # @option arguments [Boolean] :explain Specify whether to return detailed information about score computation as part of a hit - # @option arguments [List] :stored_fields A comma-separated list of stored fields to return as part of a hit - # @option arguments [List] :docvalue_fields A comma-separated list of fields to return as the docvalue representation of a field for each hit - # @option arguments [Number] :from Starting offset (default: 0) - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :ignore_throttled Whether specified concrete, expanded or aliased indices should be ignored when throttled - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) - # @option arguments [String] :q Query in the Lucene query string syntax - # @option arguments [List] :routing A comma-separated list of specific routing values - # @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search - # @option arguments [String] :search_pipeline Customizable sequence of processing stages applied to search queries. - # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) - # @option arguments [Number] :size Number of hits to return (default: 10) - # @option arguments [List] :sort A comma-separated list of : pairs - # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return - # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field - # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field - # @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - # @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes - # @option arguments [String] :suggest_field Specify which field to use for suggestions - # @option arguments [String] :suggest_mode Specify suggest mode (options: missing, popular, always) - # @option arguments [Number] :suggest_size How many suggestions to return in response - # @option arguments [String] :suggest_text The source text for which the suggestions should be returned - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Boolean] :track_scores Whether to calculate and return scores even if they are not used for sorting - # @option arguments [Boolean] :track_total_hits Indicate if the number of documents that match the query should be tracked - # @option arguments [Boolean] :allow_partial_search_results Indicate if an error should be returned if there is a partial search failure or timeout - # @option arguments [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response - # @option arguments [Boolean] :version Specify whether to return document version as part of a hit - # @option arguments [Boolean] :seq_no_primary_term Specify whether to return sequence number and primary term of the last modification of each hit - # @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting - # @option arguments [Number] :batched_reduce_size The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. - # @option arguments [Number] :max_concurrent_shard_requests The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests - # @option arguments [Number] :pre_filter_shard_size A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. - # @option arguments [Boolean] :rest_total_hits_as_int Indicates whether hits.total should be rendered as an integer or an object in the rest search response - # @option arguments [String] :min_compatible_shard_node The minimum compatible version that all shards involved in search should have for this request to be successful - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search definition using the Query DSL - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def search(arguments = {}) - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - _index = arguments.delete(:index) +module OpenSearch + module API + module Root + module Actions + # Returns results matching a query. + # + # @option args [Boolean, Enumerable, String] :_source Indicates which source fields are returned for matching documents. These fields are returned in the `hits._source` property of the search response. Valid values are: `true` to return the entire document source; `false` to not return the document source; `` to return the source fields that are specified as a comma-separated list (supports wildcard (`*`) patterns). + # @option args [Enumerable, String] :_source_excludes A comma-separated list of source fields to exclude from the response. You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter. If the `_source` parameter is `false`, this parameter is ignored. + # @option args [Enumerable, String] :_source_includes A comma-separated list of source fields to include in the response. If this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the `_source_excludes` query parameter. If the `_source` parameter is `false`, this parameter is ignored. + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. + # @option args [Boolean] :allow_partial_search_results If `true`, returns partial results if there are shard request timeouts or shard failures. If `false`, returns an error with no partial results. + # @option args [Boolean] :analyze_wildcard If `true`, wildcard and prefix queries are analyzed. This parameter can only be used when the q query string parameter is specified. + # @option args [String] :analyzer Analyzer to use for the query string. This parameter can only be used when the q query string parameter is specified. + # @option args [Integer] :batched_reduce_size The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. + # @option args [String] :cancel_after_time_interval The time after which the search request will be canceled. Request-level parameter takes precedence over `cancel_after_time_interval` cluster setting. + # @option args [Boolean] :ccs_minimize_roundtrips If `true`, network round-trips between the coordinating node and the remote clusters are minimized when executing cross-cluster search (CCS) requests. + # @option args [String] :default_operator The default operator for query string query: AND or OR. This parameter can only be used when the `q` query string parameter is specified. + # @option args [String] :df Field to use as default where no field prefix is given in the query string. This parameter can only be used when the q query string parameter is specified. + # @option args [Enumerable, String] :docvalue_fields A comma-separated list of fields to return as the docvalue representation for each hit. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. + # @option args [Boolean] :explain If `true`, returns detailed information about score computation as part of a hit. + # @option args [Integer] :from Starting document offset. Needs to be non-negative. By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. To page through more hits, use the `search_after` parameter. + # @option args [Boolean] :ignore_throttled If `true`, concrete, expanded or aliased indexes will be ignored when frozen. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Boolean] :include_named_queries_score Indicates whether `hit.matched_queries` should be rendered as a map that includes the name of the matched query associated with its score (true) or as an array containing the name of the matched queries (false) + # @option args [Boolean] :lenient If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. This parameter can only be used when the `q` query string parameter is specified. + # @option args [Integer] :max_concurrent_shard_requests Defines the number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests. + # @option args [Boolean] :phase_took Indicates whether to return phase-level `took` time values in the response. + # @option args [Integer] :pre_filter_shard_size Defines a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method (if date filters are mandatory to match but the shard bounds and the query are disjoint). When unspecified, the pre-filter phase is executed if any of these conditions is met: the request targets more than 128 shards; the request targets one or more read-only index; the primary sort of the query targets an indexed field. + # @option args [String] :preference Nodes and shards used for the search. By default, OpenSearch selects from eligible nodes and shards using adaptive replica selection, accounting for allocation awareness. Valid values are: `_only_local` to run the search only on shards on the local node; `_local` to, if possible, run the search on shards on the local node, or if not, select shards using the default method; `_only_nodes:,` to run the search on only the specified nodes IDs, where, if suitable shards exist on more than one selected node, use shards on those nodes using the default method, or if none of the specified nodes are available, select shards from any available node using the default method; `_prefer_nodes:,` to if possible, run the search on the specified nodes IDs, or if not, select shards using the default method; `_shards:,` to run the search only on the specified shards; `` (any string that does not start with `_`) to route searches with the same `` to the same shards in the same order. + # @option args [String] :q Query in the Lucene query string syntax using query parameter search. Query parameter searches do not support the full OpenSearch Query DSL but are handy for testing. + # @option args [Boolean] :request_cache If `true`, the caching of search results is enabled for requests where `size` is `0`. Defaults to index level settings. + # @option args [Boolean] :rest_total_hits_as_int Indicates whether `hits.total` should be rendered as an integer or an object in the rest search response. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [String] :scroll Period to retain the search context for scrolling. See Scroll search results. By default, this value cannot exceed `1d` (24 hours). You can change this limit using the `search.max_keep_alive` cluster-level setting. + # @option args [String] :search_pipeline Customizable sequence of processing stages applied to search queries. + # @option args [String] :search_type How distributed term frequencies are calculated for relevance scoring. + # @option args [Boolean] :seq_no_primary_term If `true`, returns sequence number and primary term of the last modification of each hit. + # @option args [Integer] :size Defines the number of hits to return. By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. To page through more hits, use the `search_after` parameter. + # @option args [Enumerable, String] :sort A comma-separated list of : pairs. + # @option args [Enumerable] :stats Specific `tag` of the request for logging and statistical purposes. + # @option args [Enumerable, String] :stored_fields A comma-separated list of stored fields to return as part of a hit. If no fields are specified, no stored fields are included in the response. If this field is specified, the `_source` parameter defaults to `false`. You can pass `_source: true` to return both source fields and stored fields in the search response. + # @option args [String] :suggest_field Specifies which field to use for suggestions. + # @option args [String] :suggest_mode Specifies the suggest mode. This parameter can only be used when the `suggest_field` and `suggest_text` query string parameters are specified. + # @option args [Integer] :suggest_size Number of suggestions to return. This parameter can only be used when the `suggest_field` and `suggest_text` query string parameters are specified. + # @option args [String] :suggest_text The source text for which the suggestions should be returned. This parameter can only be used when the `suggest_field` and `suggest_text` query string parameters are specified. + # @option args [Integer] :terminate_after Maximum number of documents to collect for each shard. If a query reaches this limit, OpenSearch terminates the query early. OpenSearch collects documents before sorting. Use with caution. OpenSearch applies this parameter to each shard handling the request. When possible, let OpenSearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indexes across multiple data tiers. If set to `0` (default), the query does not terminate early. + # @option args [String] :timeout Specifies the period of time to wait for a response from each shard. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Boolean] :track_scores If `true`, calculate and return document scores, even if the scores are not used for sorting. + # @option args [Boolean, Integer] :track_total_hits Number of hits matching the query to count accurately. If `true`, the exact number of hits is returned at the cost of some performance. If `false`, the response does not include the total number of hits matching the query. + # @option args [Boolean] :typed_keys If `true`, aggregation and suggester names are be prefixed by their respective types in the response. + # @option args [Boolean] :version If `true`, returns document version as part of a hit. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams and indexes, omit this parameter or use `*` or `_all`. + # @option args [Hash] :body The search definition using the Query DSL + def search(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - method = if arguments[:body] - OpenSearch::API::HTTP_POST - else - OpenSearch::API::HTTP_GET - end + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = [_index, '_search'].filter(&:present?).join('/').squeeze('/') - path = if _index - "#{Utils.__listify(_index)}/_search" - else - '_search' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + Utils.validate_query_params args, SEARCH_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - body = arguments[:body] - perform_request(method, path, params, body, headers).body + SEARCH_QUERY_PARAMS = Set.new(%w[ + _source + _source_excludes + _source_includes + allow_no_indices + allow_partial_search_results + analyze_wildcard + analyzer + batched_reduce_size + cancel_after_time_interval + ccs_minimize_roundtrips + default_operator + df + docvalue_fields + expand_wildcards + explain + from + ignore_throttled + ignore_unavailable + include_named_queries_score + lenient + max_concurrent_shard_requests + phase_took + pre_filter_shard_size + preference + q + request_cache + rest_total_hits_as_int + routing + scroll + search_pipeline + search_type + seq_no_primary_term + size + sort + stats + stored_fields + suggest_field + suggest_mode + suggest_size + suggest_text + terminate_after + timeout + track_scores + track_total_hits + typed_keys + version + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:search, %i[ - analyzer - analyze_wildcard - ccs_minimize_roundtrips - default_operator - df - explain - stored_fields - docvalue_fields - from - ignore_unavailable - ignore_throttled - allow_no_indices - expand_wildcards - lenient - preference - q - routing - scroll - search_pipeline - search_type - size - sort - _source - _source_excludes - _source_includes - terminate_after - stats - suggest_field - suggest_mode - suggest_size - suggest_text - timeout - track_scores - track_total_hits - allow_partial_search_results - typed_keys - version - seq_no_primary_term - request_cache - batched_reduce_size - max_concurrent_shard_requests - pre_filter_shard_size - rest_total_hits_as_int - min_compatible_shard_node - ].freeze) end end end diff --git a/lib/opensearch/api/actions/search_pipeline/delete.rb b/lib/opensearch/api/actions/search_pipeline/delete.rb new file mode 100644 index 000000000..d97f522db --- /dev/null +++ b/lib/opensearch/api/actions/search_pipeline/delete.rb @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module SearchPipeline + module Actions + # Deletes the specified search pipeline. + # + # @option args [String] :id *Required* Pipeline ID. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :timeout Operation timeout. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_search/pipeline', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, DELETE_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + + DELETE_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout + timeout + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/search_pipeline/get.rb b/lib/opensearch/api/actions/search_pipeline/get.rb new file mode 100644 index 000000000..e9ed4eead --- /dev/null +++ b/lib/opensearch/api/actions/search_pipeline/get.rb @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module SearchPipeline + module Actions + # Retrieves information about a specified search pipeline. + # + # @option args [String] :cluster_manager_timeout operation timeout for connection to cluster-manager node. + # @option args [String] :id Comma-separated list of search pipeline ids. Wildcards supported. + def get(args = {}) + args = Utils.normalize_arguments(args) + _id = args.delete('id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_search/pipeline', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, GET_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + GET_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/search_pipeline/put.rb b/lib/opensearch/api/actions/search_pipeline/put.rb new file mode 100644 index 000000000..00d687040 --- /dev/null +++ b/lib/opensearch/api/actions/search_pipeline/put.rb @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module SearchPipeline + module Actions + # Creates or replaces the specified search pipeline. + # + # @option args [String] :id *Required* Pipeline ID. + # @option args [String] :cluster_manager_timeout operation timeout for connection to cluster-manager node. + # @option args [String] :timeout Operation timeout. + # @option args [Hash] :body *Required* + def put(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _id = args.delete('id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_search/pipeline', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, PUT_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + PUT_QUERY_PARAMS = Set.new(%w[ + cluster_manager_timeout + timeout + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/search_shards.rb b/lib/opensearch/api/actions/search_shards.rb index ac70f3ed6..f4c364660 100644 --- a/lib/opensearch/api/actions/search_shards.rb +++ b/lib/opensearch/api/actions/search_shards.rb @@ -3,72 +3,48 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Returns information about the indices and shards that a search request would be executed against. - # - # @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) - # @option arguments [String] :routing Specific routing value - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def search_shards(arguments = {}) - headers = arguments.delete(:headers) || {} + module Root + module Actions + # Returns information about the indexes and shards that a search request would be executed against. + # + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Boolean] :local If `true`, the request retrieves information from the local node only. + # @option args [String] :preference Specifies the node or shard the operation should be performed on. Random by default. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [Enumerable, String] :index Returns the indexes and shards that a search request would be executed against. + # @option args [Hash] :body Defines the parameters that can be used in the `search_shards` endpoint request. See documentation for supported query syntax. + def search_shards(args = {}) + args = Utils.normalize_arguments(args) + _index = args.delete('index') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = [_index, '_search_shards'].filter(&:present?).join('/').squeeze('/') - _index = arguments.delete(:index) + Utils.validate_query_params args, SEARCH_SHARDS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - method = OpenSearch::API::HTTP_GET - path = if _index - "#{Utils.__listify(_index)}/_search_shards" - else - '_search_shards' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + SEARCH_SHARDS_QUERY_PARAMS = Set.new(%w[ + allow_no_indices + expand_wildcards + ignore_unavailable + local + preference + routing + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:search_shards, %i[ - preference - routing - local - ignore_unavailable - allow_no_indices - expand_wildcards - ].freeze) end end end diff --git a/lib/opensearch/api/actions/search_template.rb b/lib/opensearch/api/actions/search_template.rb index ba4ed4b48..a0474622d 100644 --- a/lib/opensearch/api/actions/search_template.rb +++ b/lib/opensearch/api/actions/search_template.rb @@ -3,94 +3,64 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Allows to use the Mustache language to pre-render a search definition. - # - # @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :ignore_throttled Whether specified concrete, expanded or aliased indices should be ignored when throttled - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) - # @option arguments [List] :routing A comma-separated list of specific routing values - # @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search - # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) - # @option arguments [Boolean] :explain Specify whether to return detailed information about score computation as part of a hit - # @option arguments [Boolean] :profile Specify whether to profile the query execution - # @option arguments [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response - # @option arguments [Boolean] :rest_total_hits_as_int Indicates whether hits.total should be rendered as an integer or an object in the rest search response - # @option arguments [Boolean] :ccs_minimize_roundtrips Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search definition template and its params (*Required*) - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def search_template(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + module Root + module Actions + # Allows to use the Mustache language to pre-render a search definition. + # + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. + # @option args [Boolean] :ccs_minimize_roundtrips If `true`, network round-trips are minimized for cross-cluster search requests. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Boolean] :explain If `true`, the response includes additional details about score computation as part of a hit. + # @option args [Boolean] :ignore_throttled If `true`, specified concrete, expanded, or aliased indexes are not included in the response when throttled. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [String] :preference Specifies the node or shard the operation should be performed on. Random by default. + # @option args [Boolean] :profile If `true`, the query execution is profiled. + # @option args [Boolean] :rest_total_hits_as_int If `true`, `hits.total` are rendered as an integer in the response. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [String] :scroll Specifies how long a consistent view of the index should be maintained for scrolled search. + # @option args [String] :search_type The type of the search operation. + # @option args [Boolean] :typed_keys If `true`, the response prefixes aggregation and suggester names with their respective types. + # @option args [Enumerable, String] :index Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (*). + # @option args [Hash] :body *Required* The search definition template and its parameters. + def search_template(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - headers = arguments.delete(:headers) || {} + _index = args.delete('index') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = [_index, '_search/template'].filter(&:present?).join('/').squeeze('/') - _index = arguments.delete(:index) + Utils.validate_query_params args, SEARCH_TEMPLATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - method = OpenSearch::API::HTTP_POST - path = if _index - "#{Utils.__listify(_index)}/_search/template" - else - '_search/template' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + SEARCH_TEMPLATE_QUERY_PARAMS = Set.new(%w[ + allow_no_indices + ccs_minimize_roundtrips + expand_wildcards + explain + ignore_throttled + ignore_unavailable + preference + profile + rest_total_hits_as_int + routing + scroll + search_type + typed_keys + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:search_template, %i[ - ignore_unavailable - ignore_throttled - allow_no_indices - expand_wildcards - preference - routing - scroll - search_type - explain - profile - typed_keys - rest_total_hits_as_int - ccs_minimize_roundtrips - ].freeze) end end end diff --git a/lib/opensearch/api/actions/security/authinfo.rb b/lib/opensearch/api/actions/security/authinfo.rb new file mode 100644 index 000000000..6b2e9897d --- /dev/null +++ b/lib/opensearch/api/actions/security/authinfo.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Returns the authentication information. + # + # @option args [String] :auth_type The type of current authentication request. + # @option args [Boolean] :verbose Indicates whether a verbose response should be returned. + def authinfo(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = '_plugins/_security/authinfo' + + Utils.validate_query_params args, AUTHINFO_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + AUTHINFO_QUERY_PARAMS = Set.new(%w[ + auth_type + verbose + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/security/authtoken.rb b/lib/opensearch/api/actions/security/authtoken.rb new file mode 100644 index 000000000..ccd1fdcb7 --- /dev/null +++ b/lib/opensearch/api/actions/security/authtoken.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Returns the authorization token. + # + def authtoken(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_security/api/authtoken' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/change_password.rb b/lib/opensearch/api/actions/security/change_password.rb index bd9ab57fe..5f4e47910 100644 --- a/lib/opensearch/api/actions/security/change_password.rb +++ b/lib/opensearch/api/actions/security/change_password.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,25 +13,20 @@ module OpenSearch module API module Security module Actions - CHANGE_PASSWORD_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Changes the password for the current user. # - # @option arguments [Hash] :body *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#change-password] - def change_password(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [Hash] :body *Required* + def change_password(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'account' - method = OpenSearch::API::HTTP_PUT - params = Utils.__validate_and_extract_params arguments, CHANGE_PASSWORD_QUERY_PARAMS + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = '_plugins/_security/api/account' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/config_upgrade_check.rb b/lib/opensearch/api/actions/security/config_upgrade_check.rb new file mode 100644 index 000000000..48ac1833b --- /dev/null +++ b/lib/opensearch/api/actions/security/config_upgrade_check.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Check whether or not an upgrade can be performed and what resources can be updated. + # + def config_upgrade_check(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/_upgrade_check' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/config_upgrade_perform.rb b/lib/opensearch/api/actions/security/config_upgrade_perform.rb new file mode 100644 index 000000000..a35aa6078 --- /dev/null +++ b/lib/opensearch/api/actions/security/config_upgrade_perform.rb @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Helps cluster operator upgrade missing defaults and stale default definitions. + # + # @option args [Hash] :body + def config_upgrade_perform(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_security/api/_upgrade_perform' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/create_action_group.rb b/lib/opensearch/api/actions/security/create_action_group.rb index ddf881bb2..f04a892d1 100644 --- a/lib/opensearch/api/actions/security/create_action_group.rb +++ b/lib/opensearch/api/actions/security/create_action_group.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,28 +13,24 @@ module OpenSearch module API module Security module Actions - CREATE_ACTION_GROUP_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Creates or replaces the specified action group. # - # @option arguments [String] :action_group *Required* The name of the action group to create or replace - # @option arguments [Hash] :body - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#create-action-group] - def create_action_group(arguments = {}) - raise ArgumentError, "Required argument 'action_group' missing" unless arguments[:action_group] + # @option args [String] :action_group *Required* The name of the action group to create or replace. + # @option args [Hash] :body *Required* + def create_action_group(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'action_group' missing" unless args['action_group'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - _action_group = arguments.delete(:action_group) + _action_group = args.delete('action_group') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'actiongroups', _action_group - method = OpenSearch::API::HTTP_PUT - params = Utils.__validate_and_extract_params arguments, CREATE_ACTION_GROUP_QUERY_PARAMS + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_security/api/actiongroups', _action_group].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/create_allowlist.rb b/lib/opensearch/api/actions/security/create_allowlist.rb new file mode 100644 index 000000000..a439124d3 --- /dev/null +++ b/lib/opensearch/api/actions/security/create_allowlist.rb @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Creates or replaces the permitted APIs. Accessible using Super Admin certificate or REST API permission. + # + # @option args [Hash] :body *Required* + def create_allowlist(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = '_plugins/_security/api/allowlist' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/create_role.rb b/lib/opensearch/api/actions/security/create_role.rb index 961ddf4f9..7b2db875e 100644 --- a/lib/opensearch/api/actions/security/create_role.rb +++ b/lib/opensearch/api/actions/security/create_role.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,29 +13,24 @@ module OpenSearch module API module Security module Actions - CREATE_ROLE_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Creates or replaces the specified role. # - # @option arguments [String] :role *Required* - # @option arguments [Hash] :body *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#create-role] - def create_role(arguments = {}) - raise ArgumentError, "Required argument 'role' missing" unless arguments[:role] - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [String] :role *Required* The name of the role to be created. + # @option args [Hash] :body *Required* + def create_role(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'role' missing" unless args['role'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - _role = arguments.delete(:role) + _role = args.delete('role') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'roles', _role - method = OpenSearch::API::HTTP_PUT - params = Utils.__validate_and_extract_params arguments, CREATE_ROLE_QUERY_PARAMS + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_security/api/roles', _role].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/create_role_mapping.rb b/lib/opensearch/api/actions/security/create_role_mapping.rb index ace99f1a3..298f1e677 100644 --- a/lib/opensearch/api/actions/security/create_role_mapping.rb +++ b/lib/opensearch/api/actions/security/create_role_mapping.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,29 +13,24 @@ module OpenSearch module API module Security module Actions - CREATE_ROLE_MAPPING_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Creates or replaces the specified role mapping. # - # @option arguments [String] :role *Required* - # @option arguments [Hash] :body *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#create-role-mapping] - def create_role_mapping(arguments = {}) - raise ArgumentError, "Required argument 'role' missing" unless arguments[:role] - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [String] :role *Required* The name of the role to create a role mapping for. + # @option args [Hash] :body *Required* + def create_role_mapping(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'role' missing" unless args['role'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - _role = arguments.delete(:role) + _role = args.delete('role') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'rolesmapping', _role - method = OpenSearch::API::HTTP_PUT - params = Utils.__validate_and_extract_params arguments, CREATE_ROLE_MAPPING_QUERY_PARAMS + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_security/api/rolesmapping', _role].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/create_tenant.rb b/lib/opensearch/api/actions/security/create_tenant.rb index d74f2bd1a..41610e047 100644 --- a/lib/opensearch/api/actions/security/create_tenant.rb +++ b/lib/opensearch/api/actions/security/create_tenant.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,28 +13,24 @@ module OpenSearch module API module Security module Actions - CREATE_TENANT_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Creates or replaces the specified tenant. # - # @option arguments [String] :tenant *Required* - # @option arguments [Hash] :body - # - # {API Reference}[https://opensearch.org/docs/2.7/security/access-control/api/#create-tenant] - def create_tenant(arguments = {}) - raise ArgumentError, "Required argument 'tenant' missing" unless arguments[:tenant] + # @option args [String] :tenant *Required* The name of the tenant to be created. + # @option args [Hash] :body *Required* + def create_tenant(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'tenant' missing" unless args['tenant'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - _tenant = arguments.delete(:tenant) + _tenant = args.delete('tenant') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'tenants', _tenant - method = OpenSearch::API::HTTP_PUT - params = Utils.__validate_and_extract_params arguments, CREATE_TENANT_QUERY_PARAMS + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_security/api/tenants', _tenant].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/create_update_tenancy_config.rb b/lib/opensearch/api/actions/security/create_update_tenancy_config.rb new file mode 100644 index 000000000..66b1dffc3 --- /dev/null +++ b/lib/opensearch/api/actions/security/create_update_tenancy_config.rb @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Creates or replaces the multi-tenancy configuration. Only accessible to admins and users with REST API permissions. + # + # @option args [Hash] :body *Required* + def create_update_tenancy_config(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = '_plugins/_security/api/tenancy/config' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/create_user.rb b/lib/opensearch/api/actions/security/create_user.rb index 3d1c6323e..994c5b57a 100644 --- a/lib/opensearch/api/actions/security/create_user.rb +++ b/lib/opensearch/api/actions/security/create_user.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,29 +13,24 @@ module OpenSearch module API module Security module Actions - CREATE_USER_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Creates or replaces the specified user. # - # @option arguments [String] :username *Required* - # @option arguments [Hash] :body *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#create-user] - def create_user(arguments = {}) - raise ArgumentError, "Required argument 'username' missing" unless arguments[:username] - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [String] :username *Required* The name of the user to be created. + # @option args [Hash] :body *Required* + def create_user(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'username' missing" unless args['username'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - _username = arguments.delete(:username) + _username = args.delete('username') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'internalusers', _username - method = OpenSearch::API::HTTP_PUT - params = Utils.__validate_and_extract_params arguments, CREATE_USER_QUERY_PARAMS + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_security/api/internalusers', _username].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/create_user_legacy.rb b/lib/opensearch/api/actions/security/create_user_legacy.rb new file mode 100644 index 000000000..472265894 --- /dev/null +++ b/lib/opensearch/api/actions/security/create_user_legacy.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Creates or replaces the specified user. Legacy API. + # + # @option args [String] :username *Required* The name of the user to be created. + # @option args [Hash] :body *Required* + def create_user_legacy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'username' missing" unless args['username'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _username = args.delete('username') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_security/api/user', _username].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/delete_action_group.rb b/lib/opensearch/api/actions/security/delete_action_group.rb index a6d663d0c..ed7b6d828 100644 --- a/lib/opensearch/api/actions/security/delete_action_group.rb +++ b/lib/opensearch/api/actions/security/delete_action_group.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,27 +13,24 @@ module OpenSearch module API module Security module Actions - DELETE_ACTION_GROUP_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Delete a specified action group. # - # @option arguments [String] :action_group *Required* Action group to delete. - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#delete-action-group] - def delete_action_group(arguments = {}) - raise ArgumentError, "Required argument 'action_group' missing" unless arguments[:action_group] + # @option args [String] :action_group *Required* The name of the action group to delete. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_action_group(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'action_group' missing" unless args['action_group'] - arguments = arguments.clone - _action_group = arguments.delete(:action_group) + _action_group = args.delete('action_group') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'actiongroups', _action_group - method = OpenSearch::API::HTTP_DELETE - params = Utils.__validate_and_extract_params arguments, DELETE_ACTION_GROUP_QUERY_PARAMS + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_security/api/actiongroups', _action_group].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end end end diff --git a/lib/opensearch/api/actions/security/delete_distinguished_name.rb b/lib/opensearch/api/actions/security/delete_distinguished_name.rb new file mode 100644 index 000000000..4816423c5 --- /dev/null +++ b/lib/opensearch/api/actions/security/delete_distinguished_name.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Deletes all distinguished names in the specified cluster or node allow list. Only accessible to super-admins and with rest-api permissions when enabled. + # + # @option args [String] :cluster_name *Required* The cluster-name to delete from list of distinguished names. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_distinguished_name(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'cluster_name' missing" unless args['cluster_name'] + + _cluster_name = args.delete('cluster_name') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_security/api/nodesdn', _cluster_name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/delete_distinguished_names.rb b/lib/opensearch/api/actions/security/delete_distinguished_names.rb deleted file mode 100644 index 5f3c5117d..000000000 --- a/lib/opensearch/api/actions/security/delete_distinguished_names.rb +++ /dev/null @@ -1,41 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module Security - module Actions - DELETE_DISTINGUISHED_NAMES_QUERY_PARAMS = Set.new(%i[ - ]).freeze - - # Deletes all distinguished names in the specified cluster’s or node’s allow list. - # - # @option arguments [String] :cluster_name *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#delete-distinguished-names] - def delete_distinguished_names(arguments = {}) - raise ArgumentError, "Required argument 'cluster_name' missing" unless arguments[:cluster_name] - - arguments = arguments.clone - _cluster_name = arguments.delete(:cluster_name) - - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'nodesdn', _cluster_name - method = OpenSearch::API::HTTP_DELETE - params = Utils.__validate_and_extract_params arguments, DELETE_DISTINGUISHED_NAMES_QUERY_PARAMS - - perform_request(method, url, params, body, headers).body - end - end - end - end -end diff --git a/lib/opensearch/api/actions/security/delete_role.rb b/lib/opensearch/api/actions/security/delete_role.rb index 22e814404..04433b3ca 100644 --- a/lib/opensearch/api/actions/security/delete_role.rb +++ b/lib/opensearch/api/actions/security/delete_role.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,27 +13,24 @@ module OpenSearch module API module Security module Actions - DELETE_ROLE_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Delete the specified role. # - # @option arguments [String] :role *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#delete-role] - def delete_role(arguments = {}) - raise ArgumentError, "Required argument 'role' missing" unless arguments[:role] + # @option args [String] :role *Required* The name of the role to delete. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_role(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'role' missing" unless args['role'] - arguments = arguments.clone - _role = arguments.delete(:role) + _role = args.delete('role') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'roles', _role - method = OpenSearch::API::HTTP_DELETE - params = Utils.__validate_and_extract_params arguments, DELETE_ROLE_QUERY_PARAMS + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_security/api/roles', _role].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end end end diff --git a/lib/opensearch/api/actions/security/delete_role_mapping.rb b/lib/opensearch/api/actions/security/delete_role_mapping.rb index 1599f41ef..5389c79b2 100644 --- a/lib/opensearch/api/actions/security/delete_role_mapping.rb +++ b/lib/opensearch/api/actions/security/delete_role_mapping.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,27 +13,24 @@ module OpenSearch module API module Security module Actions - DELETE_ROLE_MAPPING_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Deletes the specified role mapping. # - # @option arguments [String] :role *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#delete-role-mapping] - def delete_role_mapping(arguments = {}) - raise ArgumentError, "Required argument 'role' missing" unless arguments[:role] + # @option args [String] :role *Required* The name of the role whose mapping needs to delete. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_role_mapping(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'role' missing" unless args['role'] - arguments = arguments.clone - _role = arguments.delete(:role) + _role = args.delete('role') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'rolesmapping', _role - method = OpenSearch::API::HTTP_DELETE - params = Utils.__validate_and_extract_params arguments, DELETE_ROLE_MAPPING_QUERY_PARAMS + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_security/api/rolesmapping', _role].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end end end diff --git a/lib/opensearch/api/actions/security/delete_tenant.rb b/lib/opensearch/api/actions/security/delete_tenant.rb index 5d978b181..fb433f3de 100644 --- a/lib/opensearch/api/actions/security/delete_tenant.rb +++ b/lib/opensearch/api/actions/security/delete_tenant.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,27 +13,24 @@ module OpenSearch module API module Security module Actions - DELETE_TENANT_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Delete the specified tenant. # - # @option arguments [String] :tenant *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#delete-action-group] - def delete_tenant(arguments = {}) - raise ArgumentError, "Required argument 'tenant' missing" unless arguments[:tenant] + # @option args [String] :tenant *Required* The name of the tenant to delete. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_tenant(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'tenant' missing" unless args['tenant'] - arguments = arguments.clone - _tenant = arguments.delete(:tenant) + _tenant = args.delete('tenant') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'tenants', _tenant - method = OpenSearch::API::HTTP_DELETE - params = Utils.__validate_and_extract_params arguments, DELETE_TENANT_QUERY_PARAMS + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_security/api/tenants', _tenant].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end end end diff --git a/lib/opensearch/api/actions/security/delete_user.rb b/lib/opensearch/api/actions/security/delete_user.rb index 4e18f1cc6..a09e6d901 100644 --- a/lib/opensearch/api/actions/security/delete_user.rb +++ b/lib/opensearch/api/actions/security/delete_user.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,27 +13,24 @@ module OpenSearch module API module Security module Actions - DELETE_USER_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Delete the specified user. # - # @option arguments [String] :username *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#delete-user] - def delete_user(arguments = {}) - raise ArgumentError, "Required argument 'username' missing" unless arguments[:username] + # @option args [String] :username *Required* The name of the user to delete. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_user(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'username' missing" unless args['username'] - arguments = arguments.clone - _username = arguments.delete(:username) + _username = args.delete('username') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'internalusers', _username - method = OpenSearch::API::HTTP_DELETE - params = Utils.__validate_and_extract_params arguments, DELETE_USER_QUERY_PARAMS + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_security/api/internalusers', _username].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end end end diff --git a/lib/opensearch/api/actions/security/delete_user_legacy.rb b/lib/opensearch/api/actions/security/delete_user_legacy.rb new file mode 100644 index 000000000..e5a810107 --- /dev/null +++ b/lib/opensearch/api/actions/security/delete_user_legacy.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Delete the specified user. Legacy API. + # + # @option args [String] :username *Required* The name of the user to delete. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_user_legacy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'username' missing" unless args['username'] + + _username = args.delete('username') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_security/api/user', _username].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/flush_cache.rb b/lib/opensearch/api/actions/security/flush_cache.rb index 614acf074..730b11750 100644 --- a/lib/opensearch/api/actions/security/flush_cache.rb +++ b/lib/opensearch/api/actions/security/flush_cache.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,22 +13,19 @@ module OpenSearch module API module Security module Actions - FLUSH_CACHE_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Flushes the Security plugin user, authentication, and authorization cache. # - # - # {API Reference}[https://opensearch.org/docs/2.7/security/access-control/api/#flush-cache] - def flush_cache(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'cache' - method = OpenSearch::API::HTTP_DELETE - params = Utils.__validate_and_extract_params arguments, FLUSH_CACHE_QUERY_PARAMS + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def flush_cache(args = {}) + args = Utils.normalize_arguments(args) + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = '_plugins/_security/api/cache' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end end end diff --git a/lib/opensearch/api/actions/security/generate_obo_token.rb b/lib/opensearch/api/actions/security/generate_obo_token.rb new file mode 100644 index 000000000..965e81a25 --- /dev/null +++ b/lib/opensearch/api/actions/security/generate_obo_token.rb @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Generates On-Behalf-Of token for the current user. + # + # @option args [Hash] :body *Required* + def generate_obo_token(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_security/api/generateonbehalfoftoken' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/generate_user_token.rb b/lib/opensearch/api/actions/security/generate_user_token.rb new file mode 100644 index 000000000..3adb4bc98 --- /dev/null +++ b/lib/opensearch/api/actions/security/generate_user_token.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Generates authorization token for the given user. + # + # @option args [String] :username *Required* The name of the user for whom an auth token is to be vended. + def generate_user_token(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'username' missing" unless args['username'] + + _username = args.delete('username') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_security/api/internalusers', _username, 'authtoken'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/generate_user_token_legacy.rb b/lib/opensearch/api/actions/security/generate_user_token_legacy.rb new file mode 100644 index 000000000..dc0513a40 --- /dev/null +++ b/lib/opensearch/api/actions/security/generate_user_token_legacy.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Generates authorization token for the given user. Legacy API. Not Implemented. + # + # @option args [String] :username *Required* The name of the user for whom an auth token is to be vended. + def generate_user_token_legacy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'username' missing" unless args['username'] + + _username = args.delete('username') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_security/api/user', _username, 'authtoken'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/get_account_details.rb b/lib/opensearch/api/actions/security/get_account_details.rb index 0e075d142..1c759407c 100644 --- a/lib/opensearch/api/actions/security/get_account_details.rb +++ b/lib/opensearch/api/actions/security/get_account_details.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,22 +13,17 @@ module OpenSearch module API module Security module Actions - GET_ACCOUNT_DETAILS_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Returns account details for the current user. # - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#get-account-details] - def get_account_details(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'account' - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_ACCOUNT_DETAILS_QUERY_PARAMS + def get_account_details(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/account' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/get_action_group.rb b/lib/opensearch/api/actions/security/get_action_group.rb index 19243d0bd..0b820a977 100644 --- a/lib/opensearch/api/actions/security/get_action_group.rb +++ b/lib/opensearch/api/actions/security/get_action_group.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,27 +13,22 @@ module OpenSearch module API module Security module Actions - GET_ACTION_GROUP_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Retrieves one action group. # - # @option arguments [String] :action_group *Required* Action group to retrieve. - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#get-action-group] - def get_action_group(arguments = {}) - raise ArgumentError, "Required argument 'action_group' missing" unless arguments[:action_group] + # @option args [String] :action_group *Required* The name of the action group to retrieve. + def get_action_group(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'action_group' missing" unless args['action_group'] - arguments = arguments.clone - _action_group = arguments.delete(:action_group) + _action_group = args.delete('action_group') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'actiongroups', _action_group - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_ACTION_GROUP_QUERY_PARAMS + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_security/api/actiongroups', _action_group].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/get_action_groups.rb b/lib/opensearch/api/actions/security/get_action_groups.rb index fb044adf4..c0aa1f204 100644 --- a/lib/opensearch/api/actions/security/get_action_groups.rb +++ b/lib/opensearch/api/actions/security/get_action_groups.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,22 +13,17 @@ module OpenSearch module API module Security module Actions - GET_ACTION_GROUPS_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Retrieves all action groups. # - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#get-action-groups] - def get_action_groups(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'actiongroups' - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_ACTION_GROUPS_QUERY_PARAMS + def get_action_groups(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/actiongroups' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/get_all_certificates.rb b/lib/opensearch/api/actions/security/get_all_certificates.rb new file mode 100644 index 000000000..ddfe04ca1 --- /dev/null +++ b/lib/opensearch/api/actions/security/get_all_certificates.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Retrieves the cluster security certificates. + # + # @option args [String] :cert_type The type of certificates (HTTP, TRANSPORT, ALL) to retrieve from all nodes. + # @option args [String] :timeout The maximum duration, in seconds, to be spent to retrieve certificates from all nodes. + def get_all_certificates(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/certificates' + + Utils.validate_query_params args, GET_ALL_CERTIFICATES_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + GET_ALL_CERTIFICATES_QUERY_PARAMS = Set.new(%w[ + cert_type + timeout + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/security/get_allowlist.rb b/lib/opensearch/api/actions/security/get_allowlist.rb new file mode 100644 index 000000000..55bc24083 --- /dev/null +++ b/lib/opensearch/api/actions/security/get_allowlist.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Retrieves the current list of allowed API accessible to normal user. + # + def get_allowlist(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/allowlist' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/get_audit_configuration.rb b/lib/opensearch/api/actions/security/get_audit_configuration.rb index ff96284d9..06d1fec52 100644 --- a/lib/opensearch/api/actions/security/get_audit_configuration.rb +++ b/lib/opensearch/api/actions/security/get_audit_configuration.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,22 +13,17 @@ module OpenSearch module API module Security module Actions - GET_AUDIT_CONFIGURATION_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Retrieves the audit configuration. # - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#audit-logs] - def get_audit_configuration(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'audit' - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_AUDIT_CONFIGURATION_QUERY_PARAMS + def get_audit_configuration(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/audit' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/get_certificates.rb b/lib/opensearch/api/actions/security/get_certificates.rb index 87159a8d8..2853d42be 100644 --- a/lib/opensearch/api/actions/security/get_certificates.rb +++ b/lib/opensearch/api/actions/security/get_certificates.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,22 +13,17 @@ module OpenSearch module API module Security module Actions - GET_CERTIFICATES_QUERY_PARAMS = Set.new(%i[ - ]).freeze - - # Retrieves the cluster’s security certificates. - # + # Retrieves the cluster security certificates. # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#get-certificates] - def get_certificates(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'ssl', 'certs' - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_CERTIFICATES_QUERY_PARAMS + def get_certificates(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/ssl/certs' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/get_configuration.rb b/lib/opensearch/api/actions/security/get_configuration.rb index 3c4b770eb..0c1704f22 100644 --- a/lib/opensearch/api/actions/security/get_configuration.rb +++ b/lib/opensearch/api/actions/security/get_configuration.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,22 +13,17 @@ module OpenSearch module API module Security module Actions - GET_CONFIGURATION_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Returns the current Security plugin configuration in JSON format. # - # - # {API Reference}[https://opensearch.org/docs/2.7/security/access-control/api/#get-configuration] - def get_configuration(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'securityconfig' - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_CONFIGURATION_QUERY_PARAMS + def get_configuration(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/securityconfig' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/get_dashboards_info.rb b/lib/opensearch/api/actions/security/get_dashboards_info.rb new file mode 100644 index 000000000..0c21e37ae --- /dev/null +++ b/lib/opensearch/api/actions/security/get_dashboards_info.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Retrieves the current security-dashboards plugin configuration. + # + def get_dashboards_info(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/dashboardsinfo' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/get_distinguished_name.rb b/lib/opensearch/api/actions/security/get_distinguished_name.rb new file mode 100644 index 000000000..50b17bb8a --- /dev/null +++ b/lib/opensearch/api/actions/security/get_distinguished_name.rb @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Retrieves distinguished names. Only accessible to super-admins and with rest-api permissions when enabled. + # + # @option args [String] :cluster_name *Required* The cluster-name to retrieve nodes DN setting for. + # @option args [Boolean] :show_all A Boolean flag to include/exclude static nodes DN from final result. + def get_distinguished_name(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'cluster_name' missing" unless args['cluster_name'] + + _cluster_name = args.delete('cluster_name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_security/api/nodesdn', _cluster_name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, GET_DISTINGUISHED_NAME_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + GET_DISTINGUISHED_NAME_QUERY_PARAMS = Set.new(%w[ + show_all + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/security/get_distinguished_names.rb b/lib/opensearch/api/actions/security/get_distinguished_names.rb index ff90dcc2c..a5f2adae1 100644 --- a/lib/opensearch/api/actions/security/get_distinguished_names.rb +++ b/lib/opensearch/api/actions/security/get_distinguished_names.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,26 +13,23 @@ module OpenSearch module API module Security module Actions - GET_DISTINGUISHED_NAMES_QUERY_PARAMS = Set.new(%i[ - ]).freeze - - # Retrieves all distinguished names in the allow list. - # - # @option arguments [String] :cluster_name + # Retrieves distinguished names. Only accessible to super-admins and with rest-api permissions when enabled. # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#get-distinguished-names] - def get_distinguished_names(arguments = {}) - arguments = arguments.clone - _cluster_name = arguments.delete(:cluster_name) + # @option args [Boolean] :show_all A Boolean flag to include/exclude static nodes DN from final result. + def get_distinguished_names(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/nodesdn' - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'nodesdn', _cluster_name - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_DISTINGUISHED_NAMES_QUERY_PARAMS - - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args, GET_DISTINGUISHED_NAMES_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end + + GET_DISTINGUISHED_NAMES_QUERY_PARAMS = Set.new(%w[ + show_all + ]).freeze end end end diff --git a/lib/opensearch/api/actions/security/get_node_certificates.rb b/lib/opensearch/api/actions/security/get_node_certificates.rb new file mode 100644 index 000000000..6d3be1f72 --- /dev/null +++ b/lib/opensearch/api/actions/security/get_node_certificates.rb @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Retrieves the given node's security certificates. + # + # @option args [String] :node_id *Required* The full-id of the node to retrieve certificates. + # @option args [String] :cert_type The type of certificates (HTTP, TRANSPORT, ALL) to retrieve for a node. + # @option args [String] :timeout The maximum duration, in seconds, to be spent to retrieve a node's certificates. + def get_node_certificates(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'node_id' missing" unless args['node_id'] + + _node_id = args.delete('node_id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_security/api/certificates', _node_id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, GET_NODE_CERTIFICATES_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + GET_NODE_CERTIFICATES_QUERY_PARAMS = Set.new(%w[ + cert_type + timeout + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/security/get_permissions_info.rb b/lib/opensearch/api/actions/security/get_permissions_info.rb new file mode 100644 index 000000000..7ba9b89da --- /dev/null +++ b/lib/opensearch/api/actions/security/get_permissions_info.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Gets the evaluated REST API permissions for the currently logged in user. + # + def get_permissions_info(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/permissionsinfo' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/get_role.rb b/lib/opensearch/api/actions/security/get_role.rb index f4580b801..906c46dba 100644 --- a/lib/opensearch/api/actions/security/get_role.rb +++ b/lib/opensearch/api/actions/security/get_role.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,27 +13,22 @@ module OpenSearch module API module Security module Actions - GET_ROLE_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Retrieves one role. # - # @option arguments [String] :role *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#get-role] - def get_role(arguments = {}) - raise ArgumentError, "Required argument 'role' missing" unless arguments[:role] + # @option args [String] :role *Required* + def get_role(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'role' missing" unless args['role'] - arguments = arguments.clone - _role = arguments.delete(:role) + _role = args.delete('role') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'roles', _role - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_ROLE_QUERY_PARAMS + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_security/api/roles', _role].filter(&:present?).join('/').squeeze('/') - perform_request_complex_ignore404(method, url, params, body, headers, arguments) + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/get_role_mapping.rb b/lib/opensearch/api/actions/security/get_role_mapping.rb index 65dfb584a..438b9d9a9 100644 --- a/lib/opensearch/api/actions/security/get_role_mapping.rb +++ b/lib/opensearch/api/actions/security/get_role_mapping.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,27 +13,22 @@ module OpenSearch module API module Security module Actions - GET_ROLE_MAPPING_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Retrieves one role mapping. # - # @option arguments [String] :role *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#get-role-mapping] - def get_role_mapping(arguments = {}) - raise ArgumentError, "Required argument 'role' missing" unless arguments[:role] + # @option args [String] :role *Required* + def get_role_mapping(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'role' missing" unless args['role'] - arguments = arguments.clone - _role = arguments.delete(:role) + _role = args.delete('role') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'rolesmapping', _role - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_ROLE_MAPPING_QUERY_PARAMS + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_security/api/rolesmapping', _role].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/get_role_mappings.rb b/lib/opensearch/api/actions/security/get_role_mappings.rb index 122bb1a3b..b87a8c814 100644 --- a/lib/opensearch/api/actions/security/get_role_mappings.rb +++ b/lib/opensearch/api/actions/security/get_role_mappings.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,22 +13,17 @@ module OpenSearch module API module Security module Actions - GET_ROLE_MAPPINGS_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Retrieves all role mappings. # - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#get-role-mappings] - def get_role_mappings(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'rolesmapping' - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_ROLE_MAPPINGS_QUERY_PARAMS + def get_role_mappings(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/rolesmapping' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/get_roles.rb b/lib/opensearch/api/actions/security/get_roles.rb index 55036b97d..de6def475 100644 --- a/lib/opensearch/api/actions/security/get_roles.rb +++ b/lib/opensearch/api/actions/security/get_roles.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,22 +13,17 @@ module OpenSearch module API module Security module Actions - GET_ROLES_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Retrieves all roles. # - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#get-roles] - def get_roles(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'roles' - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_ROLES_QUERY_PARAMS + def get_roles(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/roles' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/get_sslinfo.rb b/lib/opensearch/api/actions/security/get_sslinfo.rb new file mode 100644 index 000000000..825ec08e9 --- /dev/null +++ b/lib/opensearch/api/actions/security/get_sslinfo.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Retrieves the SSL configuration information. + # + # @option args [Hash] :show_dn A Boolean flag to indicate whether all domain names should be returned. + def get_sslinfo(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_opendistro/_security/sslinfo' + + Utils.validate_query_params args, GET_SSLINFO_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + GET_SSLINFO_QUERY_PARAMS = Set.new(%w[ + show_dn + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/security/get_tenancy_config.rb b/lib/opensearch/api/actions/security/get_tenancy_config.rb new file mode 100644 index 000000000..00a1cead8 --- /dev/null +++ b/lib/opensearch/api/actions/security/get_tenancy_config.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Retrieves multi-tenancy configuration. Only accessible to admins and users with REST API permissions. + # + def get_tenancy_config(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/tenancy/config' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/get_tenant.rb b/lib/opensearch/api/actions/security/get_tenant.rb index 0f6121e09..ac38b76e3 100644 --- a/lib/opensearch/api/actions/security/get_tenant.rb +++ b/lib/opensearch/api/actions/security/get_tenant.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,27 +13,22 @@ module OpenSearch module API module Security module Actions - GET_TENANT_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Retrieves one tenant. # - # @option arguments [String] :tenant *Required* - # - # {API Reference}[https://opensearch.org/docs/2.7/security/access-control/api/#get-tenant] - def get_tenant(arguments = {}) - raise ArgumentError, "Required argument 'tenant' missing" unless arguments[:tenant] + # @option args [String] :tenant *Required* The name of the tenant to retrieve. + def get_tenant(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'tenant' missing" unless args['tenant'] - arguments = arguments.clone - _tenant = arguments.delete(:tenant) + _tenant = args.delete('tenant') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'tenants', _tenant - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_TENANT_QUERY_PARAMS + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_security/api/tenants', _tenant].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/get_tenants.rb b/lib/opensearch/api/actions/security/get_tenants.rb index 019a0ba1c..fdb2793a7 100644 --- a/lib/opensearch/api/actions/security/get_tenants.rb +++ b/lib/opensearch/api/actions/security/get_tenants.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,22 +13,17 @@ module OpenSearch module API module Security module Actions - GET_TENANTS_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Retrieves all tenants. # - # - # {API Reference}[https://opensearch.org/docs/2.7/security/access-control/api/#get-tenants] - def get_tenants(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'tenants' - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_TENANTS_QUERY_PARAMS + def get_tenants(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/tenants' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/get_user.rb b/lib/opensearch/api/actions/security/get_user.rb index 0ff6b9b59..29cc4f46a 100644 --- a/lib/opensearch/api/actions/security/get_user.rb +++ b/lib/opensearch/api/actions/security/get_user.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,27 +13,22 @@ module OpenSearch module API module Security module Actions - GET_USER_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Retrieve one internal user. # - # @option arguments [String] :username *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#get-user] - def get_user(arguments = {}) - raise ArgumentError, "Required argument 'username' missing" unless arguments[:username] + # @option args [String] :username *Required* The name of the user to retrieve. + def get_user(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'username' missing" unless args['username'] - arguments = arguments.clone - _username = arguments.delete(:username) + _username = args.delete('username') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'internalusers', _username - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_USER_QUERY_PARAMS + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_security/api/internalusers', _username].filter(&:present?).join('/').squeeze('/') - perform_request_complex_ignore404(method, url, params, body, headers, arguments) + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/get_user_legacy.rb b/lib/opensearch/api/actions/security/get_user_legacy.rb new file mode 100644 index 000000000..008bd5487 --- /dev/null +++ b/lib/opensearch/api/actions/security/get_user_legacy.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Retrieve one user. Legacy API. + # + # @option args [String] :username *Required* The name of the user to retrieve. + def get_user_legacy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'username' missing" unless args['username'] + + _username = args.delete('username') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_security/api/user', _username].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/get_users.rb b/lib/opensearch/api/actions/security/get_users.rb index d1349786d..dc2a2cac8 100644 --- a/lib/opensearch/api/actions/security/get_users.rb +++ b/lib/opensearch/api/actions/security/get_users.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,22 +13,17 @@ module OpenSearch module API module Security module Actions - GET_USERS_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Retrieve all internal users. # - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#get-users] - def get_users(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'internalusers' - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, GET_USERS_QUERY_PARAMS + def get_users(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/internalusers' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/get_users_legacy.rb b/lib/opensearch/api/actions/security/get_users_legacy.rb new file mode 100644 index 000000000..ecd0d3830 --- /dev/null +++ b/lib/opensearch/api/actions/security/get_users_legacy.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Retrieve all internal users. Legacy API. + # + def get_users_legacy(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/user' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/health.rb b/lib/opensearch/api/actions/security/health.rb index 92f770744..a83ae8406 100644 --- a/lib/opensearch/api/actions/security/health.rb +++ b/lib/opensearch/api/actions/security/health.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,23 +13,23 @@ module OpenSearch module API module Security module Actions - HEALTH_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Checks to see if the Security plugin is up and running. # - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#health-check] - def health(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'health' - method = OpenSearch::API::HTTP_GET - params = Utils.__validate_and_extract_params arguments, HEALTH_QUERY_PARAMS + # @option args [String] :mode A flag to indicate whether service should consider security-plugin's status before returning health response. `strict` mode indicates service should check Security plugin status. + def health(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = '_plugins/_security/health' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args, HEALTH_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end + + HEALTH_QUERY_PARAMS = Set.new(%w[ + mode + ]).freeze end end end diff --git a/lib/opensearch/api/actions/security/migrate.rb b/lib/opensearch/api/actions/security/migrate.rb new file mode 100644 index 000000000..735c3eb52 --- /dev/null +++ b/lib/opensearch/api/actions/security/migrate.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Migrates security configuration from v6 to v7. + # + def migrate(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_security/api/migrate' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/patch_action_group.rb b/lib/opensearch/api/actions/security/patch_action_group.rb index 4d3ff86fb..fc408fcae 100644 --- a/lib/opensearch/api/actions/security/patch_action_group.rb +++ b/lib/opensearch/api/actions/security/patch_action_group.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,28 +13,24 @@ module OpenSearch module API module Security module Actions - PATCH_ACTION_GROUP_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Updates individual attributes of an action group. # - # @option arguments [String] :action_group *Required* - # @option arguments [Hash] :body - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#patch-action-group] - def patch_action_group(arguments = {}) - raise ArgumentError, "Required argument 'action_group' missing" unless arguments[:action_group] + # @option args [String] :action_group *Required* The name of the action group to update. + # @option args [Enumerable] :body *Required* + def patch_action_group(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'action_group' missing" unless args['action_group'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - _action_group = arguments.delete(:action_group) + _action_group = args.delete('action_group') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'actiongroups', _action_group - method = OpenSearch::API::HTTP_PATCH - params = Utils.__validate_and_extract_params arguments, PATCH_ACTION_GROUP_QUERY_PARAMS + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = 'PATCH' + url = ['_plugins/_security/api/actiongroups', _action_group].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/patch_action_groups.rb b/lib/opensearch/api/actions/security/patch_action_groups.rb index 4e3995e64..bdd2d6ec3 100644 --- a/lib/opensearch/api/actions/security/patch_action_groups.rb +++ b/lib/opensearch/api/actions/security/patch_action_groups.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,23 +13,20 @@ module OpenSearch module API module Security module Actions - PATCH_ACTION_GROUPS_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Creates, updates, or deletes multiple action groups in a single call. # - # @option arguments [Hash] :body - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#patch-action-groups] - def patch_action_groups(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'actiongroups' - method = OpenSearch::API::HTTP_PATCH - params = Utils.__validate_and_extract_params arguments, PATCH_ACTION_GROUPS_QUERY_PARAMS + # @option args [Enumerable] :body *Required* + def patch_action_groups(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = 'PATCH' + url = '_plugins/_security/api/actiongroups' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/patch_allowlist.rb b/lib/opensearch/api/actions/security/patch_allowlist.rb new file mode 100644 index 000000000..2447a2357 --- /dev/null +++ b/lib/opensearch/api/actions/security/patch_allowlist.rb @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Updates the current list of allowed API accessible to normal user. + # + # @option args [Enumerable] :body *Required* + def patch_allowlist(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = 'PATCH' + url = '_plugins/_security/api/allowlist' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/patch_audit_configuration.rb b/lib/opensearch/api/actions/security/patch_audit_configuration.rb index 420be5232..d22ab1b19 100644 --- a/lib/opensearch/api/actions/security/patch_audit_configuration.rb +++ b/lib/opensearch/api/actions/security/patch_audit_configuration.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,25 +13,20 @@ module OpenSearch module API module Security module Actions - PATCH_AUDIT_CONFIGURATION_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # A PATCH call is used to update specified fields in the audit configuration. # - # @option arguments [Hash] :body *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#audit-logs] - def patch_audit_configuration(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [Enumerable] :body *Required* + def patch_audit_configuration(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'audit' - method = OpenSearch::API::HTTP_PATCH - params = Utils.__validate_and_extract_params arguments, PATCH_AUDIT_CONFIGURATION_QUERY_PARAMS + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = 'PATCH' + url = '_plugins/_security/api/audit' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/patch_configuration.rb b/lib/opensearch/api/actions/security/patch_configuration.rb index 4a831df01..1f5467efc 100644 --- a/lib/opensearch/api/actions/security/patch_configuration.rb +++ b/lib/opensearch/api/actions/security/patch_configuration.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,25 +13,20 @@ module OpenSearch module API module Security module Actions - PATCH_CONFIGURATION_QUERY_PARAMS = Set.new(%i[ - ]).freeze - - # A PATCH call is used to update the existing configuration using the REST API. - # - # @option arguments [Hash] :body *Required* + # A `PATCH` call is used to update the existing configuration using the REST API. Only accessible by admins and users with REST API access and only when put or patch is enabled. # - # {API Reference}[https://opensearch.org/docs/2.7/security/access-control/api/#patch-configuration] - def patch_configuration(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [Enumerable] :body *Required* + def patch_configuration(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'securityconfig' - method = OpenSearch::API::HTTP_PATCH - params = Utils.__validate_and_extract_params arguments, PATCH_CONFIGURATION_QUERY_PARAMS + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = 'PATCH' + url = '_plugins/_security/api/securityconfig' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/patch_distinguished_name.rb b/lib/opensearch/api/actions/security/patch_distinguished_name.rb new file mode 100644 index 000000000..3fd9cafc5 --- /dev/null +++ b/lib/opensearch/api/actions/security/patch_distinguished_name.rb @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Updates a distinguished cluster name for a specific cluster. Only accessible to super-admins and with rest-api permissions when enabled. + # + # @option args [String] :cluster_name *Required* The cluster name to update `nodesDn` value. + # @option args [Hash] :body + def patch_distinguished_name(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'cluster_name' missing" unless args['cluster_name'] + + _cluster_name = args.delete('cluster_name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PATCH' + url = ['_plugins/_security/api/nodesdn', _cluster_name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/patch_distinguished_names.rb b/lib/opensearch/api/actions/security/patch_distinguished_names.rb index 1a462b518..070b5fc16 100644 --- a/lib/opensearch/api/actions/security/patch_distinguished_names.rb +++ b/lib/opensearch/api/actions/security/patch_distinguished_names.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,25 +13,20 @@ module OpenSearch module API module Security module Actions - PATCH_DISTINGUISHED_NAMES_QUERY_PARAMS = Set.new(%i[ - ]).freeze - - # Bulk update of distinguished names. - # - # @option arguments [Hash] :body *Required* + # Bulk update of distinguished names. Only accessible to super-admins and with rest-api permissions when enabled. # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#update-all-distinguished-names] - def patch_distinguished_names(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [Enumerable] :body *Required* + def patch_distinguished_names(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'nodesdn' - method = OpenSearch::API::HTTP_PATCH - params = Utils.__validate_and_extract_params arguments, PATCH_DISTINGUISHED_NAMES_QUERY_PARAMS + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = 'PATCH' + url = '_plugins/_security/api/nodesdn' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/patch_role.rb b/lib/opensearch/api/actions/security/patch_role.rb index c18b24224..f5e007e42 100644 --- a/lib/opensearch/api/actions/security/patch_role.rb +++ b/lib/opensearch/api/actions/security/patch_role.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,29 +13,24 @@ module OpenSearch module API module Security module Actions - PATCH_ROLE_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Updates individual attributes of a role. # - # @option arguments [String] :role *Required* - # @option arguments [Hash] :body *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#patch-role] - def patch_role(arguments = {}) - raise ArgumentError, "Required argument 'role' missing" unless arguments[:role] - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [String] :role *Required* The name of the role to update. + # @option args [Enumerable] :body *Required* + def patch_role(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'role' missing" unless args['role'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - _role = arguments.delete(:role) + _role = args.delete('role') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'roles', _role - method = OpenSearch::API::HTTP_PATCH - params = Utils.__validate_and_extract_params arguments, PATCH_ROLE_QUERY_PARAMS + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = 'PATCH' + url = ['_plugins/_security/api/roles', _role].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/patch_role_mapping.rb b/lib/opensearch/api/actions/security/patch_role_mapping.rb index ab2064d4c..7758ed581 100644 --- a/lib/opensearch/api/actions/security/patch_role_mapping.rb +++ b/lib/opensearch/api/actions/security/patch_role_mapping.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,29 +13,24 @@ module OpenSearch module API module Security module Actions - PATCH_ROLE_MAPPING_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Updates individual attributes of a role mapping. # - # @option arguments [String] :role *Required* - # @option arguments [Hash] :body *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#patch-role-mapping] - def patch_role_mapping(arguments = {}) - raise ArgumentError, "Required argument 'role' missing" unless arguments[:role] - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [String] :role *Required* The name of the role to update role-mapping for. + # @option args [Enumerable] :body *Required* + def patch_role_mapping(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'role' missing" unless args['role'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - _role = arguments.delete(:role) + _role = args.delete('role') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'rolesmapping', _role - method = OpenSearch::API::HTTP_PATCH - params = Utils.__validate_and_extract_params arguments, PATCH_ROLE_MAPPING_QUERY_PARAMS + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = 'PATCH' + url = ['_plugins/_security/api/rolesmapping', _role].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/patch_role_mappings.rb b/lib/opensearch/api/actions/security/patch_role_mappings.rb index 1c4c5f63d..dd8336718 100644 --- a/lib/opensearch/api/actions/security/patch_role_mappings.rb +++ b/lib/opensearch/api/actions/security/patch_role_mappings.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,25 +13,20 @@ module OpenSearch module API module Security module Actions - PATCH_ROLE_MAPPINGS_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Creates or updates multiple role mappings in a single call. # - # @option arguments [Hash] :body *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#patch-role-mappings] - def patch_role_mappings(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [Enumerable] :body *Required* + def patch_role_mappings(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'rolesmapping' - method = OpenSearch::API::HTTP_PATCH - params = Utils.__validate_and_extract_params arguments, PATCH_ROLE_MAPPINGS_QUERY_PARAMS + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = 'PATCH' + url = '_plugins/_security/api/rolesmapping' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/patch_roles.rb b/lib/opensearch/api/actions/security/patch_roles.rb index 51f7074b8..2d3c40a50 100644 --- a/lib/opensearch/api/actions/security/patch_roles.rb +++ b/lib/opensearch/api/actions/security/patch_roles.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,25 +13,20 @@ module OpenSearch module API module Security module Actions - PATCH_ROLES_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Creates, updates, or deletes multiple roles in a single call. # - # @option arguments [Hash] :body *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#patch-roles] - def patch_roles(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [Enumerable] :body *Required* + def patch_roles(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'roles' - method = OpenSearch::API::HTTP_PATCH - params = Utils.__validate_and_extract_params arguments, PATCH_ROLES_QUERY_PARAMS + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = 'PATCH' + url = '_plugins/_security/api/roles' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/patch_tenant.rb b/lib/opensearch/api/actions/security/patch_tenant.rb index 284175eb2..8aa56a414 100644 --- a/lib/opensearch/api/actions/security/patch_tenant.rb +++ b/lib/opensearch/api/actions/security/patch_tenant.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,29 +13,24 @@ module OpenSearch module API module Security module Actions - PATCH_TENANT_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Add, delete, or modify a single tenant. # - # @option arguments [String] :tenant *Required* - # @option arguments [Hash] :body *Required* - # - # {API Reference}[https://opensearch.org/docs/2.7/security/access-control/api/#patch-tenant] - def patch_tenant(arguments = {}) - raise ArgumentError, "Required argument 'tenant' missing" unless arguments[:tenant] - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [String] :tenant *Required* The name of the tenant to update. + # @option args [Enumerable] :body *Required* + def patch_tenant(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'tenant' missing" unless args['tenant'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - _tenant = arguments.delete(:tenant) + _tenant = args.delete('tenant') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'tenants', _tenant - method = OpenSearch::API::HTTP_PATCH - params = Utils.__validate_and_extract_params arguments, PATCH_TENANT_QUERY_PARAMS + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = 'PATCH' + url = ['_plugins/_security/api/tenants', _tenant].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/patch_tenants.rb b/lib/opensearch/api/actions/security/patch_tenants.rb index 215e90b61..a80f08ac5 100644 --- a/lib/opensearch/api/actions/security/patch_tenants.rb +++ b/lib/opensearch/api/actions/security/patch_tenants.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,25 +13,20 @@ module OpenSearch module API module Security module Actions - PATCH_TENANTS_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Add, delete, or modify multiple tenants in a single call. # - # @option arguments [Hash] :body *Required* - # - # {API Reference}[https://opensearch.org/docs/2.7/security/access-control/api/#patch-tenants] - def patch_tenants(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [Enumerable] :body *Required* + def patch_tenants(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'tenants' - method = OpenSearch::API::HTTP_PATCH - params = Utils.__validate_and_extract_params arguments, PATCH_TENANTS_QUERY_PARAMS + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = 'PATCH' + url = '_plugins/_security/api/tenants' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/patch_user.rb b/lib/opensearch/api/actions/security/patch_user.rb index 696a9848b..c90c9bc85 100644 --- a/lib/opensearch/api/actions/security/patch_user.rb +++ b/lib/opensearch/api/actions/security/patch_user.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,29 +13,24 @@ module OpenSearch module API module Security module Actions - PATCH_USER_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Updates individual attributes of an internal user. # - # @option arguments [String] :username *Required* - # @option arguments [Hash] :body *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#patch-user] - def patch_user(arguments = {}) - raise ArgumentError, "Required argument 'username' missing" unless arguments[:username] - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [String] :username *Required* The name of the user to update. + # @option args [Enumerable] :body *Required* + def patch_user(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'username' missing" unless args['username'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - _username = arguments.delete(:username) + _username = args.delete('username') - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'internalusers', _username - method = OpenSearch::API::HTTP_PATCH - params = Utils.__validate_and_extract_params arguments, PATCH_USER_QUERY_PARAMS + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = 'PATCH' + url = ['_plugins/_security/api/internalusers', _username].filter(&:present?).join('/').squeeze('/') - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/patch_users.rb b/lib/opensearch/api/actions/security/patch_users.rb index 2dd447386..6f9c1d3b9 100644 --- a/lib/opensearch/api/actions/security/patch_users.rb +++ b/lib/opensearch/api/actions/security/patch_users.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,25 +13,20 @@ module OpenSearch module API module Security module Actions - PATCH_USERS_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Creates, updates, or deletes multiple internal users in a single call. # - # @option arguments [Hash] :body *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#patch-users] - def patch_users(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [Enumerable] :body *Required* + def patch_users(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'internalusers' - method = OpenSearch::API::HTTP_PATCH - params = Utils.__validate_and_extract_params arguments, PATCH_USERS_QUERY_PARAMS + headers = (args.delete('headers') || {}).merge('Content-Type' => 'application/x-ndjson') + body = Utils.bulkify(args.delete('body')) + method = 'PATCH' + url = '_plugins/_security/api/internalusers' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/post_dashboards_info.rb b/lib/opensearch/api/actions/security/post_dashboards_info.rb new file mode 100644 index 000000000..1dc1ba78d --- /dev/null +++ b/lib/opensearch/api/actions/security/post_dashboards_info.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Updates the current security-dashboards plugin configuration. + # + def post_dashboards_info(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_security/dashboardsinfo' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/reload_http_certificates.rb b/lib/opensearch/api/actions/security/reload_http_certificates.rb index 3b41bc2d2..de1a0ba3a 100644 --- a/lib/opensearch/api/actions/security/reload_http_certificates.rb +++ b/lib/opensearch/api/actions/security/reload_http_certificates.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,22 +13,17 @@ module OpenSearch module API module Security module Actions - RELOAD_HTTP_CERTIFICATES_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Reload HTTP layer communication certificates. # - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#reload-http-certificates] - def reload_http_certificates(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'ssl', 'http', 'reloadcerts' - method = OpenSearch::API::HTTP_PUT - params = Utils.__validate_and_extract_params arguments, RELOAD_HTTP_CERTIFICATES_QUERY_PARAMS + def reload_http_certificates(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = '_plugins/_security/api/ssl/http/reloadcerts' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/reload_transport_certificates.rb b/lib/opensearch/api/actions/security/reload_transport_certificates.rb index dfcad4fa5..23ac580e4 100644 --- a/lib/opensearch/api/actions/security/reload_transport_certificates.rb +++ b/lib/opensearch/api/actions/security/reload_transport_certificates.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,22 +13,17 @@ module OpenSearch module API module Security module Actions - RELOAD_TRANSPORT_CERTIFICATES_QUERY_PARAMS = Set.new(%i[ - ]).freeze - - # Reload transport layer communication certificates. - # + # Reload Transport layer communication certificates. # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#reload-transport-certificates] - def reload_transport_certificates(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'ssl', 'transport', 'reloadcerts' - method = OpenSearch::API::HTTP_PUT - params = Utils.__validate_and_extract_params arguments, RELOAD_TRANSPORT_CERTIFICATES_QUERY_PARAMS + def reload_transport_certificates(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = '_plugins/_security/api/ssl/transport/reloadcerts' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/tenant_info.rb b/lib/opensearch/api/actions/security/tenant_info.rb new file mode 100644 index 000000000..6fa1a6a5d --- /dev/null +++ b/lib/opensearch/api/actions/security/tenant_info.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Retrieves the tenant names if any exist. Only accessible to super admins or kibanaserver user. + # + def tenant_info(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = '_plugins/_security/tenantinfo' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/update_audit_configuration.rb b/lib/opensearch/api/actions/security/update_audit_configuration.rb index dd3f054fe..7f660c8e6 100644 --- a/lib/opensearch/api/actions/security/update_audit_configuration.rb +++ b/lib/opensearch/api/actions/security/update_audit_configuration.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,25 +13,20 @@ module OpenSearch module API module Security module Actions - UPDATE_AUDIT_CONFIGURATION_QUERY_PARAMS = Set.new(%i[ - ]).freeze - # Updates the audit configuration. # - # @option arguments [Hash] :body *Required* - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#audit-logs] - def update_audit_configuration(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [Hash] :body *Required* + def update_audit_configuration(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'audit', 'config' - method = OpenSearch::API::HTTP_PUT - params = Utils.__validate_and_extract_params arguments, UPDATE_AUDIT_CONFIGURATION_QUERY_PARAMS + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = '_plugins/_security/api/audit/config' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/update_configuration.rb b/lib/opensearch/api/actions/security/update_configuration.rb index 671ed7124..d4740cba8 100644 --- a/lib/opensearch/api/actions/security/update_configuration.rb +++ b/lib/opensearch/api/actions/security/update_configuration.rb @@ -4,8 +4,8 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. # frozen_string_literal: true @@ -13,25 +13,20 @@ module OpenSearch module API module Security module Actions - UPDATE_CONFIGURATION_QUERY_PARAMS = Set.new(%i[ - ]).freeze - - # Adds or updates the existing configuration using the REST API. - # - # @option arguments [Hash] :body *Required* + # Adds or updates the existing configuration using the REST API. Only accessible by admins and users with REST API access and only when put or patch is enabled. # - # {API Reference}[https://opensearch.org/docs/2.7/security/access-control/api/#update-configuration] - def update_configuration(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + # @option args [Hash] :body *Required* + def update_configuration(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'securityconfig', 'config' - method = OpenSearch::API::HTTP_PUT - params = Utils.__validate_and_extract_params arguments, UPDATE_CONFIGURATION_QUERY_PARAMS + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = '_plugins/_security/api/securityconfig/config' - perform_request(method, url, params, body, headers).body + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body end end end diff --git a/lib/opensearch/api/actions/security/update_distinguished_name.rb b/lib/opensearch/api/actions/security/update_distinguished_name.rb new file mode 100644 index 000000000..eabeee53a --- /dev/null +++ b/lib/opensearch/api/actions/security/update_distinguished_name.rb @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Adds or updates the specified distinguished names in the cluster or node allow list. Only accessible to super-admins and with rest-api permissions when enabled. + # + # @option args [String] :cluster_name *Required* The cluster-name to create/update `nodesDn` value for. + # @option args [Hash] :body + def update_distinguished_name(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'cluster_name' missing" unless args['cluster_name'] + + _cluster_name = args.delete('cluster_name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_security/api/nodesdn', _cluster_name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/update_distinguished_names.rb b/lib/opensearch/api/actions/security/update_distinguished_names.rb deleted file mode 100644 index 6a986589d..000000000 --- a/lib/opensearch/api/actions/security/update_distinguished_names.rb +++ /dev/null @@ -1,42 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module Security - module Actions - UPDATE_DISTINGUISHED_NAMES_QUERY_PARAMS = Set.new(%i[ - ]).freeze - - # Adds or updates the specified distinguished names in the cluster’s or node’s allow list. - # - # @option arguments [String] :cluster_name *Required* - # @option arguments [Hash] :body - # - # {API Reference}[https://opensearch.org/docs/latest/security/access-control/api/#update-distinguished-names] - def update_distinguished_names(arguments = {}) - raise ArgumentError, "Required argument 'cluster_name' missing" unless arguments[:cluster_name] - - arguments = arguments.clone - _cluster_name = arguments.delete(:cluster_name) - - headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) - url = Utils.__pathify '_plugins', '_security', 'api', 'nodesdn', _cluster_name - method = OpenSearch::API::HTTP_PUT - params = Utils.__validate_and_extract_params arguments, UPDATE_DISTINGUISHED_NAMES_QUERY_PARAMS - - perform_request(method, url, params, body, headers).body - end - end - end - end -end diff --git a/lib/opensearch/api/actions/security/validate.rb b/lib/opensearch/api/actions/security/validate.rb new file mode 100644 index 000000000..5859701d9 --- /dev/null +++ b/lib/opensearch/api/actions/security/validate.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Checks whether the v6 security configuration is valid and ready to be migrated to v7. + # + # @option args [Boolean] :accept_invalid A Boolean flag to indicate whether invalid v6 configuration should be allowed. + def validate(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/api/validate' + + Utils.validate_query_params args, VALIDATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + VALIDATE_QUERY_PARAMS = Set.new(%w[ + accept_invalid + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/security/who_am_i.rb b/lib/opensearch/api/actions/security/who_am_i.rb new file mode 100644 index 000000000..7aa441b27 --- /dev/null +++ b/lib/opensearch/api/actions/security/who_am_i.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Gets the user identity related information for currently logged in user. + # + def who_am_i(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = '_plugins/_security/whoami' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/security/who_am_i_protected.rb b/lib/opensearch/api/actions/security/who_am_i_protected.rb new file mode 100644 index 000000000..3045bbe1b --- /dev/null +++ b/lib/opensearch/api/actions/security/who_am_i_protected.rb @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Security + module Actions + # Gets the user identity related information for currently logged in user. User needs to have access to this endpoint when authorization at REST layer is enabled. + # + def who_am_i_protected(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_security/whoamiprotected' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/shutdown/delete_node.rb b/lib/opensearch/api/actions/shutdown/delete_node.rb deleted file mode 100644 index 570b314de..000000000 --- a/lib/opensearch/api/actions/shutdown/delete_node.rb +++ /dev/null @@ -1,60 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Shutdown - module Actions - # Removes a node from the shutdown list - # This functionality is Experimental and may be changed or removed - # completely in a future release. OpenSearch will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. - # - # @option arguments [String] :node_id The node id of node to be removed from the shutdown state - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def delete_node(arguments = {}) - raise ArgumentError, "Required argument 'node_id' missing" unless arguments[:node_id] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _node_id = arguments.delete(:node_id) - - method = OpenSearch::API::HTTP_DELETE - path = "_nodes/#{Utils.__listify(_node_id)}/shutdown" - params = {} - - body = nil - perform_request(method, path, params, body, headers).body - end - end - end - end -end diff --git a/lib/opensearch/api/actions/shutdown/get_node.rb b/lib/opensearch/api/actions/shutdown/get_node.rb deleted file mode 100644 index 44a5056d0..000000000 --- a/lib/opensearch/api/actions/shutdown/get_node.rb +++ /dev/null @@ -1,62 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Shutdown - module Actions - # Retrieve status of a node or nodes that are currently marked as shutting down - # This functionality is Experimental and may be changed or removed - # completely in a future release. OpenSearch will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. - # - # @option arguments [String] :node_id Which node for which to retrieve the shutdown status - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def get_node(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _node_id = arguments.delete(:node_id) - - method = OpenSearch::API::HTTP_GET - path = if _node_id - "_nodes/#{Utils.__listify(_node_id)}/shutdown" - else - '_nodes/shutdown' - end - params = {} - - body = nil - perform_request(method, path, params, body, headers).body - end - end - end - end -end diff --git a/lib/opensearch/api/actions/shutdown/params_registry.rb b/lib/opensearch/api/actions/shutdown/params_registry.rb deleted file mode 100644 index c48a12c6a..000000000 --- a/lib/opensearch/api/actions/shutdown/params_registry.rb +++ /dev/null @@ -1,69 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Shutdown - module Actions - module ParamsRegistry - extend self - - # A Mapping of all the actions to their list of valid params. - # - # @since 6.1.1 - PARAMS = {} - - # Register an action with its list of valid params. - # - # @example Register the action. - # ParamsRegistry.register(:benchmark, [ :verbose ]) - # - # @param [ Symbol ] action The action to register. - # @param [ Array[Symbol] ] valid_params The list of valid params. - # - # @since 6.1.1 - def register(action, valid_params) - PARAMS[action.to_sym] = valid_params - end - - # Get the list of valid params for a given action. - # - # @example Get the list of valid params. - # ParamsRegistry.get(:benchmark) - # - # @param [ Symbol ] action The action. - # - # @return [ Array ] The list of valid params for the action. - # - # @since 6.1.1 - def get(action) - PARAMS.fetch(action, []) - end - end - end - end - end -end diff --git a/lib/opensearch/api/actions/shutdown/put_node.rb b/lib/opensearch/api/actions/shutdown/put_node.rb deleted file mode 100644 index 2b6afe502..000000000 --- a/lib/opensearch/api/actions/shutdown/put_node.rb +++ /dev/null @@ -1,62 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Shutdown - module Actions - # Adds a node to be shut down - # This functionality is Experimental and may be changed or removed - # completely in a future release. OpenSearch will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. - # - # @option arguments [String] :node_id The node id of node to be shut down - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The shutdown type definition to register (*Required*) - # - # - def put_node(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'node_id' missing" unless arguments[:node_id] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _node_id = arguments.delete(:node_id) - - method = OpenSearch::API::HTTP_PUT - path = "_nodes/#{Utils.__listify(_node_id)}/shutdown" - params = {} - - body = arguments[:body] - perform_request(method, path, params, body, headers).body - end - end - end - end -end diff --git a/lib/opensearch/api/actions/sm/create_policy.rb b/lib/opensearch/api/actions/sm/create_policy.rb new file mode 100644 index 000000000..5cf81b90a --- /dev/null +++ b/lib/opensearch/api/actions/sm/create_policy.rb @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Sm + module Actions + # Creates a snapshot management policy. + # + # @option args [String] :policy_name *Required* The name of the snapshot management policy. + # @option args [Hash] :body + def create_policy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'policy_name' missing" unless args['policy_name'] + + _policy_name = args.delete('policy_name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_sm/policies', _policy_name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/sm/delete_policy.rb b/lib/opensearch/api/actions/sm/delete_policy.rb new file mode 100644 index 000000000..b5fc3b945 --- /dev/null +++ b/lib/opensearch/api/actions/sm/delete_policy.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Sm + module Actions + # Deletes a snapshot management policy. + # + # @option args [String] :policy_name *Required* The name of the snapshot management policy. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_policy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'policy_name' missing" unless args['policy_name'] + + _policy_name = args.delete('policy_name') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_sm/policies', _policy_name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/sm/explain_policy.rb b/lib/opensearch/api/actions/sm/explain_policy.rb new file mode 100644 index 000000000..e0ccf9185 --- /dev/null +++ b/lib/opensearch/api/actions/sm/explain_policy.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Sm + module Actions + # Explains the state of the snapshot management policy. + # + # @option args [String] :policy_name *Required* The name of the snapshot management policy. + def explain_policy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'policy_name' missing" unless args['policy_name'] + + _policy_name = args.delete('policy_name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_sm/policies', _policy_name, '_explain'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/sm/get_policies.rb b/lib/opensearch/api/actions/sm/get_policies.rb new file mode 100644 index 000000000..a6194d422 --- /dev/null +++ b/lib/opensearch/api/actions/sm/get_policies.rb @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Sm + module Actions + # Retrieves all snapshot management policies with optional pagination and filtering. + # + # @option args [Integer] :from The starting index (default: 0) + # @option args [String] :queryString A query string to filter policies. + # @option args [Integer] :size The number of policies to return. + # @option args [String] :sortField The field to sort on. + # @option args [String] :sortOrder The order of sorting. + def get_policies(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_sm/policies' + + Utils.validate_query_params args, GET_POLICIES_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + GET_POLICIES_QUERY_PARAMS = Set.new(%w[ + from + queryString + size + sortField + sortOrder + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/sm/get_policy.rb b/lib/opensearch/api/actions/sm/get_policy.rb new file mode 100644 index 000000000..8ed9598f2 --- /dev/null +++ b/lib/opensearch/api/actions/sm/get_policy.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Sm + module Actions + # Retrieves a specific snapshot management policy by name. + # + # @option args [String] :policy_name *Required* The name of the snapshot management policy. + def get_policy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'policy_name' missing" unless args['policy_name'] + + _policy_name = args.delete('policy_name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_sm/policies', _policy_name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/sm/start_policy.rb b/lib/opensearch/api/actions/sm/start_policy.rb new file mode 100644 index 000000000..987162b7a --- /dev/null +++ b/lib/opensearch/api/actions/sm/start_policy.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Sm + module Actions + # Starts a snapshot management policy. + # + # @option args [String] :policy_name *Required* The name of the snapshot management policy. + def start_policy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'policy_name' missing" unless args['policy_name'] + + _policy_name = args.delete('policy_name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_sm/policies', _policy_name, '_start'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/sm/stop_policy.rb b/lib/opensearch/api/actions/sm/stop_policy.rb new file mode 100644 index 000000000..8707ff768 --- /dev/null +++ b/lib/opensearch/api/actions/sm/stop_policy.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Sm + module Actions + # Stops a snapshot management policy. + # + # @option args [String] :policy_name *Required* The name of the snapshot management policy. + def stop_policy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'policy_name' missing" unless args['policy_name'] + + _policy_name = args.delete('policy_name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_sm/policies', _policy_name, '_stop'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/sm/update_policy.rb b/lib/opensearch/api/actions/sm/update_policy.rb new file mode 100644 index 000000000..0831ab41b --- /dev/null +++ b/lib/opensearch/api/actions/sm/update_policy.rb @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Sm + module Actions + # Updates an existing snapshot management policy. Requires `if_seq_no` and `if_primary_term`. + # + # @option args [String] :policy_name *Required* The name of the snapshot management policy. + # @option args [Integer] :if_primary_term *Required* The primary term of the policy to update. + # @option args [Integer] :if_seq_no *Required* The sequence number of the policy to update. + # @option args [Hash] :body + def update_policy(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'policy_name' missing" unless args['policy_name'] + raise ArgumentError, "Required argument 'if_primary_term' missing" unless args['if_primary_term'] + raise ArgumentError, "Required argument 'if_seq_no' missing" unless args['if_seq_no'] + + _policy_name = args.delete('policy_name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_sm/policies', _policy_name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, UPDATE_POLICY_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + UPDATE_POLICY_QUERY_PARAMS = Set.new(%w[ + if_primary_term + if_seq_no + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/snapshot/cleanup_repository.rb b/lib/opensearch/api/actions/snapshot/cleanup_repository.rb index 3162242df..937e5a9e9 100644 --- a/lib/opensearch/api/actions/snapshot/cleanup_repository.rb +++ b/lib/opensearch/api/actions/snapshot/cleanup_repository.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,38 +15,30 @@ module Snapshot module Actions # Removes stale data from repository. # - # @option arguments [String] :repository A repository name - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def cleanup_repository(arguments = {}) - raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :repository *Required* Snapshot repository to clean up. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. + # @option args [String] :timeout Period to wait for a response. + def cleanup_repository(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'repository' missing" unless args['repository'] - _repository = arguments.delete(:repository) + _repository = args.delete('repository') - method = OpenSearch::API::HTTP_POST - path = "_snapshot/#{Utils.__listify(_repository)}/_cleanup" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_snapshot', _repository, '_cleanup'].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, CLEANUP_REPOSITORY_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:cleanup_repository, %i[ - master_timeout + CLEANUP_REPOSITORY_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + master_timeout timeout - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/snapshot/clone.rb b/lib/opensearch/api/actions/snapshot/clone.rb index 4a606991d..ed5751535 100644 --- a/lib/opensearch/api/actions/snapshot/clone.rb +++ b/lib/opensearch/api/actions/snapshot/clone.rb @@ -3,73 +3,48 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Snapshot module Actions - # Clones indices from one snapshot into another snapshot in the same repository. - # - # @option arguments [String] :repository A repository name - # @option arguments [String] :snapshot The name of the snapshot to clone from - # @option arguments [String] :target_snapshot The name of the cloned snapshot to create - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The snapshot clone definition (*Required*) + # Clones indexes from one snapshot into another snapshot in the same repository. # - # - def clone(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] - raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot] - raise ArgumentError, "Required argument 'target_snapshot' missing" unless arguments[:target_snapshot] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _repository = arguments.delete(:repository) - - _snapshot = arguments.delete(:snapshot) - - _target_snapshot = arguments.delete(:target_snapshot) - - method = OpenSearch::API::HTTP_PUT - path = "_snapshot/#{Utils.__listify(_repository)}/#{Utils.__listify(_snapshot)}/_clone/#{Utils.__listify(_target_snapshot)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + # @option args [String] :repository *Required* A repository name + # @option args [String] :snapshot *Required* The name of the snapshot to clone from + # @option args [String] :target_snapshot *Required* The name of the cloned snapshot to create + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Explicit operation timeout for connection to cluster-manager node + # @option args [Hash] :body *Required* The snapshot clone definition + def clone(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'repository' missing" unless args['repository'] + raise ArgumentError, "Required argument 'snapshot' missing" unless args['snapshot'] + raise ArgumentError, "Required argument 'target_snapshot' missing" unless args['target_snapshot'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _repository = args.delete('repository') + _snapshot = args.delete('snapshot') + _target_snapshot = args.delete('target_snapshot') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_snapshot', _repository, _snapshot, '_clone', _target_snapshot].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, CLONE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:clone, %i[ - master_timeout + CLONE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout - ].freeze) + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/snapshot/create.rb b/lib/opensearch/api/actions/snapshot/create.rb index 0bf2b6c3c..f0ddce5b4 100644 --- a/lib/opensearch/api/actions/snapshot/create.rb +++ b/lib/opensearch/api/actions/snapshot/create.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,43 +15,34 @@ module Snapshot module Actions # Creates a snapshot in a repository. # - # @option arguments [String] :repository A repository name - # @option arguments [String] :snapshot A snapshot name - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The snapshot definition - # - # - def create(arguments = {}) - raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] - raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _repository = arguments.delete(:repository) - - _snapshot = arguments.delete(:snapshot) - - method = OpenSearch::API::HTTP_PUT - path = "_snapshot/#{Utils.__listify(_repository)}/#{Utils.__listify(_snapshot)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + # @option args [String] :repository *Required* Repository for the snapshot. + # @option args [String] :snapshot *Required* Name of the snapshot. Must be unique in the repository. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Boolean] :wait_for_completion If `true`, the request returns a response when the snapshot is complete. If `false`, the request returns a response when the snapshot initializes. + # @option args [Hash] :body The snapshot definition + def create(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'repository' missing" unless args['repository'] + raise ArgumentError, "Required argument 'snapshot' missing" unless args['snapshot'] + + _repository = args.delete('repository') + _snapshot = args.delete('snapshot') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_snapshot', _repository, _snapshot].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, CREATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:create, %i[ - master_timeout + CREATE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + master_timeout wait_for_completion - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/snapshot/create_repository.rb b/lib/opensearch/api/actions/snapshot/create_repository.rb index 1b2501119..6087de927 100644 --- a/lib/opensearch/api/actions/snapshot/create_repository.rb +++ b/lib/opensearch/api/actions/snapshot/create_repository.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,42 +15,34 @@ module Snapshot module Actions # Creates a repository. # - # @option arguments [String] :repository A repository name - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Boolean] :verify Whether to verify the repository after creation - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The repository definition (*Required*) - # - # - def create_repository(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :repository *Required* A repository name + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Explicit operation timeout for connection to cluster-manager node + # @option args [String] :timeout Explicit operation timeout + # @option args [Boolean] :verify Whether to verify the repository after creation + # @option args [Hash] :body *Required* The repository definition + def create_repository(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'repository' missing" unless args['repository'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - _repository = arguments.delete(:repository) + _repository = args.delete('repository') - method = OpenSearch::API::HTTP_PUT - path = "_snapshot/#{Utils.__listify(_repository)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_snapshot', _repository].filter(&:present?).join('/').squeeze('/') - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, CREATE_REPOSITORY_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:create_repository, %i[ - master_timeout + CREATE_REPOSITORY_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + master_timeout timeout verify - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/snapshot/delete.rb b/lib/opensearch/api/actions/snapshot/delete.rb index 06b5e4601..b205f3670 100644 --- a/lib/opensearch/api/actions/snapshot/delete.rb +++ b/lib/opensearch/api/actions/snapshot/delete.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,44 +15,33 @@ module Snapshot module Actions # Deletes a snapshot. # - # @option arguments [String] :repository A repository name - # @option arguments [String] :snapshot A snapshot name - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def delete(arguments = {}) - raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] - raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _repository = arguments.delete(:repository) - - _snapshot = arguments.delete(:snapshot) - - method = OpenSearch::API::HTTP_DELETE - path = "_snapshot/#{Utils.__listify(_repository)}/#{Utils.__listify(_snapshot)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body } - else - perform_request(method, path, params, body, headers).body - end + # @option args [String] :repository *Required* A repository name + # @option args [String] :snapshot *Required* A comma-separated list of snapshot names + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Explicit operation timeout for connection to cluster-manager node + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'repository' missing" unless args['repository'] + raise ArgumentError, "Required argument 'snapshot' missing" unless args['snapshot'] + + _repository = args.delete('repository') + _snapshot = args.delete('snapshot') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_snapshot', _repository, _snapshot].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, DELETE_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:delete, %i[ - master_timeout + DELETE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout - ].freeze) + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/snapshot/delete_repository.rb b/lib/opensearch/api/actions/snapshot/delete_repository.rb index 5f41bae86..728191146 100644 --- a/lib/opensearch/api/actions/snapshot/delete_repository.rb +++ b/lib/opensearch/api/actions/snapshot/delete_repository.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,42 +15,32 @@ module Snapshot module Actions # Deletes a repository. # - # @option arguments [List] :repository Name of the snapshot repository to unregister. Wildcard (`*`) patterns are supported. - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def delete_repository(arguments = {}) - raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Enumerable, String] :repository *Required* Name of the snapshot repository to unregister. Wildcard (`*`) patterns are supported. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Explicit operation timeout for connection to cluster-manager node + # @option args [String] :timeout Explicit operation timeout + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_repository(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'repository' missing" unless args['repository'] - _repository = arguments.delete(:repository) + _repository = args.delete('repository') - method = OpenSearch::API::HTTP_DELETE - path = "_snapshot/#{Utils.__listify(_repository)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_snapshot', _repository].filter(&:present?).join('/').squeeze('/') - body = nil - if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body } - else - perform_request(method, path, params, body, headers).body - end + Utils.validate_query_params args, DELETE_REPOSITORY_QUERY_PARAMS + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:delete_repository, %i[ - master_timeout + DELETE_REPOSITORY_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + master_timeout timeout - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/snapshot/get.rb b/lib/opensearch/api/actions/snapshot/get.rb index 9f445e54a..98a683ebf 100644 --- a/lib/opensearch/api/actions/snapshot/get.rb +++ b/lib/opensearch/api/actions/snapshot/get.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,52 +15,35 @@ module Snapshot module Actions # Returns information about a snapshot. # - # @option arguments [String] :repository A repository name - # @option arguments [List] :snapshot A comma-separated list of snapshot names - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Boolean] :ignore_unavailable Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown - # @option arguments [Boolean] :index_details Whether to include details of each index in the snapshot, if those details are available. Defaults to false. - # @option arguments [Boolean] :include_repository Whether to include the repository name in the snapshot info. Defaults to true. - # @option arguments [Boolean] :verbose Whether to show verbose snapshot info or only show the basic info found in the repository index blob - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def get(arguments = {}) - raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] - raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _repository = arguments.delete(:repository) - - _snapshot = arguments.delete(:snapshot) - - method = OpenSearch::API::HTTP_GET - path = "_snapshot/#{Utils.__listify(_repository)}/#{Utils.__listify(_snapshot)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body } - else - perform_request(method, path, params, body, headers).body - end + # @option args [String] :repository *Required* Comma-separated list of snapshot repository names used to limit the request. Wildcard (*) expressions are supported. + # @option args [Enumerable, String] :snapshot *Required* Comma-separated list of snapshot names to retrieve. Also accepts wildcards (`*`). - To get information about all snapshots in a registered repository, use a wildcard (`*`) or `_all`. - To get information about any snapshots that are currently running, use `_current`. + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error for any snapshots that are unavailable. + # @option args [String] :master_timeout DEPRECATED Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Boolean] :verbose If `true`, returns additional information about each snapshot such as the version of OpenSearch which took the snapshot, the start and end times of the snapshot, and the number of shards snapshotted. + def get(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'repository' missing" unless args['repository'] + raise ArgumentError, "Required argument 'snapshot' missing" unless args['snapshot'] + + _repository = args.delete('repository') + _snapshot = args.delete('snapshot') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_snapshot', _repository, _snapshot].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, GET_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get, %i[ - master_timeout + GET_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout ignore_unavailable - index_details - include_repository + master_timeout verbose - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/snapshot/get_features.rb b/lib/opensearch/api/actions/snapshot/get_features.rb deleted file mode 100644 index e22c9ea8d..000000000 --- a/lib/opensearch/api/actions/snapshot/get_features.rb +++ /dev/null @@ -1,61 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Snapshot - module Actions - # Returns a list of features which can be snapshotted in this cluster. - # - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def get_features(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - method = OpenSearch::API::HTTP_GET - path = '_snapshottable_features' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body - end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_features, %i[ - master_timeout - cluster_manager_timeout - ].freeze) - end - end - end -end diff --git a/lib/opensearch/api/actions/snapshot/get_repository.rb b/lib/opensearch/api/actions/snapshot/get_repository.rb index 969d3c081..1462ada6c 100644 --- a/lib/opensearch/api/actions/snapshot/get_repository.rb +++ b/lib/opensearch/api/actions/snapshot/get_repository.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,43 +15,28 @@ module Snapshot module Actions # Returns information about a repository. # - # @option arguments [List] :repository A comma-separated list of repository names - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to cluster_manager node - # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def get_repository(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _repository = arguments.delete(:repository) + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :local Return local information, do not retrieve the state from cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Explicit operation timeout for connection to cluster-manager node + # @option args [Enumerable, String] :repository A comma-separated list of repository names + def get_repository(args = {}) + args = Utils.normalize_arguments(args) + _repository = args.delete('repository') - method = OpenSearch::API::HTTP_GET - path = if _repository - "_snapshot/#{Utils.__listify(_repository)}" - else - '_snapshot' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_snapshot', _repository].filter(&:present?).join('/').squeeze('/') - body = nil - if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body } - else - perform_request(method, path, params, body, headers).body - end + Utils.validate_query_params args, GET_REPOSITORY_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get_repository, %i[ - master_timeout + GET_REPOSITORY_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout local - ].freeze) + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/snapshot/params_registry.rb b/lib/opensearch/api/actions/snapshot/params_registry.rb deleted file mode 100644 index 8ec8ea70c..000000000 --- a/lib/opensearch/api/actions/snapshot/params_registry.rb +++ /dev/null @@ -1,69 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Snapshot - module Actions - module ParamsRegistry - extend self - - # A Mapping of all the actions to their list of valid params. - # - # @since 6.1.1 - PARAMS = {} - - # Register an action with its list of valid params. - # - # @example Register the action. - # ParamsRegistry.register(:benchmark, [ :verbose ]) - # - # @param [ Symbol ] action The action to register. - # @param [ Array[Symbol] ] valid_params The list of valid params. - # - # @since 6.1.1 - def register(action, valid_params) - PARAMS[action.to_sym] = valid_params - end - - # Get the list of valid params for a given action. - # - # @example Get the list of valid params. - # ParamsRegistry.get(:benchmark) - # - # @param [ Symbol ] action The action. - # - # @return [ Array ] The list of valid params for the action. - # - # @since 6.1.1 - def get(action) - PARAMS.fetch(action, []) - end - end - end - end - end -end diff --git a/lib/opensearch/api/actions/snapshot/repository_analyze.rb b/lib/opensearch/api/actions/snapshot/repository_analyze.rb deleted file mode 100644 index 65c0b39ec..000000000 --- a/lib/opensearch/api/actions/snapshot/repository_analyze.rb +++ /dev/null @@ -1,84 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Snapshot - module Actions - # Analyzes a repository for correctness and performance - # - # @option arguments [String] :repository A repository name - # @option arguments [Number] :blob_count Number of blobs to create during the test. Defaults to 100. - # @option arguments [Number] :concurrency Number of operations to run concurrently during the test. Defaults to 10. - # @option arguments [Number] :read_node_count Number of nodes on which to read a blob after writing. Defaults to 10. - # @option arguments [Number] :early_read_node_count Number of nodes on which to perform an early read on a blob, i.e. before writing has completed. Early reads are rare actions so the 'rare_action_probability' parameter is also relevant. Defaults to 2. - # @option arguments [Number] :seed Seed for the random number generator used to create the test workload. Defaults to a random value. - # @option arguments [Number] :rare_action_probability Probability of taking a rare action such as an early read or an overwrite. Defaults to 0.02. - # @option arguments [String] :max_blob_size Maximum size of a blob to create during the test, e.g '1gb' or '100mb'. Defaults to '10mb'. - # @option arguments [String] :max_total_data_size Maximum total size of all blobs to create during the test, e.g '1tb' or '100gb'. Defaults to '1gb'. - # @option arguments [Time] :timeout Explicit operation timeout. Defaults to '30s'. - # @option arguments [Boolean] :detailed Whether to return detailed results or a summary. Defaults to 'false' so that only the summary is returned. - # @option arguments [Boolean] :rarely_abort_writes Whether to rarely abort writes before they complete. Defaults to 'true'. - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def repository_analyze(arguments = {}) - raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _repository = arguments.delete(:repository) - - method = OpenSearch::API::HTTP_POST - path = "_snapshot/#{Utils.__listify(_repository)}/_analyze" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body - end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:repository_analyze, %i[ - blob_count - concurrency - read_node_count - early_read_node_count - seed - rare_action_probability - max_blob_size - max_total_data_size - timeout - detailed - rarely_abort_writes - ].freeze) - end - end - end -end diff --git a/lib/opensearch/api/actions/snapshot/restore.rb b/lib/opensearch/api/actions/snapshot/restore.rb index fc010a657..ec00accb4 100644 --- a/lib/opensearch/api/actions/snapshot/restore.rb +++ b/lib/opensearch/api/actions/snapshot/restore.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,43 +15,34 @@ module Snapshot module Actions # Restores a snapshot. # - # @option arguments [String] :repository A repository name - # @option arguments [String] :snapshot A snapshot name - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Details of what to restore - # - # - def restore(arguments = {}) - raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] - raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _repository = arguments.delete(:repository) - - _snapshot = arguments.delete(:snapshot) - - method = OpenSearch::API::HTTP_POST - path = "_snapshot/#{Utils.__listify(_repository)}/#{Utils.__listify(_snapshot)}/_restore" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + # @option args [String] :repository *Required* A repository name + # @option args [String] :snapshot *Required* A snapshot name + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Explicit operation timeout for connection to cluster-manager node + # @option args [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning + # @option args [Hash] :body Details of what to restore + def restore(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'repository' missing" unless args['repository'] + raise ArgumentError, "Required argument 'snapshot' missing" unless args['snapshot'] + + _repository = args.delete('repository') + _snapshot = args.delete('snapshot') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_snapshot', _repository, _snapshot, '_restore'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, RESTORE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:restore, %i[ - master_timeout + RESTORE_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + master_timeout wait_for_completion - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/snapshot/status.rb b/lib/opensearch/api/actions/snapshot/status.rb index 23236e1fe..accf24809 100644 --- a/lib/opensearch/api/actions/snapshot/status.rb +++ b/lib/opensearch/api/actions/snapshot/status.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,49 +15,30 @@ module Snapshot module Actions # Returns information about the status of a snapshot. # - # @option arguments [String] :repository A repository name - # @option arguments [List] :snapshot A comma-separated list of snapshot names - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Boolean] :ignore_unavailable Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def status(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _repository = arguments.delete(:repository) - - _snapshot = arguments.delete(:snapshot) + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [Boolean] :ignore_unavailable Whether to ignore unavailable snapshots, defaults to `false` which means a SnapshotMissingException is thrown + # @option args [String] :master_timeout DEPRECATED Explicit operation timeout for connection to cluster-manager node + # @option args [String] :repository A repository name + # @option args [Enumerable, String] :snapshot A comma-separated list of snapshot names + def status(args = {}) + args = Utils.normalize_arguments(args) + _repository = args.delete('repository') + _snapshot = args.delete('snapshot') - method = OpenSearch::API::HTTP_GET - path = if _repository && _snapshot - "_snapshot/#{Utils.__listify(_repository)}/#{Utils.__listify(_snapshot)}/_status" - elsif _repository - "_snapshot/#{Utils.__listify(_repository)}/_status" - else - '_snapshot/_status' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_snapshot', _repository, _snapshot, '_status'].filter(&:present?).join('/').squeeze('/') - body = nil - if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body } - else - perform_request(method, path, params, body, headers).body - end + Utils.validate_query_params args, STATUS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:status, %i[ - master_timeout + STATUS_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout ignore_unavailable - ].freeze) + master_timeout + ]).freeze end end end diff --git a/lib/opensearch/api/actions/snapshot/verify_repository.rb b/lib/opensearch/api/actions/snapshot/verify_repository.rb index 5779507ef..f480c73ef 100644 --- a/lib/opensearch/api/actions/snapshot/verify_repository.rb +++ b/lib/opensearch/api/actions/snapshot/verify_repository.rb @@ -3,26 +3,11 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API @@ -30,38 +15,30 @@ module Snapshot module Actions # Verifies a repository. # - # @option arguments [String] :repository A repository name - # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node - # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def verify_repository(arguments = {}) - raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :repository *Required* A repository name + # @option args [String] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. + # @option args [String] :master_timeout DEPRECATED Explicit operation timeout for connection to cluster-manager node + # @option args [String] :timeout Explicit operation timeout + def verify_repository(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'repository' missing" unless args['repository'] - _repository = arguments.delete(:repository) + _repository = args.delete('repository') - method = OpenSearch::API::HTTP_POST - path = "_snapshot/#{Utils.__listify(_repository)}/_verify" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_snapshot', _repository, '_verify'].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, VERIFY_REPOSITORY_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:verify_repository, %i[ - master_timeout + VERIFY_REPOSITORY_QUERY_PARAMS = Set.new(%w[ cluster_manager_timeout + master_timeout timeout - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/sql/close.rb b/lib/opensearch/api/actions/sql/close.rb new file mode 100644 index 000000000..9bb0c3504 --- /dev/null +++ b/lib/opensearch/api/actions/sql/close.rb @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Sql + module Actions + # Clear the cursor context. + # + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Boolean] :sanitize Specifies whether to escape special characters in the results + # @option args [Hash] :body + def close(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_sql/close' + + Utils.validate_query_params args, CLOSE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + CLOSE_QUERY_PARAMS = Set.new(%w[ + format + sanitize + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/sql/explain.rb b/lib/opensearch/api/actions/sql/explain.rb new file mode 100644 index 000000000..ceac09f38 --- /dev/null +++ b/lib/opensearch/api/actions/sql/explain.rb @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Sql + module Actions + # Shows how a query is executed against OpenSearch. + # + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Boolean] :sanitize Specifies whether to escape special characters in the results + # @option args [Hash] :body + def explain(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_sql/_explain' + + Utils.validate_query_params args, EXPLAIN_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + EXPLAIN_QUERY_PARAMS = Set.new(%w[ + format + sanitize + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/sql/get_stats.rb b/lib/opensearch/api/actions/sql/get_stats.rb new file mode 100644 index 000000000..9420f61ec --- /dev/null +++ b/lib/opensearch/api/actions/sql/get_stats.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Sql + module Actions + # Collect metrics for the plugin within the interval. + # + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Boolean] :sanitize Specifies whether to escape special characters in the results + def get_stats(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_sql/stats' + + Utils.validate_query_params args, GET_STATS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + GET_STATS_QUERY_PARAMS = Set.new(%w[ + format + sanitize + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/sql/post_stats.rb b/lib/opensearch/api/actions/sql/post_stats.rb new file mode 100644 index 000000000..948243717 --- /dev/null +++ b/lib/opensearch/api/actions/sql/post_stats.rb @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Sql + module Actions + # By a stats endpoint, you are able to collect metrics for the plugin within the interval. + # + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Boolean] :sanitize Specifies whether to escape special characters in the results + # @option args [Hash] :body + def post_stats(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_sql/stats' + + Utils.validate_query_params args, POST_STATS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + POST_STATS_QUERY_PARAMS = Set.new(%w[ + format + sanitize + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/sql/query.rb b/lib/opensearch/api/actions/sql/query.rb new file mode 100644 index 000000000..6969df97a --- /dev/null +++ b/lib/opensearch/api/actions/sql/query.rb @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Sql + module Actions + # Send a SQL/PPL query to the SQL plugin. + # + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Boolean] :sanitize Specifies whether to escape special characters in the results + # @option args [Hash] :body + def query(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_sql' + + Utils.validate_query_params args, QUERY_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + QUERY_QUERY_PARAMS = Set.new(%w[ + format + sanitize + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/sql/settings.rb b/lib/opensearch/api/actions/sql/settings.rb new file mode 100644 index 000000000..8f9f15d34 --- /dev/null +++ b/lib/opensearch/api/actions/sql/settings.rb @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Sql + module Actions + # Adds SQL settings to the standard OpenSearch cluster settings. + # + # @option args [String] :format A short version of the Accept header (for example, `json`, `yaml`). + # @option args [Hash] :body + def settings(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = '_plugins/_query/settings' + + Utils.validate_query_params args, SETTINGS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + SETTINGS_QUERY_PARAMS = Set.new(%w[ + format + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/tasks/cancel.rb b/lib/opensearch/api/actions/tasks/cancel.rb index 512282dd8..02af0f5b1 100644 --- a/lib/opensearch/api/actions/tasks/cancel.rb +++ b/lib/opensearch/api/actions/tasks/cancel.rb @@ -3,73 +3,42 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Tasks module Actions # Cancels a task, if it can be cancelled through an API. - # This functionality is Experimental and may be changed or removed - # completely in a future release. OpenSearch will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. - # - # @option arguments [String] :task_id Cancel the task with specified task id (node_id:task_number) - # @option arguments [List] :nodes A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - # @option arguments [List] :actions A comma-separated list of actions that should be cancelled. Leave empty to cancel all. - # @option arguments [String] :parent_task_id Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. - # @option arguments [Boolean] :wait_for_completion Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false - # @option arguments [Hash] :headers Custom HTTP headers # - # - def cancel(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _task_id = arguments.delete(:task_id) + # @option args [Enumerable, String] :actions Comma-separated list or wildcard expression of actions used to limit the request. + # @option args [Enumerable] :nodes Comma-separated list of node IDs or names used to limit the request. + # @option args [String] :parent_task_id Parent task ID used to limit the tasks. + # @option args [Boolean] :wait_for_completion Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false + # @option args [Float, String] :task_id ID of the task. + def cancel(args = {}) + args = Utils.normalize_arguments(args) + _task_id = args.delete('task_id') - method = OpenSearch::API::HTTP_POST - path = if _task_id - "_tasks/#{Utils.__listify(_task_id)}/_cancel" - else - '_tasks/_cancel' - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_tasks', _task_id, '_cancel'].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, CANCEL_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:cancel, %i[ - nodes + CANCEL_QUERY_PARAMS = Set.new(%w[ actions + nodes parent_task_id wait_for_completion - ].freeze) + ]).freeze end end end diff --git a/lib/opensearch/api/actions/tasks/get.rb b/lib/opensearch/api/actions/tasks/get.rb index 9f021aad3..c6ace3d08 100644 --- a/lib/opensearch/api/actions/tasks/get.rb +++ b/lib/opensearch/api/actions/tasks/get.rb @@ -3,65 +3,40 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Tasks module Actions # Returns information about a task. - # This functionality is Experimental and may be changed or removed - # completely in a future release. OpenSearch will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. # - # @option arguments [String] :task_id Return the task with specified id (node_id:task_number) - # @option arguments [Boolean] :wait_for_completion Wait for the matching tasks to complete (default: false) - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def get(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [String] :task_id *Required* ID of the task. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Boolean] :wait_for_completion If `true`, the request blocks until the task has completed. + def get(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'task_id' missing" unless args['task_id'] - _task_id = arguments.delete(:task_id) + _task_id = args.delete('task_id') - method = OpenSearch::API::HTTP_GET - path = "_tasks/#{Utils.__listify(_task_id)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_tasks', _task_id].filter(&:present?).join('/').squeeze('/') - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, GET_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:get, %i[ - wait_for_completion + GET_QUERY_PARAMS = Set.new(%w[ timeout - ].freeze) + wait_for_completion + ]).freeze end end end diff --git a/lib/opensearch/api/actions/tasks/list.rb b/lib/opensearch/api/actions/tasks/list.rb index 67807438b..f870cb680 100644 --- a/lib/opensearch/api/actions/tasks/list.rb +++ b/lib/opensearch/api/actions/tasks/list.rb @@ -3,72 +3,45 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API module Tasks module Actions # Returns a list of tasks. - # This functionality is Experimental and may be changed or removed - # completely in a future release. OpenSearch will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. - # - # @option arguments [List] :nodes A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - # @option arguments [List] :actions A comma-separated list of actions that should be returned. Leave empty to return all. - # @option arguments [Boolean] :detailed Return detailed task information (default: false) - # @option arguments [String] :parent_task_id Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. - # @option arguments [Boolean] :wait_for_completion Wait for the matching tasks to complete (default: false) - # @option arguments [String] :group_by Group tasks by nodes or parent/child relationships (options: nodes, parents, none) - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Hash] :headers Custom HTTP headers # - # - def list(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone + # @option args [Enumerable, String] :actions Comma-separated list or wildcard expression of actions used to limit the request. + # @option args [Boolean] :detailed If `true`, the response includes detailed information about shard recoveries. + # @option args [String] :group_by Key used to group tasks in the response. + # @option args [Enumerable] :nodes Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes. + # @option args [String] :parent_task_id Parent task ID used to limit returned information. To return all tasks, omit this parameter or use a value of `-1`. + # @option args [String] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option args [Boolean] :wait_for_completion If `true`, the request blocks until the operation is complete. + def list(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_tasks' - method = OpenSearch::API::HTTP_GET - path = '_tasks' - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, LIST_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:list, %i[ - nodes + LIST_QUERY_PARAMS = Set.new(%w[ actions detailed - parent_task_id - wait_for_completion group_by + nodes + parent_task_id timeout - ].freeze) + wait_for_completion + ]).freeze end end end diff --git a/lib/opensearch/api/actions/tasks/params_registry.rb b/lib/opensearch/api/actions/tasks/params_registry.rb deleted file mode 100644 index 086f8f1ee..000000000 --- a/lib/opensearch/api/actions/tasks/params_registry.rb +++ /dev/null @@ -1,69 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Tasks - module Actions - module ParamsRegistry - extend self - - # A Mapping of all the actions to their list of valid params. - # - # @since 6.1.1 - PARAMS = {} - - # Register an action with its list of valid params. - # - # @example Register the action. - # ParamsRegistry.register(:benchmark, [ :verbose ]) - # - # @param [ Symbol ] action The action to register. - # @param [ Array[Symbol] ] valid_params The list of valid params. - # - # @since 6.1.1 - def register(action, valid_params) - PARAMS[action.to_sym] = valid_params - end - - # Get the list of valid params for a given action. - # - # @example Get the list of valid params. - # ParamsRegistry.get(:benchmark) - # - # @param [ Symbol ] action The action. - # - # @return [ Array ] The list of valid params for the action. - # - # @since 6.1.1 - def get(action) - PARAMS.fetch(action, []) - end - end - end - end - end -end diff --git a/lib/opensearch/api/actions/termvectors.rb b/lib/opensearch/api/actions/termvectors.rb index 74f155e9a..56fe7aa3d 100644 --- a/lib/opensearch/api/actions/termvectors.rb +++ b/lib/opensearch/api/actions/termvectors.rb @@ -3,106 +3,62 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Actions - # Returns information and statistics about terms in the fields of a particular document. - # - # @option arguments [String] :index The index in which the document resides. (*Required*) - # @option arguments [String] :id The id of the document, when not specified a doc param should be supplied. - # @option arguments [Boolean] :term_statistics Specifies if total term frequency and document frequency should be returned. - # @option arguments [Boolean] :field_statistics Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. - # @option arguments [List] :fields A comma-separated list of fields to return. - # @option arguments [Boolean] :offsets Specifies if term offsets should be returned. - # @option arguments [Boolean] :positions Specifies if term positions should be returned. - # @option arguments [Boolean] :payloads Specifies if term payloads should be returned. - # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random). - # @option arguments [String] :routing Specific routing value. - # @option arguments [Boolean] :realtime Specifies if request is real-time as opposed to near-real-time (default: true). - # @option arguments [Number] :version Explicit version number for concurrency control - # @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Define parameters and or supply a document to get termvectors for. See documentation. - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def termvectors(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - headers = arguments.delete(:headers) || {} +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - arguments = arguments.clone +# frozen_string_literal: true - _index = arguments.delete(:index) - - _id = arguments.delete(:id) - - method = if arguments[:body] - OpenSearch::API::HTTP_POST - else - OpenSearch::API::HTTP_GET - end +module OpenSearch + module API + module Root + module Actions + # Returns information and statistics about terms in the fields of a particular document. + # + # @option args [String] :index *Required* Name of the index that contains the document. + # @option args [Boolean] :field_statistics If `true`, the response includes the document count, sum of document frequencies, and sum of total term frequencies. + # @option args [Enumerable, String] :fields Comma-separated list or wildcard expressions of fields to include in the statistics. Used as the default list unless a specific field list is provided in the `completion_fields` or `fielddata_fields` parameters. + # @option args [Boolean] :offsets If `true`, the response includes term offsets. + # @option args [Boolean] :payloads If `true`, the response includes term payloads. + # @option args [Boolean] :positions If `true`, the response includes term positions. + # @option args [String] :preference Specifies the node or shard the operation should be performed on. Random by default. + # @option args [Boolean] :realtime If `true`, the request is real-time as opposed to near-real-time. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [Boolean] :term_statistics If `true`, the response includes term frequency and document frequency. + # @option args [Integer] :version If `true`, returns the document version as part of a hit. + # @option args [String] :version_type Specific version type. + # @option args [String] :id Unique identifier of the document. + # @option args [Hash] :body Define parameters and or supply a document to get termvectors for. See documentation. + def termvectors(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] - endpoint = arguments.delete(:endpoint) || '_termvectors' - path = if _index && _id - "#{Utils.__listify(_index)}/#{endpoint}/#{Utils.__listify(_id)}" - else - "#{Utils.__listify(_index)}/#{endpoint}" - end + _index = args.delete('index') + _id = args.delete('id') - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = body ? 'POST' : 'GET' + url = [_index, '_termvectors', _id].filter(&:present?).join('/').squeeze('/') - body = arguments[:body] - perform_request(method, path, params, body, headers).body - end + Utils.validate_query_params args, TERMVECTORS_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - # Deprecated: Use the plural version, {#termvectors} - # - def termvector(arguments = {}) - termvectors(arguments.merge(endpoint: '_termvector')) + TERMVECTORS_QUERY_PARAMS = Set.new(%w[ + field_statistics + fields + offsets + payloads + positions + preference + realtime + routing + term_statistics + version + version_type + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:termvectors, %i[ - term_statistics - field_statistics - fields - offsets - positions - payloads - preference - routing - realtime - version - version_type - ].freeze) end end end diff --git a/lib/opensearch/api/actions/transforms/delete.rb b/lib/opensearch/api/actions/transforms/delete.rb new file mode 100644 index 000000000..af6c774e9 --- /dev/null +++ b/lib/opensearch/api/actions/transforms/delete.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Transforms + module Actions + # Delete an index transform. + # + # @option args [String] :id *Required* Transform to delete + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_plugins/_transform', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/transforms/explain.rb b/lib/opensearch/api/actions/transforms/explain.rb new file mode 100644 index 000000000..11dfbc8ec --- /dev/null +++ b/lib/opensearch/api/actions/transforms/explain.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Transforms + module Actions + # Returns the status and metadata of a transform job. + # + # @option args [String] :id *Required* Transform to explain + def explain(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_transform', _id, '_explain'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/transforms/get.rb b/lib/opensearch/api/actions/transforms/get.rb new file mode 100644 index 000000000..7003beca6 --- /dev/null +++ b/lib/opensearch/api/actions/transforms/get.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Transforms + module Actions + # Returns the status and metadata of a transform job. + # + # @option args [String] :id *Required* Transform to access + def get(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_plugins/_transform', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/transforms/preview.rb b/lib/opensearch/api/actions/transforms/preview.rb new file mode 100644 index 000000000..807765f6d --- /dev/null +++ b/lib/opensearch/api/actions/transforms/preview.rb @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Transforms + module Actions + # Returns a preview of what a transformed index would look like. + # + # @option args [Hash] :body + def preview(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = '_plugins/_transform/_preview' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/transforms/put.rb b/lib/opensearch/api/actions/transforms/put.rb new file mode 100644 index 000000000..946a9a9d8 --- /dev/null +++ b/lib/opensearch/api/actions/transforms/put.rb @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Transforms + module Actions + # Create an index transform, or update a transform if `if_seq_no` and `if_primary_term` are provided. + # + # @option args [String] :id *Required* Transform to create/update + # @option args [Float] :if_primary_term Only perform the operation if the document has this primary term. + # @option args [Integer] :if_seq_no Only perform the operation if the document has this sequence number. + # @option args [Hash] :body + def put(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_plugins/_transform', _id].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args, PUT_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + PUT_QUERY_PARAMS = Set.new(%w[ + if_primary_term + if_seq_no + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/transforms/search.rb b/lib/opensearch/api/actions/transforms/search.rb new file mode 100644 index 000000000..5070e9af1 --- /dev/null +++ b/lib/opensearch/api/actions/transforms/search.rb @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Transforms + module Actions + # Returns the details of all transform jobs. + # + # @option args [Float] :from The starting transform to return. Default is `0`. + # @option args [String] :search The search term to use to filter results. + # @option args [Float] :size Specifies the number of transforms to return. Default is `10`. + # @option args [String] :sortDirection Specifies the direction to sort results in. Can be `ASC` or `DESC`. Default is `ASC`. + # @option args [String] :sortField The field to sort results with. + def search(args = {}) + args = Utils.normalize_arguments(args) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = '_plugins/_transform' + + Utils.validate_query_params args, SEARCH_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end + + SEARCH_QUERY_PARAMS = Set.new(%w[ + from + search + size + sortDirection + sortField + ]).freeze + end + end + end +end diff --git a/lib/opensearch/api/actions/transforms/start.rb b/lib/opensearch/api/actions/transforms/start.rb new file mode 100644 index 000000000..8185d2d1f --- /dev/null +++ b/lib/opensearch/api/actions/transforms/start.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Transforms + module Actions + # Start transform. + # + # @option args [String] :id *Required* Transform to start + def start(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_transform', _id, '_start'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/transforms/stop.rb b/lib/opensearch/api/actions/transforms/stop.rb new file mode 100644 index 000000000..27a3d05ca --- /dev/null +++ b/lib/opensearch/api/actions/transforms/stop.rb @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Transforms + module Actions + # Stop transform. + # + # @option args [String] :id *Required* Transform to stop + def stop(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + + _id = args.delete('id') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_plugins/_transform', _id, '_stop'].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/update.rb b/lib/opensearch/api/actions/update.rb index 41e8cca48..c3f2ffa8e 100644 --- a/lib/opensearch/api/actions/update.rb +++ b/lib/opensearch/api/actions/update.rb @@ -3,97 +3,66 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -module OpenSearch - module API - module Actions - # Updates a document with a script or partial document. - # - # @option arguments [String] :id Document ID - # @option arguments [String] :index The name of the index - # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return - # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field - # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field - # @option arguments [String] :lang The script language (default: painless) - # @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for) - # @option arguments [Number] :retry_on_conflict Specify how many times should the operation be retried when a conflict occurs (default: 0) - # @option arguments [String] :routing Specific routing value - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Number] :if_seq_no only perform the update operation if the last operation that has changed the document has the specified sequence number - # @option arguments [Number] :if_primary_term only perform the update operation if the last operation that has changed the document has the specified primary term - # @option arguments [Boolean] :require_alias When true, requires destination is an alias. Default is false - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The request definition requires either `script` or partial `doc` (*Required*) - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def update(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. - headers = arguments.delete(:headers) || {} +# frozen_string_literal: true - arguments = arguments.clone - - _id = arguments.delete(:id) +module OpenSearch + module API + module Root + module Actions + # Updates a document with a script or partial document. + # + # @option args [String] :id *Required* Document ID + # @option args [String] :index *Required* The name of the index + # @option args [Boolean, Enumerable, String] :_source Set to `false` to disable source retrieval. You can also specify a comma-separated list of the fields you want to retrieve. + # @option args [Enumerable, String] :_source_excludes Specify the source fields you want to exclude. + # @option args [Enumerable, String] :_source_includes Specify the source fields you want to retrieve. + # @option args [Integer] :if_primary_term Only perform the operation if the document has this primary term. + # @option args [Integer] :if_seq_no Only perform the operation if the document has this sequence number. + # @option args [String] :lang The script language. + # @option args [Boolean, String] :refresh If 'true', OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes. + # @option args [Boolean] :require_alias If `true`, the destination must be an index alias. + # @option args [Integer] :retry_on_conflict Specify how many times should the operation be retried when a conflict occurs. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [String] :timeout Period to wait for dynamic mapping updates and active shards. This guarantees OpenSearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operations. Set to 'all' or any positive integer up to the total number of shards in the index (number_of_replicas+1). Defaults to 1 meaning the primary shard. + # @option args [Hash] :body *Required* The request definition requires either `script` or partial `doc` + def update(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'id' missing" unless args['id'] + raise ArgumentError, "Required argument 'index' missing" unless args['index'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] - _index = arguments.delete(:index) + _id = args.delete('id') + _index = args.delete('index') - method = OpenSearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_update/#{Utils.__listify(_id)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_index, '_update', _id].filter(&:present?).join('/').squeeze('/') - body = arguments[:body] - if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body } - else - perform_request(method, path, params, body, headers).body + Utils.validate_query_params args, UPDATE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body end - end - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:update, %i[ - wait_for_active_shards - _source - _source_excludes - _source_includes - lang - refresh - retry_on_conflict - routing - timeout - if_seq_no - if_primary_term - require_alias - ].freeze) + UPDATE_QUERY_PARAMS = Set.new(%w[ + _source + _source_excludes + _source_includes + if_primary_term + if_seq_no + lang + refresh + require_alias + retry_on_conflict + routing + timeout + wait_for_active_shards + ]).freeze + end end end end diff --git a/lib/opensearch/api/actions/update_by_query.rb b/lib/opensearch/api/actions/update_by_query.rb index 4511ec634..e7362d127 100644 --- a/lib/opensearch/api/actions/update_by_query.rb +++ b/lib/opensearch/api/actions/update_by_query.rb @@ -3,135 +3,107 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Performs an update on every document in the index without changing the source, - # for example to pick up a mapping change. - # - # @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices (*Required*) - # @option arguments [String] :analyzer The analyzer to use for the query string - # @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false) - # @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR) - # @option arguments [String] :df The field to use as default where no field prefix is given in the query string - # @option arguments [Number] :from Starting offset (default: 0) - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - # @option arguments [String] :conflicts What to do when the update by query hits version conflicts? (options: abort, proceed) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - # @option arguments [String] :pipeline Ingest pipeline to set on index requests made by this action. (default: none) - # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) - # @option arguments [String] :q Query in the Lucene query string syntax - # @option arguments [List] :routing A comma-separated list of specific routing values - # @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search - # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) - # @option arguments [Time] :search_timeout Explicit timeout for each search request. Defaults to no timeout. - # @option arguments [Number] :size Deprecated, please use `max_docs` instead - # @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents) - # @option arguments [List] :sort A comma-separated list of : pairs - # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return - # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field - # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field - # @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - # @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes - # @option arguments [Boolean] :version Specify whether to return document version as part of a hit - # @option arguments [Boolean] :version_type Should the document increment the version number (internal) on hit or not (reindex) - # @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting - # @option arguments [Boolean] :refresh Should the affected indexes be refreshed? - # @option arguments [Time] :timeout Time each individual bulk request should wait for shards that are unavailable. - # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - # @option arguments [Number] :scroll_size Size on the scroll request powering the update by query - # @option arguments [Boolean] :wait_for_completion Should the request should block until the update by query operation is complete. - # @option arguments [Number] :requests_per_second The throttle to set on this request in sub-requests per second. -1 means no throttle. - # @option arguments [Number|string] :slices The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search definition using the Query DSL - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # - def update_by_query(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] + module Root + module Actions + # Performs an update on every document in the index without changing the source, + # for example to pick up a mapping change. + # + # @option args [Enumerable, String] :index *Required* Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams or indexes, omit this parameter or use `*` or `_all`. + # @option args [Enumerable] :_source Set to `true` or `false` to return the `_source` field or not, or a list of fields to return. + # @option args [Enumerable] :_source_excludes List of fields to exclude from the returned `_source` field. + # @option args [Enumerable] :_source_includes List of fields to extract and return from the `_source` field. + # @option args [Boolean] :allow_no_indices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. + # @option args [Boolean] :analyze_wildcard If `true`, wildcard and prefix queries are analyzed. + # @option args [String] :analyzer Analyzer to use for the query string. + # @option args [String] :conflicts What to do if update by query hits version conflicts: `abort` or `proceed`. + # @option args [String] :default_operator The default operator for query string query: `AND` or `OR`. + # @option args [String] :df Field to use as default where no field prefix is given in the query string. + # @option args [Enumerable, String] :expand_wildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + # @option args [Integer] :from Starting offset. + # @option args [Boolean] :ignore_unavailable If `false`, the request returns an error if it targets a missing or closed index. + # @option args [Boolean] :lenient If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. + # @option args [Integer] :max_docs Maximum number of documents to process. Defaults to all documents. + # @option args [String] :pipeline ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request. If a final pipeline is configured it will always run, regardless of the value of this parameter. + # @option args [String] :preference Specifies the node or shard the operation should be performed on. Random by default. + # @option args [String] :q Query in the Lucene query string syntax. + # @option args [Boolean, String] :refresh If `true`, OpenSearch refreshes affected shards to make the operation visible to search. + # @option args [Boolean] :request_cache If `true`, the request cache is used for this request. + # @option args [Float] :requests_per_second The throttle for this request in sub-requests per second. + # @option args [Enumerable, String] :routing Custom value used to route operations to a specific shard. + # @option args [String] :scroll Period to retain the search context for scrolling. + # @option args [Integer] :scroll_size Size of the scroll request that powers the operation. + # @option args [String] :search_timeout Explicit timeout for each search request. + # @option args [String] :search_type The type of the search operation. Available options: `query_then_fetch`, `dfs_query_then_fetch`. + # @option args [Integer] :size Deprecated, use `max_docs` instead. + # @option args [Float, String] :slices The number of slices this task should be divided into. + # @option args [Enumerable] :sort A comma-separated list of : pairs. + # @option args [Enumerable] :stats Specific `tag` of the request for logging and statistical purposes. + # @option args [Integer] :terminate_after Maximum number of documents to collect for each shard. If a query reaches this limit, OpenSearch terminates the query early. OpenSearch collects documents before sorting. Use with caution. OpenSearch applies this parameter to each shard handling the request. When possible, let OpenSearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indexes across multiple data tiers. + # @option args [String] :timeout Period each update request waits for the following operations: dynamic mapping updates, waiting for active shards. + # @option args [Boolean] :version If `true`, returns the document version as part of a hit. + # @option args [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + # @option args [Boolean] :wait_for_completion If `true`, the request blocks until the operation is complete. + # @option args [Hash] :body The search definition using the Query DSL + def update_by_query(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'index' missing" unless args['index'] - headers = arguments.delete(:headers) || {} + _index = args.delete('index') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = [_index, '_update_by_query'].filter(&:present?).join('/').squeeze('/') - _index = arguments.delete(:index) + Utils.validate_query_params args, UPDATE_BY_QUERY_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - method = OpenSearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_update_by_query" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = arguments[:body] - perform_request(method, path, params, body, headers).body + UPDATE_BY_QUERY_QUERY_PARAMS = Set.new(%w[ + _source + _source_excludes + _source_includes + allow_no_indices + analyze_wildcard + analyzer + conflicts + default_operator + df + expand_wildcards + from + ignore_unavailable + lenient + max_docs + pipeline + preference + q + refresh + request_cache + requests_per_second + routing + scroll + scroll_size + search_timeout + search_type + size + slices + sort + stats + terminate_after + timeout + version + wait_for_active_shards + wait_for_completion + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:update_by_query, %i[ - analyzer - analyze_wildcard - default_operator - df - from - ignore_unavailable - allow_no_indices - conflicts - expand_wildcards - lenient - pipeline - preference - q - routing - scroll - search_type - search_timeout - size - max_docs - sort - _source - _source_excludes - _source_includes - terminate_after - stats - version - version_type - request_cache - refresh - timeout - wait_for_active_shards - scroll_size - wait_for_completion - requests_per_second - slices - ].freeze) end end end diff --git a/lib/opensearch/api/actions/update_by_query_rethrottle.rb b/lib/opensearch/api/actions/update_by_query_rethrottle.rb index e630b715b..040ae8af0 100644 --- a/lib/opensearch/api/actions/update_by_query_rethrottle.rb +++ b/lib/opensearch/api/actions/update_by_query_rethrottle.rb @@ -3,60 +3,39 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true module OpenSearch module API - module Actions - # Changes the number of requests per second for a particular Update By Query operation. - # - # @option arguments [String] :task_id The task id to rethrottle - # @option arguments [Number] :requests_per_second The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. (*Required*) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def update_by_query_rethrottle(arguments = {}) - raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id] + module Root + module Actions + # Changes the number of requests per second for a particular Update By Query operation. + # + # @option args [String] :task_id *Required* The ID for the task. + # @option args [Float] :requests_per_second The throttle for this request in sub-requests per second. + def update_by_query_rethrottle(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'task_id' missing" unless args['task_id'] - headers = arguments.delete(:headers) || {} + _task_id = args.delete('task_id') - arguments = arguments.clone + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'POST' + url = ['_update_by_query', _task_id, '_rethrottle'].filter(&:present?).join('/').squeeze('/') - _task_id = arguments.delete(:task_id) + Utils.validate_query_params args, UPDATE_BY_QUERY_RETHROTTLE_QUERY_PARAMS + transport.perform_request(method, url, args, body, headers).body + end - method = OpenSearch::API::HTTP_POST - path = "_update_by_query/#{Utils.__listify(_task_id)}/_rethrottle" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - perform_request(method, path, params, body, headers).body + UPDATE_BY_QUERY_RETHROTTLE_QUERY_PARAMS = Set.new(%w[ + requests_per_second + ]).freeze end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:update_by_query_rethrottle, [ - :requests_per_second - ].freeze) end end end diff --git a/lib/opensearch/api/actions/wlm/create_query_group.rb b/lib/opensearch/api/actions/wlm/create_query_group.rb new file mode 100644 index 000000000..3191ac84f --- /dev/null +++ b/lib/opensearch/api/actions/wlm/create_query_group.rb @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Wlm + module Actions + # Creates a new query group and sets the resource limits for the new query group. + # + # @option args [Hash] :body *Required* + def create_query_group(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = '_wlm/query_group' + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/wlm/delete_query_group.rb b/lib/opensearch/api/actions/wlm/delete_query_group.rb new file mode 100644 index 000000000..32b1ae362 --- /dev/null +++ b/lib/opensearch/api/actions/wlm/delete_query_group.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Wlm + module Actions + # Deletes the specified query group. + # + # @option args [String] :name *Required* The name of the query group. + # @option args [List] :ignore set to [404] to ignore server's NOT FOUND error for this request + def delete_query_group(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] + + _name = args.delete('name') + + ignore = args.delete('ignore') || [] + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'DELETE' + url = ['_wlm/query_group', _name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_delete_request method, url, args, body, headers, ignore.include?(404) + end + end + end + end +end diff --git a/lib/opensearch/api/actions/wlm/get_query_group.rb b/lib/opensearch/api/actions/wlm/get_query_group.rb new file mode 100644 index 000000000..5b7986091 --- /dev/null +++ b/lib/opensearch/api/actions/wlm/get_query_group.rb @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Wlm + module Actions + # Retrieves the specified query group. If no query group is specified, all query groups in the cluster are retrieved. + # + # @option args [String] :name The name of the query group. + def get_query_group(args = {}) + args = Utils.normalize_arguments(args) + _name = args.delete('name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'GET' + url = ['_wlm/query_group', _name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/actions/wlm/update_query_group.rb b/lib/opensearch/api/actions/wlm/update_query_group.rb new file mode 100644 index 000000000..8f305995a --- /dev/null +++ b/lib/opensearch/api/actions/wlm/update_query_group.rb @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec. + +# frozen_string_literal: true + +module OpenSearch + module API + module Wlm + module Actions + # Updates the specified query group. + # + # @option args [String] :name *Required* The name of the query group. + # @option args [Hash] :body *Required* + def update_query_group(args = {}) + args = Utils.normalize_arguments(args) + raise ArgumentError, "Required argument 'name' missing" unless args['name'] + raise ArgumentError, "Required argument 'body' missing" unless args['body'] + + _name = args.delete('name') + + headers = args.delete('headers') || {} + body = args.delete('body') + method = 'PUT' + url = ['_wlm/query_group', _name].filter(&:present?).join('/').squeeze('/') + + Utils.validate_query_params args + transport.perform_request(method, url, args, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/http.rb b/lib/opensearch/api/http.rb new file mode 100644 index 000000000..2680b183c --- /dev/null +++ b/lib/opensearch/api/http.rb @@ -0,0 +1,94 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +module OpenSearch + module API + module Http + module Actions + # Make a customized CONNECT request. + # + # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) + # @option arguments [Hash] :params Querystring parameters to be appended to the path + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [String | Hash | Array] :body The body of the request + def connect(url, headers: {}, body: nil, params: {}) + request('CONNECT', url, headers: headers, body: body, params: params) + end + + # Make a customized DELETE request. + # + # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) + # @option arguments [Hash] :params Querystring parameters to be appended to the path + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [String | Hash | Array] :body The body of the request + def delete(url, headers: {}, body: nil, params: {}) + request('DELETE', url, headers: headers, body: body, params: params) + end + + # Make a customized GET request. + # + # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) + # @option arguments [Hash] :params Querystring parameters to be appended to the path + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [String | Hash | Array] :body The body of the request + def get(url, headers: {}, body: nil, params: {}) + request('GET', url, headers: headers, body: body, params: params) + end + + # Make a customized HEAD request. + # + # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) + # @option arguments [Hash] :params Querystring parameters to be appended to the path + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [String | Hash | Array] :body The body of the request + def head(url, headers: {}, body: nil, params: {}) + request('HEAD', url, headers: headers, body: body, params: params) + end + + # Make a customized OPTIONS request. + # + # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) + # @option arguments [Hash] :params Querystring parameters to be appended to the path + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [String | Hash | Array] :body The body of the request + def options(url, headers: {}, body: nil, params: {}) + request('OPTIONS', url, headers: headers, body: body, params: params) + end + + # Make a customized POST request. + # + # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) + # @option arguments [Hash] :params Querystring parameters to be appended to the path + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [String | Hash | Array] :body The body of the request + def post(url, headers: {}, body: nil, params: {}) + request('POST', url, headers: headers, body: body, params: params) + end + + # Make a customized PUT request. + # + # @option arguments [String] :url Relative path to the endpoint (e.g. 'cat/indices/books,movies') (*Required*) + # @option arguments [Hash] :params Querystring parameters to be appended to the path + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [String | Hash | Array] :body The body of the request + def put(url, headers: {}, body: nil, params: {}) + request('PUT', url, headers: headers, body: body, params: params) + end + + private + + def request(method, url, headers: {}, body: nil, params: {}) + body = OpenSearch::API::Utils.bulkify(body) if body.is_a?(Array) + headers.merge!('Content-Type' => 'application/x-ndjson') if body.is_a?(Array) + + transport.perform_request(method, url, params, body, headers).body + end + end + end + end +end diff --git a/lib/opensearch/api/namespace.rb b/lib/opensearch/api/namespace.rb new file mode 100644 index 000000000..e05cf386a --- /dev/null +++ b/lib/opensearch/api/namespace.rb @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +# frozen_string_literal: true + +module OpenSearch + module API + # A child-client housing all the actions for a specific namespace + class Namespace + attr_reader :transport + + # @param [OpenSearch::Transport::Client] transport + # @param [Module] ns_actions the module containing the API actions for this namespace + def initialize(transport, ns_actions) + @transport = transport + send :extend, ns_actions + end + end + end +end diff --git a/lib/opensearch/api/namespace/cat.rb b/lib/opensearch/api/namespace/cat.rb deleted file mode 100644 index 2e1560dc6..000000000 --- a/lib/opensearch/api/namespace/cat.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Cat - module Actions; end - - # Client for the "cat" namespace (includes the {Cat::Actions} methods) - # - class CatClient - include Cat::Actions - include Common::Client::Base - include Common::Client - end - - # Proxy method for {CatClient}, available in the receiving object - # - def cat - @cat ||= CatClient.new(self) - end - end - end -end diff --git a/lib/opensearch/api/namespace/cluster.rb b/lib/opensearch/api/namespace/cluster.rb deleted file mode 100644 index c10c7082e..000000000 --- a/lib/opensearch/api/namespace/cluster.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Cluster - module Actions; end - - # Client for the "cluster" namespace (includes the {Cluster::Actions} methods) - # - class ClusterClient - include Cluster::Actions - include Common::Client::Base - include Common::Client - end - - # Proxy method for {ClusterClient}, available in the receiving object - # - def cluster - @cluster ||= ClusterClient.new(self) - end - end - end -end diff --git a/lib/opensearch/api/namespace/common.rb b/lib/opensearch/api/namespace/common.rb deleted file mode 100644 index 5ed25b078..000000000 --- a/lib/opensearch/api/namespace/common.rb +++ /dev/null @@ -1,72 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Common - module Actions; end - - module Client - # Base client wrapper - # - module Base - attr_reader :client - - def initialize(client) - @client = client - end - end - - # Delegates the `perform_request` method to the wrapped client - # - def perform_request(method, path, params = {}, body = nil, headers = nil) - client.perform_request method, path, params, body, headers - end - - def perform_request_simple_ignore404(method, path, params, body, headers) - Utils.__rescue_from_not_found do - perform_request(method, path, params, body, headers).status == 200 - end - end - - def perform_request_complex_ignore404(method, path, params, body, headers, arguments) - if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body } - else - perform_request(method, path, params, body, headers).body - end - end - - def perform_request_ping(method, path, params, body, headers) - perform_request(method, path, params, body, headers).status == 200 - rescue StandardError => e - raise e unless e.class.to_s =~ /NotFound|ConnectionFailed/ || e.message =~ /Not\s*Found|404|ConnectionFailed/i - false - end - end - end - end -end diff --git a/lib/opensearch/api/namespace/dangling_indices.rb b/lib/opensearch/api/namespace/dangling_indices.rb deleted file mode 100644 index ad4f8e2a4..000000000 --- a/lib/opensearch/api/namespace/dangling_indices.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module DanglingIndices - module Actions; end - - # Client for the "dangling_indices" namespace (includes the {DanglingIndices::Actions} methods) - # - class DanglingIndicesClient - include DanglingIndices::Actions - include Common::Client::Base - include Common::Client - end - - # Proxy method for {DanglingIndicesClient}, available in the receiving object - # - def dangling_indices - @dangling_indices ||= DanglingIndicesClient.new(self) - end - end - end -end diff --git a/lib/opensearch/api/namespace/features.rb b/lib/opensearch/api/namespace/features.rb deleted file mode 100644 index d01272838..000000000 --- a/lib/opensearch/api/namespace/features.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Features - module Actions; end - - # Client for the "features" namespace (includes the {Features::Actions} methods) - # - class FeaturesClient - include Features::Actions - include Common::Client::Base - include Common::Client - end - - # Proxy method for {FeaturesClient}, available in the receiving object - # - def features - @features ||= FeaturesClient.new(self) - end - end - end -end diff --git a/lib/opensearch/api/namespace/http.rb b/lib/opensearch/api/namespace/http.rb deleted file mode 100644 index 3fd045bfc..000000000 --- a/lib/opensearch/api/namespace/http.rb +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module Http - module Actions; end - - # Client for the "http" namespace (includes the Http::Actions methods) - class HttpClient - include Http::Actions - include Common::Client - include Common::Client::Base - end - - # Proxy method for HttpClient, available in the receiving object - def http - @http ||= HttpClient.new(self) - end - end - end -end diff --git a/lib/opensearch/api/namespace/indices.rb b/lib/opensearch/api/namespace/indices.rb deleted file mode 100644 index 9e4b6f05d..000000000 --- a/lib/opensearch/api/namespace/indices.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Indices - module Actions; end - - # Client for the "indices" namespace (includes the {Indices::Actions} methods) - # - class IndicesClient - include Indices::Actions - include Common::Client::Base - include Common::Client - end - - # Proxy method for {IndicesClient}, available in the receiving object - # - def indices - @indices ||= IndicesClient.new(self) - end - end - end -end diff --git a/lib/opensearch/api/namespace/ingest.rb b/lib/opensearch/api/namespace/ingest.rb deleted file mode 100644 index be3683c26..000000000 --- a/lib/opensearch/api/namespace/ingest.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Ingest - module Actions; end - - # Client for the "ingest" namespace (includes the {Ingest::Actions} methods) - # - class IngestClient - include Ingest::Actions - include Common::Client::Base - include Common::Client - end - - # Proxy method for {IngestClient}, available in the receiving object - # - def ingest - @ingest ||= IngestClient.new(self) - end - end - end -end diff --git a/lib/opensearch/api/namespace/nodes.rb b/lib/opensearch/api/namespace/nodes.rb deleted file mode 100644 index 253e2efe2..000000000 --- a/lib/opensearch/api/namespace/nodes.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Nodes - module Actions; end - - # Client for the "nodes" namespace (includes the {Nodes::Actions} methods) - # - class NodesClient - include Nodes::Actions - include Common::Client::Base - include Common::Client - end - - # Proxy method for {NodesClient}, available in the receiving object - # - def nodes - @nodes ||= NodesClient.new(self) - end - end - end -end diff --git a/lib/opensearch/api/namespace/remote.rb b/lib/opensearch/api/namespace/remote.rb deleted file mode 100644 index 53f85bc29..000000000 --- a/lib/opensearch/api/namespace/remote.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Remote - module Actions; end - - # Client for the "remote" namespace (includes the {Remote::Actions} methods) - # - class RemoteClient - include Remote::Actions - include Common::Client::Base - include Common::Client - end - - # Proxy method for {RemoteClient}, available in the receiving object - # - def remote - @remote ||= RemoteClient.new(self) - end - end - end -end diff --git a/lib/opensearch/api/namespace/remote_store.rb b/lib/opensearch/api/namespace/remote_store.rb deleted file mode 100644 index 255fef121..000000000 --- a/lib/opensearch/api/namespace/remote_store.rb +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module RemoteStore - module Actions; end - - # Client for the "remote_store" namespace (includes the RemoteStore::Actions methods) - class RemoteStoreClient - include RemoteStore::Actions - include Common::Client - include Common::Client::Base - end - - # Proxy method for RemoteStoreClient, available in the receiving object - def remote_store - @remote_store ||= RemoteStoreClient.new(self) - end - end - end -end diff --git a/lib/opensearch/api/namespace/security.rb b/lib/opensearch/api/namespace/security.rb deleted file mode 100644 index 389c2b34d..000000000 --- a/lib/opensearch/api/namespace/security.rb +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -module OpenSearch - module API - module Security - module Actions; end - - # Client for the "security" namespace (includes the Security::Actions methods) - class SecurityClient - include Security::Actions - include Common::Client - include Common::Client::Base - end - - # Proxy method for SecurityClient, available in the receiving object - def security - @security ||= SecurityClient.new(self) - end - end - end -end diff --git a/lib/opensearch/api/namespace/shutdown.rb b/lib/opensearch/api/namespace/shutdown.rb deleted file mode 100644 index 414e604b8..000000000 --- a/lib/opensearch/api/namespace/shutdown.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Shutdown - module Actions; end - - # Client for the "shutdown" namespace (includes the {Shutdown::Actions} methods) - # - class ShutdownClient - include Shutdown::Actions - include Common::Client::Base - include Common::Client - end - - # Proxy method for {ShutdownClient}, available in the receiving object - # - def shutdown - @shutdown ||= ShutdownClient.new(self) - end - end - end -end diff --git a/lib/opensearch/api/namespace/snapshot.rb b/lib/opensearch/api/namespace/snapshot.rb deleted file mode 100644 index 658706646..000000000 --- a/lib/opensearch/api/namespace/snapshot.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Snapshot - module Actions; end - - # Client for the "snapshot" namespace (includes the {Snapshot::Actions} methods) - # - class SnapshotClient - include Snapshot::Actions - include Common::Client::Base - include Common::Client - end - - # Proxy method for {SnapshotClient}, available in the receiving object - # - def snapshot - @snapshot ||= SnapshotClient.new(self) - end - end - end -end diff --git a/lib/opensearch/api/namespace/tasks.rb b/lib/opensearch/api/namespace/tasks.rb deleted file mode 100644 index 61535c6da..000000000 --- a/lib/opensearch/api/namespace/tasks.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Tasks - module Actions; end - - # Client for the "tasks" namespace (includes the {Tasks::Actions} methods) - # - class TasksClient - include Tasks::Actions - include Common::Client::Base - include Common::Client - end - - # Proxy method for {TasksClient}, available in the receiving object - # - def tasks - @tasks ||= TasksClient.new(self) - end - end - end -end diff --git a/lib/opensearch/api/utils.rb b/lib/opensearch/api/utils.rb index 4eb20f68c..12a82d891 100644 --- a/lib/opensearch/api/utils.rb +++ b/lib/opensearch/api/utils.rb @@ -3,90 +3,46 @@ # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. + +# This file is generated from the OpenSearch REST API spec. +# Do not modify it by hand. Instead, modify the generator or the spec + +# frozen_string_literal: true + +require 'cgi' module OpenSearch module API - # Generic utility methods - # module Utils - # URL-escape a string - # - # @example - # __escape('foo/bar') # => 'foo%2Fbar' - # __escape('bar^bam') # => 'bar%5Ebam' - # - # @api private - def __escape(string) - return string if string == '*' - - CGI.escape(string.to_s) + NON_URL_ARGS = Set.new(%w[body headers ignore]).freeze + BULK_OPERATIONS = Set.new(%w[index create delete update]).freeze + + # @return a new hash with all keys converted to strings and url param values escaped + # @param [Hash] args + def self.normalize_arguments(args) + args.each_with_object({}) do |(k, v), acc| + k = k.to_s + acc[k] = NON_URL_ARGS.include?(k) ? v : normalize_value(v) + end end - # Create a "list" of values from arguments, ignoring nil values and encoding special characters. - # - # @example Create a list from array - # __listify(['A','B']) # => 'A,B' - # - # @example Create a list from arguments - # __listify('A','B') # => 'A,B' - # - # @example Escape values - # __listify('foo','bar^bam') # => 'foo,bar%5Ebam' - # - # @example Do not escape the values - # __listify('foo','bar^bam', escape: false) # => 'foo,bar^bam' - # - # @api private - def __listify(*list) - options = list.last.is_a?(Hash) ? list.pop : {} - - escape = options[:escape] - Array(list) - .flat_map { |e| e.respond_to?(:split) ? e.split(',') : e } - .flatten - .compact - .map { |e| escape == false ? e : __escape(e) } - .join(',') + # @param [Hash] params the query params to validate + # @param [Set] valid_param_names the list of valid params names for the api method + def self.validate_query_params(params, valid_param_names = nil) + return if OpenSearch::API.settings[:skip_parameter_validation] + params.each_key do |k| + next if valid_param_names&.include?(k) + next if GLOBAL_QUERY_PARAMS.include?(k) + raise ArgumentError, "URL parameter '#{k}' is not supported" + end end - # Create a path (URL part) from arguments, ignoring nil values and empty strings. - # - # @example Create a path from array - # __pathify(['foo', '', nil, 'bar']) # => 'foo/bar' - # - # @example Create a path from arguments - # __pathify('foo', '', nil, 'bar') # => 'foo/bar' - # - # # @example Encode special characters - # __pathify(['foo', 'bar^bam']) # => 'foo/bar%5Ebam' - # - # @api private - def __pathify(*segments) - Array(segments).flatten - .compact - .reject { |s| s.to_s.strip.empty? } - .join('/') - .squeeze('/') + # @return the value escaped for URL unless it is a Hash + def self.normalize_value(value) + return value if value.is_a? Hash + value = value.to_s.strip unless value.is_a? Enumerable + value = value.split(',') if value.is_a? String + value.map { |v| CGI.escape(v.to_s) }.join(',') end # Convert an array of payloads into OpenSearch `header\ndata` format @@ -104,13 +60,13 @@ def __pathify(*segments) # # => {"title":"Test"} # # => {"update":{"_index":"myindexB","_id":"2"}} # # => {"doc":{"title":"Update"}} - # - def __bulkify(payload) - operations = %w[index create delete update] + # TODO: refactor this method to be more readable + def self.bulkify(payload) + return payload unless payload.is_a?(Array) # Hashes with `:data` if payload.any? do |d| - d.is_a?(Hash) && d.values.first.is_a?(Hash) && operations.include?(d.keys.first.to_s) && (d.values.first[:data] || d.values.first['data']) + d.is_a?(Hash) && d.values.first.is_a?(Hash) && BULK_OPERATIONS.include?(d.keys.first.to_s) && (d.values.first[:data] || d.values.first['data']) end payload = payload .each_with_object([]) do |item, sum| @@ -134,163 +90,8 @@ def __bulkify(payload) payload << '' end - payload = payload.join("\n") - end - - # Validates the argument Hash against common and valid API parameters - # - # @param arguments [Hash] Hash of arguments to verify and extract, **with symbolized keys** - # @param valid_params [Array] An array of symbols with valid keys - # - # @return [Hash] Return whitelisted Hash - # @raise [ArgumentError] If the arguments Hash contains invalid keys - # - # @example Extract parameters - # __validate_and_extract_params( { :foo => 'qux' }, [:foo, :bar] ) - # # => { :foo => 'qux' } - # - # @example Raise an exception for invalid parameters - # __validate_and_extract_params( { :foo => 'qux', :bam => 'mux' }, [:foo, :bar] ) - # # ArgumentError: "URL parameter 'bam' is not supported" - # - # @example Skip validating parameters - # __validate_and_extract_params( { :foo => 'q', :bam => 'm' }, [:foo, :bar], { skip_parameter_validation: true } ) - # # => { :foo => "q", :bam => "m" } - # - # @example Skip validating parameters when the module setting is set - # OpenSearch::API.settings[:skip_parameter_validation] = true - # __validate_and_extract_params( { :foo => 'q', :bam => 'm' }, [:foo, :bar] ) - # # => { :foo => "q", :bam => "m" } - # - # @api private - # - def __validate_and_extract_params(arguments, params = [], options = {}) - if options[:skip_parameter_validation] || OpenSearch::API.settings[:skip_parameter_validation] - arguments - else - __validate_params(arguments, params) - __extract_params(arguments, params, options.merge(escape: false)) - end - end - - def __validate_params(arguments, valid_params = []) - arguments.each do |k, _v| - raise ArgumentError, "URL parameter '#{k}' is not supported" \ - unless COMMON_PARAMS.include?(k) || COMMON_QUERY_PARAMS.include?(k) || valid_params.include?(k) - end + payload.join("\n") end - - def __extract_params(arguments, params = [], options = {}) - result = arguments.select { |k, _v| COMMON_QUERY_PARAMS.include?(k) || params.include?(k) } - result = result.to_h unless result.is_a?(Hash) # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour - result.map { |k, v| v.is_a?(Array) ? [k, __listify(v, options)] : [k, v] }.to_h # Listify Arrays - end - - # Extracts the valid parts of the URL from the arguments - # - # @note Mutates the `arguments` argument, to prevent failures in `__validate_and_extract_params`. - # - # @param arguments [Hash] Hash of arguments to verify and extract, **with symbolized keys** - # @param valid_parts [Array] An array of symbol with valid keys - # - # @return [Array] Valid parts of the URL as an array of strings - # - # @example Extract parts - # __extract_parts { :foo => true }, [:foo, :bar] - # # => [:foo] - # - # - # @api private - # - def __extract_parts(arguments, valid_parts = []) - parts = arguments.select { |k, _v| valid_parts.include?(k) }.to_h - parts = parts.reduce([]) do |sum, item| - k, v = item - sum << (v.is_a?(TrueClass) ? k.to_s : v) - end - - arguments.delete_if { |k, _v| valid_parts.include? k } - parts - end - - # Calls the given block, rescuing from `StandardError`. - # - # Primary use case is the `:ignore` parameter for API calls. - # - # Returns `false` if exception contains NotFound in its class name or message, - # else re-raises the exception. - # - # @yield [block] A block of code to be executed with exception handling. - # - # @api private - # - def __rescue_from_not_found - yield - rescue StandardError => e - raise e unless e.class.to_s =~ /NotFound/ || e.message =~ /Not\s*Found/i - false - end - - def __report_unsupported_parameters(arguments, params = []) - messages = [] - unsupported_params = params.select do |d| - d.is_a?(Hash) ? arguments.include?(d.keys.first) : arguments.include?(d) - end - - unsupported_params.each do |param| - name = case param - when Symbol - param - when Hash - param.keys.first - else - raise ArgumentError, 'The param must be a Symbol or a Hash' - end - - explanation = if param.is_a?(Hash) - ". #{param.values.first[:explanation]}." - else - ". This parameter is not supported in the version you're using: #{OpenSearch::VERSION}, and will be removed in the next release." - end - - message = "[!] You are using unsupported parameter [:#{name}]" - - if (source = caller&.last) - message += " in `#{source}`" - end - - message += explanation - - messages << message - end - - return if messages.empty? - - messages << 'Suppress this warning by the `-WO` command line flag.' - - if $stderr.tty? - Kernel.warn messages.map { |m| "\e[31;1m#{m}\e[0m" }.join("\n") - else - Kernel.warn messages.join("\n") - end - end - - def __report_unsupported_method(name) - message = "[!] You are using unsupported method [#{name}]" - if (source = caller&.last) - message += " in `#{source}`" - end - - message += ". This method is not supported in the version you're using: #{OpenSearch::VERSION}, and will be removed in the next release. Suppress this warning by the `-WO` command line flag." - - if $stderr.tty? - Kernel.warn "\e[31;1m#{message}\e[0m" - else - Kernel.warn message - end - end - - extend self end end end diff --git a/lib/opensearch/dsl.rb b/lib/opensearch/dsl.rb index b8083bddd..d1a5504bd 100644 --- a/lib/opensearch/dsl.rb +++ b/lib/opensearch/dsl.rb @@ -36,9 +36,9 @@ require 'opensearch/dsl/search/options' require 'opensearch/dsl/search/suggest' -Dir[File.expand_path('dsl/search/queries/**/*.rb', __dir__)].sort.each { |f| require f } -Dir[File.expand_path('dsl/search/filters/**/*.rb', __dir__)].sort.each { |f| require f } -Dir[File.expand_path('dsl/search/aggregations/**/*.rb', __dir__)].sort.each { |f| require f } +Dir[File.expand_path('dsl/search/queries/**/*.rb', __dir__)].each { |f| require f } +Dir[File.expand_path('dsl/search/filters/**/*.rb', __dir__)].each { |f| require f } +Dir[File.expand_path('dsl/search/aggregations/**/*.rb', __dir__)].each { |f| require f } require 'opensearch/dsl/search' diff --git a/lib/opensearch/dsl/search.rb b/lib/opensearch/dsl/search.rb index 987820582..e3cac62e9 100644 --- a/lib/opensearch/dsl/search.rb +++ b/lib/opensearch/dsl/search.rb @@ -51,8 +51,8 @@ module Search # # => {:query=>{:match=>{:title=>"test"}}} # # - def search(*args, &block) - Search.new(*args, &block) + def search(...) + Search.new(...) end extend self diff --git a/lib/opensearch/transport/client.rb b/lib/opensearch/transport/client.rb index ee4b60af2..b06efd845 100644 --- a/lib/opensearch/transport/client.rb +++ b/lib/opensearch/transport/client.rb @@ -180,7 +180,6 @@ def initialize(arguments = {}, &block) end # Performs a request through delegation to {#transport}. - # def perform_request(method, path, params = {}, body = nil, headers = nil) method = @send_get_body_as if method == 'GET' && body if (opaque_id = params.delete(:opaque_id)) @@ -191,6 +190,32 @@ def perform_request(method, path, params = {}, body = nil, headers = nil) transport.perform_request(method, path, params, body, headers) end + def perform_ping_request(*args) + perform_request(*args).status == 200 + rescue StandardError => e + return false if e.class.to_s =~ /NotFound|ConnectionFailed/ + return false if e.message =~ /Not *Found|404|ConnectionFailed/i + raise e + end + + def perform_head_request(*args) + perform_request(*args).status == 200 + rescue StandardError => e + return false if e.class.to_s =~ /NotFound/ + return false if e.message =~ /Not\s*Found/i + raise e + end + + def perform_delete_request(*args, ignore404) + perform_request(*args).body + rescue StandardError => e + if ignore404 + return false if e.class.to_s =~ /NotFound/ + return false if e.message =~ /Not\s*Found/i + end + raise e + end + private def set_api_key diff --git a/lib/opensearch/transport/transport/http/faraday.rb b/lib/opensearch/transport/transport/http/faraday.rb index 3ceb97e47..16f21c138 100644 --- a/lib/opensearch/transport/transport/http/faraday.rb +++ b/lib/opensearch/transport/transport/http/faraday.rb @@ -24,6 +24,8 @@ # specific language governing permissions and limitations # under the License. +require 'opensearch/version' + module OpenSearch module Transport module Transport @@ -91,7 +93,7 @@ def user_agent_header(client) meta << "#{RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase} #{RbConfig::CONFIG['target_cpu']}" end meta << client.headers[USER_AGENT_STR].to_s - "opensearch-ruby/#{VERSION} (#{meta.join('; ')})" + "opensearch-ruby/#{OpenSearch::VERSION} (#{meta.join('; ')})" end end end diff --git a/lib/opensearch/version.rb b/lib/opensearch/version.rb index d67c59d14..071541299 100644 --- a/lib/opensearch/version.rb +++ b/lib/opensearch/version.rb @@ -25,5 +25,5 @@ # under the License. module OpenSearch - VERSION = '3.4.0'.freeze + VERSION = '4.0.0'.freeze end diff --git a/opensearch-ruby.gemspec b/opensearch-ruby.gemspec index f86f69800..0849ee1da 100644 --- a/opensearch-ruby.gemspec +++ b/opensearch-ruby.gemspec @@ -62,8 +62,9 @@ Gem::Specification.new do |s| s.cert_chain = ['.github/opensearch-rubygems.pem'] end - s.required_ruby_version = '>= 2.5' + s.required_ruby_version = '>= 3.0' + s.add_dependency 'activesupport' s.add_dependency 'faraday', '>= 1.0', '< 3' s.add_dependency 'multi_json', '>= 1.0' end diff --git a/spec/opensearch/api/actions/abort_benchmark_spec.rb b/spec/opensearch/api/actions/abort_benchmark_spec.rb deleted file mode 100644 index 6ec449d8e..000000000 --- a/spec/opensearch/api/actions/abort_benchmark_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#abort_benchmark' do - let(:expected_args) do - [ - 'POST', - '_bench/abort/foo', - {}, - nil - ] - end - - it 'performs the request' do - expect(client_double.abort_benchmark(name: 'foo')) - end -end diff --git a/spec/opensearch/api/actions/benchmark_spec.rb b/spec/opensearch/api/actions/benchmark_spec.rb deleted file mode 100644 index 4721fbb40..000000000 --- a/spec/opensearch/api/actions/benchmark_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#benchmark' do - let(:expected_args) do - [ - 'PUT', - '_bench', - {}, - { name: 'foo' } - ] - end - - it 'performs the request' do - expect(client_double.benchmark(body: { name: 'foo' })) - end -end diff --git a/spec/opensearch/api/actions/bulk_spec.rb b/spec/opensearch/api/actions/bulk_spec.rb deleted file mode 100644 index 1466de3fa..000000000 --- a/spec/opensearch/api/actions/bulk_spec.rb +++ /dev/null @@ -1,129 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#bulk' do - let(:expected_args) do - [ - 'POST', - url, - params, - body, - headers - ] - end - - let(:headers) { { 'Content-Type' => 'application/x-ndjson' } } - let(:params) { {} } - let(:url) { '_bulk' } - let(:body) { '' } - - context 'when a list of operations is provided' do - let(:body) do - <<-PAYLOAD.gsub(/^\s+/, '') - {"index":{"_index":"myindexA","_id":"1"}} - {"title":"Test"} - {"update":{"_index":"myindexB","_id":"2"}} - {"doc":{"title":"Update"}} - {"delete":{"_index":"myindexC","_id":"3"}} - {"index":{"_index":"myindexD","_id":"1"}} - {"data":"MYDATA"} - PAYLOAD - end - - it 'performs the request' do - expect(client_double.bulk(body: [ - { index: { _index: 'myindexA', _id: '1', data: { title: 'Test' } } }, - { update: { _index: 'myindexB', _id: '2', data: { doc: { title: 'Update' } } } }, - { delete: { _index: 'myindexC', _id: '3' } }, - { index: { _index: 'myindexD', _id: '1', data: { data: 'MYDATA' } } } - ])).to eq({}) - end - end - - context 'when an index is specified' do - let(:url) { 'myindex/_bulk' } - - it 'performs the request' do - expect(client_double.bulk(index: 'myindex', body: [])).to eq({}) - end - end - - context 'when there are data keys in the head/data payloads' do - let(:body) do - <<-PAYLOAD.gsub(/^\s+/, '') - {"update":{"_index":"myindex","_id":"1"}} - {"doc":{"data":{"title":"Update"}}} - PAYLOAD - end - - it 'performs the request' do - expect(client_double.bulk(body: [{ update: { _index: 'myindex', _id: '1' } }, - { doc: { data: { title: 'Update' } } }])).to eq({}) - end - end - - context 'when the payload is a string' do - let(:body) do - 'foo\nbar' - end - - it 'performs the request' do - expect(client_double.bulk(body: 'foo\nbar')).to eq({}) - end - end - - context 'when the payload is an array of Strings' do - let(:body) do - "foo\nbar\n" - end - - it 'performs the request' do - expect(client_double.bulk(body: %w[foo bar])).to eq({}) - end - end - - context 'when there are parameters' do - let(:params) do - { refresh: true } - end - - it 'performs the request' do - expect(client_double.bulk(refresh: true, body: [])).to eq({}) - end - end - - context 'when url characters need to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_bulk' - end - - it 'performs the request' do - expect(client_double.bulk(index: 'foo^bar', body: [])).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/cat/aliases_spec.rb b/spec/opensearch/api/actions/cat/aliases_spec.rb deleted file mode 100644 index f5ffbcbc4..000000000 --- a/spec/opensearch/api/actions/cat/aliases_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#aliases' do - let(:expected_args) do - [ - 'GET', - '_cat/aliases', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.aliases).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/all_pit_segments_spec.rb b/spec/opensearch/api/actions/cat/all_pit_segments_spec.rb deleted file mode 100644 index c460609c1..000000000 --- a/spec/opensearch/api/actions/cat/all_pit_segments_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. - -require_relative '../../../../spec_helper' - -describe 'client.cat#all_pit_segments' do - let(:expected_args) do - [ - 'GET', - '_cat/pit_segments/_all', - {}, - nil, - {} - ] - end - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'does not accept unregistered params' do - expect do - client.cat.all_pit_segments(something: :else) - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.cat.all_pit_segments).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/allocation_spec.rb b/spec/opensearch/api/actions/cat/allocation_spec.rb deleted file mode 100644 index 67525a77a..000000000 --- a/spec/opensearch/api/actions/cat/allocation_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#allocation' do - let(:expected_args) do - [ - 'GET', - '_cat/allocation', - { cluster_manager_timeout: 2 }, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.allocation(cluster_manager_timeout: 2)).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/cluster_manager_spec.rb b/spec/opensearch/api/actions/cat/cluster_manager_spec.rb deleted file mode 100644 index 0696ee51c..000000000 --- a/spec/opensearch/api/actions/cat/cluster_manager_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. - -require_relative '../../../../spec_helper' - -describe 'client.cat#cluster_manager' do - let(:expected_args) do - [ - 'GET', - '_cat/cluster_manager', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.cluster_manager).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/count_spec.rb b/spec/opensearch/api/actions/cat/count_spec.rb deleted file mode 100644 index 3bf31208a..000000000 --- a/spec/opensearch/api/actions/cat/count_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#count' do - let(:expected_args) do - [ - 'GET', - '_cat/count', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.count).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/fielddata_spec.rb b/spec/opensearch/api/actions/cat/fielddata_spec.rb deleted file mode 100644 index bbb89c131..000000000 --- a/spec/opensearch/api/actions/cat/fielddata_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#fielddata' do - let(:expected_args) do - [ - 'GET', - '_cat/fielddata', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.fielddata).to eq({}) - end - - context 'when field are specified' do - let(:expected_args) do - [ - 'GET', - '_cat/fielddata/foo,bar', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.fielddata(fields: %w[foo bar])).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/cat/health_spec.rb b/spec/opensearch/api/actions/cat/health_spec.rb deleted file mode 100644 index 3e6767132..000000000 --- a/spec/opensearch/api/actions/cat/health_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#health' do - let(:expected_args) do - [ - 'GET', - '_cat/health', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.health).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/help_spec.rb b/spec/opensearch/api/actions/cat/help_spec.rb deleted file mode 100644 index 44fc666bd..000000000 --- a/spec/opensearch/api/actions/cat/help_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#help' do - let(:expected_args) do - [ - 'GET', - '_cat', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.help).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/indices_spec.rb b/spec/opensearch/api/actions/cat/indices_spec.rb deleted file mode 100644 index 420a9f3a1..000000000 --- a/spec/opensearch/api/actions/cat/indices_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#indices' do - let(:expected_args) do - [ - 'GET', - '_cat/indices', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.indices).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/master_spec.rb b/spec/opensearch/api/actions/cat/master_spec.rb deleted file mode 100644 index ce55f1eae..000000000 --- a/spec/opensearch/api/actions/cat/master_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#master' do - let(:expected_args) do - [ - 'GET', - '_cat/master', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.master).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/nodeattrs_spec.rb b/spec/opensearch/api/actions/cat/nodeattrs_spec.rb deleted file mode 100644 index d59bade8b..000000000 --- a/spec/opensearch/api/actions/cat/nodeattrs_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#nodeattrs' do - let(:expected_args) do - [ - 'GET', - '_cat/nodeattrs', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.nodeattrs).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/nodes_spec.rb b/spec/opensearch/api/actions/cat/nodes_spec.rb deleted file mode 100644 index b7b7e1648..000000000 --- a/spec/opensearch/api/actions/cat/nodes_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#nodes' do - let(:expected_args) do - [ - 'GET', - '_cat/nodes', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.nodes).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/pending_tasks_spec.rb b/spec/opensearch/api/actions/cat/pending_tasks_spec.rb deleted file mode 100644 index f321d063e..000000000 --- a/spec/opensearch/api/actions/cat/pending_tasks_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#pending_tasks' do - let(:expected_args) do - [ - 'GET', - '_cat/pending_tasks', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.pending_tasks).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/pit_segments_spec.rb b/spec/opensearch/api/actions/cat/pit_segments_spec.rb deleted file mode 100644 index a51a7771b..000000000 --- a/spec/opensearch/api/actions/cat/pit_segments_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. - -require_relative '../../../../spec_helper' - -describe 'client.cat#pit_segments' do - let(:expected_args) do - [ - 'GET', - '_cat/pit_segments', - {}, - { pit_id: ['abc'] }, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.cat.pit_segments - end.to raise_exception(ArgumentError) - end - - it 'does not accept unregistered params' do - expect do - client.cat.pit_segments(body: {}, something: :else) - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.cat.pit_segments(body: { pit_id: ['abc'] })).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/plugins_spec.rb b/spec/opensearch/api/actions/cat/plugins_spec.rb deleted file mode 100644 index 391e4e308..000000000 --- a/spec/opensearch/api/actions/cat/plugins_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#plugins' do - let(:expected_args) do - [ - 'GET', - '_cat/plugins', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.plugins).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/recovery_spec.rb b/spec/opensearch/api/actions/cat/recovery_spec.rb deleted file mode 100644 index 59b3fa67e..000000000 --- a/spec/opensearch/api/actions/cat/recovery_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#recovery' do - let(:expected_args) do - [ - 'GET', - '_cat/recovery', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.recovery).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/repositories_spec.rb b/spec/opensearch/api/actions/cat/repositories_spec.rb deleted file mode 100644 index 80201bd0e..000000000 --- a/spec/opensearch/api/actions/cat/repositories_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#repositories' do - let(:expected_args) do - [ - 'GET', - '_cat/repositories', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.repositories).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/segments_spec.rb b/spec/opensearch/api/actions/cat/segments_spec.rb deleted file mode 100644 index 7497a75ee..000000000 --- a/spec/opensearch/api/actions/cat/segments_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#segments' do - let(:expected_args) do - [ - 'GET', - url, - {}, - nil, - {} - ] - end - - let(:url) do - '_cat/segments' - end - - it 'performs the request' do - expect(client_double.cat.segments).to eq({}) - end - - context 'when index is specified' do - let(:url) do - '_cat/segments/foo' - end - - it 'performs the request' do - expect(client_double.cat.segments(index: 'foo')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/cat/shards_spec.rb b/spec/opensearch/api/actions/cat/shards_spec.rb deleted file mode 100644 index 2d3f1b4bd..000000000 --- a/spec/opensearch/api/actions/cat/shards_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#shards' do - let(:expected_args) do - [ - 'GET', - '_cat/shards', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.shards).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/snapshot_spec.rb b/spec/opensearch/api/actions/cat/snapshot_spec.rb deleted file mode 100644 index b600498fd..000000000 --- a/spec/opensearch/api/actions/cat/snapshot_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#snapshots' do - let(:expected_args) do - [ - 'GET', - '_cat/snapshots/foo', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.snapshots(repository: 'foo')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/tasks_spec.rb b/spec/opensearch/api/actions/cat/tasks_spec.rb deleted file mode 100644 index bfc4807c2..000000000 --- a/spec/opensearch/api/actions/cat/tasks_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#tasks' do - let(:expected_args) do - [ - 'GET', - '_cat/tasks', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.tasks).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/templates_spec.rb b/spec/opensearch/api/actions/cat/templates_spec.rb deleted file mode 100644 index 87091ac04..000000000 --- a/spec/opensearch/api/actions/cat/templates_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#templates' do - let(:expected_args) do - [ - 'GET', - '_cat/templates', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.templates).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cat/thread_pool_spec.rb b/spec/opensearch/api/actions/cat/thread_pool_spec.rb deleted file mode 100644 index a2acc8883..000000000 --- a/spec/opensearch/api/actions/cat/thread_pool_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cat#thread_pool' do - let(:expected_args) do - [ - 'GET', - '_cat/thread_pool', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cat.thread_pool).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/clear_scroll_spec.rb b/spec/opensearch/api/actions/clear_scroll_spec.rb deleted file mode 100644 index 42f8f0386..000000000 --- a/spec/opensearch/api/actions/clear_scroll_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#clear_scroll' do - let(:expected_args) do - [ - 'DELETE', - '_search/scroll/abc123', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.clear_scroll(scroll_id: 'abc123')).to eq({}) - end - - context 'when a list of scroll ids is provided' do - let(:expected_args) do - [ - 'DELETE', - '_search/scroll/abc123,def456', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.clear_scroll(scroll_id: %w[abc123 def456])).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/cluster/allocation_explain_spec.rb b/spec/opensearch/api/actions/cluster/allocation_explain_spec.rb deleted file mode 100644 index c2ba73278..000000000 --- a/spec/opensearch/api/actions/cluster/allocation_explain_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#allocation_explain' do - let(:expected_args) do - [ - 'GET', - '_cluster/allocation/explain', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cluster.allocation_explain).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cluster/get_settings_spec.rb b/spec/opensearch/api/actions/cluster/get_settings_spec.rb deleted file mode 100644 index 0aff2b03c..000000000 --- a/spec/opensearch/api/actions/cluster/get_settings_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#get_settings' do - let(:expected_args) do - [ - 'GET', - '_cluster/settings', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cluster.get_settings).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cluster/health_spec.rb b/spec/opensearch/api/actions/cluster/health_spec.rb deleted file mode 100644 index afbc458a9..000000000 --- a/spec/opensearch/api/actions/cluster/health_spec.rb +++ /dev/null @@ -1,75 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#health' do - let(:expected_args) do - [ - 'GET', - '_cluster/health', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cluster.health).to eq({}) - end - - context 'when a level is specified' do - let(:expected_args) do - [ - 'GET', - '_cluster/health', - { level: 'indices' }, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cluster.health(level: 'indices')).to eq({}) - end - end - - context 'when an index is specified' do - let(:expected_args) do - [ - 'GET', - '_cluster/health/foo', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cluster.health(index: 'foo')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/cluster/pending_tasks_spec.rb b/spec/opensearch/api/actions/cluster/pending_tasks_spec.rb deleted file mode 100644 index a7b251af1..000000000 --- a/spec/opensearch/api/actions/cluster/pending_tasks_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#pending_tasks' do - let(:expected_args) do - [ - 'GET', - '_cluster/pending_tasks', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cluster.pending_tasks).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cluster/put_settings_spec.rb b/spec/opensearch/api/actions/cluster/put_settings_spec.rb deleted file mode 100644 index 277352ac0..000000000 --- a/spec/opensearch/api/actions/cluster/put_settings_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#put_settings' do - let(:expected_args) do - [ - 'PUT', - '_cluster/settings', - {}, - {}, - {} - ] - end - - it 'performs the request' do - expect(client_double.cluster.put_settings(body: {})).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cluster/remote_info_spec.rb b/spec/opensearch/api/actions/cluster/remote_info_spec.rb deleted file mode 100644 index a7842da4d..000000000 --- a/spec/opensearch/api/actions/cluster/remote_info_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#remote_info' do - let(:expected_args) do - [ - 'GET', - '_remote/info', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cluster.remote_info).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/cluster/reroute_spec.rb b/spec/opensearch/api/actions/cluster/reroute_spec.rb deleted file mode 100644 index 1bd27b9b3..000000000 --- a/spec/opensearch/api/actions/cluster/reroute_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#reroute' do - let(:expected_args) do - [ - 'POST', - '_cluster/reroute', - {}, - {}, - {} - ] - end - - it 'performs the request' do - expect(client_double.cluster.reroute).to eq({}) - end - - context 'when a body is specified' do - let(:expected_args) do - [ - 'POST', - '_cluster/reroute', - {}, - { commands: [move: { index: 'myindex', shard: 0 }] }, - {} - ] - end - - it 'performs the request' do - expect(client_double.cluster.reroute(body: { commands: [move: { index: 'myindex', shard: 0 }] })).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/cluster/state_spec.rb b/spec/opensearch/api/actions/cluster/state_spec.rb deleted file mode 100644 index 7316b0670..000000000 --- a/spec/opensearch/api/actions/cluster/state_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#state' do - let(:expected_args) do - [ - 'GET', - '_cluster/state', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cluster.state).to eq({}) - end - - context 'when a metric is specified' do - let(:expected_args) do - [ - 'GET', - '_cluster/state/foo,bar', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cluster.state(metric: %w[foo bar])).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/cluster/stats_spec.rb b/spec/opensearch/api/actions/cluster/stats_spec.rb deleted file mode 100644 index 2df2f7bc7..000000000 --- a/spec/opensearch/api/actions/cluster/stats_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#stats' do - let(:expected_args) do - [ - 'GET', - '_cluster/stats', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cluster.stats).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/count_spec.rb b/spec/opensearch/api/actions/count_spec.rb deleted file mode 100644 index 48419d830..000000000 --- a/spec/opensearch/api/actions/count_spec.rb +++ /dev/null @@ -1,75 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#count' do - let(:expected_args) do - [ - 'POST', - '_count', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.count).to eq({}) - end - - context 'when an index is specified' do - let(:expected_args) do - [ - 'POST', - 'foo,bar/_count', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.count(index: %w[foo bar])).to eq({}) - end - end - - context 'when there is a query provided' do - let(:expected_args) do - [ - 'POST', - '_count', - {}, - { match: { foo: 'bar' } }, - {} - ] - end - - it 'performs the request' do - expect(client_double.count(body: { match: { foo: 'bar' } })).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/create_document_spec.rb b/spec/opensearch/api/actions/create_document_spec.rb deleted file mode 100644 index b1c0413a1..000000000 --- a/spec/opensearch/api/actions/create_document_spec.rb +++ /dev/null @@ -1,91 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#create_document' do - let(:expected_args) do - [ - 'PUT', - 'foo/_doc/123', - { op_type: 'create' }, - { foo: 'bar' }, - {} - ] - end - - it 'performs the request' do - expect(client_double.create(index: 'foo', id: '123', body: { foo: 'bar' })).to eq({}) - end - - context 'when the request needs to be URL-escaped' do - let(:expected_args) do - [ - 'PUT', - 'foo%5Ebar/_doc/123', - { op_type: 'create' }, - {}, - {} - ] - end - - it 'performs the request' do - expect(client_double.create(index: 'foo^bar', id: '123', body: {})).to eq({}) - end - end - - context 'when an id is provided as an integer' do - let(:expected_args) do - [ - 'PUT', - 'foo/_doc/1', - { op_type: 'create' }, - { foo: 'bar' }, - {} - ] - end - - it 'updates the arguments with the `op_type`' do - expect(client_double.create(index: 'foo', id: 1, body: { foo: 'bar' })).to eq({}) - end - end - - context 'when an id is not provided' do - let(:expected_args) do - [ - 'POST', - 'foo/_doc', - {}, - { foo: 'bar' }, - {} - ] - end - - it 'updates the arguments with the `op_type`' do - expect(client_double.create(index: 'foo', body: { foo: 'bar' })).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/create_pit_spec.rb b/spec/opensearch/api/actions/create_pit_spec.rb deleted file mode 100644 index c4979fd35..000000000 --- a/spec/opensearch/api/actions/create_pit_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. - -require_relative '../../../spec_helper' - -describe 'client#create_pit' do - let(:expected_args) do - [ - 'POST', - 'movies,books/_search/point_in_time', - { keep_alive: '1m', - preference: :random, - routing: :route, - expand_wildcards: :open, - allow_partial_pit_creation: false }, - nil - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :index argument' do - expect do - client.create_pit(keep_alive: '1m') - end.to raise_exception(ArgumentError) - end - - it 'requires the :index argument' do - expect do - client.create_pit(index: 'movies') - end.to raise_exception(ArgumentError) - end - - it 'does not accept unregistered params' do - expect do - client.create_pit(index: 'movies', keep_alive: '1m', something: 42) - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.create_pit( - index: %w[movies books], - keep_alive: '1m', - preference: :random, - routing: :route, - expand_wildcards: :open, - allow_partial_pit_creation: false - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/dangling_indices/delete_dangling_indices_spec.rb b/spec/opensearch/api/actions/dangling_indices/delete_dangling_indices_spec.rb deleted file mode 100644 index 12c704600..000000000 --- a/spec/opensearch/api/actions/dangling_indices/delete_dangling_indices_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'dangling_indices#delete_dangling_index' do - let(:expected_args) do - [ - 'DELETE', - '_dangling/foo', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect( - client_double.dangling_indices.delete_dangling_index(index_uuid: 'foo') - ).to eq({}) - end - - context 'when no index_uuid is specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises the exception' do - expect do - client.dangling_indices.delete_dangling_index - end.to raise_exception(ArgumentError) - end - end -end diff --git a/spec/opensearch/api/actions/dangling_indices/import_dangling_indices_spec.rb b/spec/opensearch/api/actions/dangling_indices/import_dangling_indices_spec.rb deleted file mode 100644 index 5e11b5265..000000000 --- a/spec/opensearch/api/actions/dangling_indices/import_dangling_indices_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'dangling_indices#import_dangling_index' do - let(:expected_args) do - [ - 'POST', - '_dangling/foo', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect( - client_double.dangling_indices.import_dangling_index(index_uuid: 'foo') - ).to eq({}) - end - - context 'when no index_uuid is specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises the exception' do - expect do - client.dangling_indices.delete_dangling_index - end.to raise_exception(ArgumentError) - end - end -end diff --git a/spec/opensearch/api/actions/dangling_indices/list_dangling_indices_spec.rb b/spec/opensearch/api/actions/dangling_indices/list_dangling_indices_spec.rb deleted file mode 100644 index eccf34cef..000000000 --- a/spec/opensearch/api/actions/dangling_indices/list_dangling_indices_spec.rb +++ /dev/null @@ -1,45 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'dangling_indices#list_dangling_index' do - let(:expected_args) do - [ - 'GET', - '_dangling', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect( - client_double.dangling_indices.list_dangling_indices - ).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/delete_all_pits_spec.rb b/spec/opensearch/api/actions/delete_all_pits_spec.rb deleted file mode 100644 index 9c549f0c4..000000000 --- a/spec/opensearch/api/actions/delete_all_pits_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. - -require_relative '../../../spec_helper' - -describe 'client#delete_all_pits' do - let(:expected_args) do - [ - 'DELETE', - '_search/point_in_time/_all', - {}, - nil - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'does not accept unregistered params' do - expect do - client.delete_all_pits(something: :else) - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.delete_all_pits).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/delete_by_query_spec.rb b/spec/opensearch/api/actions/delete_by_query_spec.rb deleted file mode 100644 index 180771fda..000000000 --- a/spec/opensearch/api/actions/delete_by_query_spec.rb +++ /dev/null @@ -1,71 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#delete_by_query' do - let(:expected_args) do - [ - 'POST', - 'foo/_delete_by_query', - {}, - { term: {} }, - {} - ] - end - - it 'requires the :index argument' do - expect do - Class.new { include OpenSearch::API }.new.delete_by_query(body: {}) - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.delete_by_query(index: 'foo', body: { term: {} })).to eq({}) - end - - context 'when a query is provided' do - let(:expected_args) do - [ - 'POST', - 'foo/_delete_by_query', - { q: 'foo:bar' }, - { query: 'query' }, - {} - ] - end - - it 'performs the request' do - expect( - client_double.delete_by_query( - index: 'foo', - q: 'foo:bar', - body: { query: 'query' } - ) - ).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/delete_document_spec.rb b/spec/opensearch/api/actions/delete_document_spec.rb deleted file mode 100644 index b26b5b616..000000000 --- a/spec/opensearch/api/actions/delete_document_spec.rb +++ /dev/null @@ -1,115 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#delete' do - let(:expected_args) do - [ - 'DELETE', - 'foo/_doc/1', - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :index argument' do - expect do - client.delete(id: '1') - end.to raise_exception(ArgumentError) - end - - it 'requires the :id argument' do - expect do - client.delete(index: 'foo') - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.delete(index: 'foo', id: '1')).to eq({}) - end - - context 'when url params are provided' do - let(:params) do - { routing: 'abc123' } - end - - it 'performs the request' do - expect(client_double.delete(index: 'foo', id: '1', routing: 'abc123')).to eq({}) - end - end - - context 'when invalid url params are provided' do - it 'raises an ArgumentError' do - expect do - client.delete(index: 'foo', id: '1', qwertypoiuy: 'asdflkjhg') - end.to raise_exception(ArgumentError) - end - end - - context 'when the url params need to be escaped' do - let(:expected_args) do - [ - 'DELETE', - 'foo%5Ebar/_doc/1', - params, - nil, - {} - ] - end - - it 'escapes the url params' do - expect(client_double.delete(index: 'foo^bar', id: 1)).to eq({}) - end - end - - context 'when the index is not found' do - before do - expect(client).to receive(:perform_request).and_raise(NotFound) - end - - it 'raises the exception' do - expect do - client.delete(index: 'foo', id: 'XXX') - end.to raise_exception(NotFound) - end - - context 'when the :ignore option is provided' do - it 'does not raise the NotFound exception' do - expect(client.delete(index: 'foo', id: 1, ignore: 404)).to be(false) - end - end - end -end diff --git a/spec/opensearch/api/actions/delete_pit_spec.rb b/spec/opensearch/api/actions/delete_pit_spec.rb deleted file mode 100644 index 4b6207ad8..000000000 --- a/spec/opensearch/api/actions/delete_pit_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. - -require_relative '../../../spec_helper' - -describe 'client#delete_pit' do - let(:expected_args) do - [ - 'DELETE', - '_search/point_in_time', - {}, - { pit_id: ['abc'] } - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.delete_pit - end.to raise_exception(ArgumentError) - end - - it 'does not accept unregistered params' do - expect do - client.delete_pit(body: {}, something: :else) - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.delete_pit(body: { pit_id: ['abc'] })).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/delete_script_spec.rb b/spec/opensearch/api/actions/delete_script_spec.rb deleted file mode 100644 index 5c9136a06..000000000 --- a/spec/opensearch/api/actions/delete_script_spec.rb +++ /dev/null @@ -1,45 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#delete_script' do - context 'when lang parameter is not provided' do - let(:expected_args) do - [ - 'DELETE', - '_scripts/foo', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.delete_script(id: 'foo')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/exists_document_spec.rb b/spec/opensearch/api/actions/exists_document_spec.rb deleted file mode 100644 index e5f762a3e..000000000 --- a/spec/opensearch/api/actions/exists_document_spec.rb +++ /dev/null @@ -1,129 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#exists' do - let(:expected_args) do - [ - 'HEAD', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:url) do - 'foo/_doc/1' - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :index argument' do - expect do - client.exists(id: '1') - end.to raise_exception(ArgumentError) - end - - it 'requires the :id argument' do - expect do - client.exists(index: 'foo') - end.to raise_exception(ArgumentError) - end - - context 'when the type parameter is not provided' do - let(:url) do - 'foo/_doc/1' - end - - it 'performs the request' do - expect(client_double.exists(index: 'foo', id: '1')).to be(true) - end - end - - it 'is aliased to a predicated method' do - expect(client_double.exists?(index: 'foo', id: '1')).to be(true) - end - - context 'when URL parameters are provided' do - let(:params) do - { routing: 'abc123' } - end - - it 'passes the parameters' do - expect(client_double.exists(index: 'foo', id: '1', routing: 'abc123')).to be(true) - end - end - - context 'when the request needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_doc/1' - end - - it 'URL-escapes the characters' do - expect(client_double.exists(index: 'foo^bar', id: '1')).to be(true) - end - end - - context 'when the response is 404' do - before do - expect(response_double).to receive(:status).and_return(404) - end - - it 'returns false' do - expect(client_double.exists(index: 'foo', id: '1')).to be(false) - end - end - - context 'when the response is 404 NotFound' do - before do - expect(response_double).to receive(:status).and_raise(StandardError.new('404 NotFound')) - end - - it 'returns false' do - expect(client_double.exists(index: 'foo', id: '1')).to be(false) - end - end - - context 'when there are other errors' do - before do - expect(response_double).to receive(:status).and_raise(StandardError) - end - - it 'raises the error' do - expect do - client_double.exists(index: 'foo', id: '1') - end.to raise_exception(StandardError) - end - end -end diff --git a/spec/opensearch/api/actions/explain_document_spec.rb b/spec/opensearch/api/actions/explain_document_spec.rb deleted file mode 100644 index 7a975b086..000000000 --- a/spec/opensearch/api/actions/explain_document_spec.rb +++ /dev/null @@ -1,108 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#explain' do - let(:expected_args) do - [ - method, - url, - params, - body, - {} - ] - end - - let(:method) { 'POST' } - - let(:params) do - {} - end - - let(:body) do - {} - end - - let(:url) do - 'foo/_explain/1' - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :index argument' do - expect do - client.explain(id: '1') - end.to raise_exception(ArgumentError) - end - - it 'requires the :id argument' do - expect do - client.explain(index: 'foo') - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.explain(index: 'foo', id: 1, body: {})).to eq({}) - end - - context 'when a query is provided' do - let(:method) { 'GET' } - let(:params) do - { q: 'abc123' } - end - - let(:body) do - nil - end - - it 'passes the query' do - expect(client_double.explain(index: 'foo', id: '1', q: 'abc123')).to eq({}) - end - end - - context 'when a query definition is provided' do - let(:body) do - { query: { match: {} } } - end - - it 'passes the query definition' do - expect(client_double.explain(index: 'foo', id: '1', body: { query: { match: {} } })).to eq({}) - end - end - - context 'when the request needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_explain/1' - end - - it 'URL-escapes the parts' do - expect(client_double.explain(index: 'foo^bar', id: '1', body: {})).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/features/get_features_spec.rb b/spec/opensearch/api/actions/features/get_features_spec.rb deleted file mode 100644 index 96e480235..000000000 --- a/spec/opensearch/api/actions/features/get_features_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.features#get_features' do - let(:expected_args) do - [ - 'GET', - '_features', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.features.get_features).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/features/reset_features_spec.rb b/spec/opensearch/api/actions/features/reset_features_spec.rb deleted file mode 100644 index 728f677e2..000000000 --- a/spec/opensearch/api/actions/features/reset_features_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.features#reset_features' do - let(:expected_args) do - [ - 'POST', - '_features/_reset', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.features.reset_features).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/field_caps_spec.rb b/spec/opensearch/api/actions/field_caps_spec.rb deleted file mode 100644 index 270bfd804..000000000 --- a/spec/opensearch/api/actions/field_caps_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#field_caps' do - let(:expected_args) do - [ - 'GET', - 'foo/_field_caps', - { fields: 'bar' }, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.field_caps(index: 'foo', fields: 'bar')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/get_all_pits_spec.rb b/spec/opensearch/api/actions/get_all_pits_spec.rb deleted file mode 100644 index 1d7209fda..000000000 --- a/spec/opensearch/api/actions/get_all_pits_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. - -require_relative '../../../spec_helper' - -describe 'client#get_all_pits' do - let(:expected_args) do - [ - 'GET', - '_search/point_in_time/_all', - {}, - nil - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'does not accept unregistered params' do - expect do - client.get_all_pits(something: :else) - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.get_all_pits).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/get_document_source_spec.rb b/spec/opensearch/api/actions/get_document_source_spec.rb deleted file mode 100644 index 63ed6ac15..000000000 --- a/spec/opensearch/api/actions/get_document_source_spec.rb +++ /dev/null @@ -1,105 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#get_source' do - let(:expected_args) do - [ - 'GET', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:url) do - 'foo/_source/1' - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :index argument' do - expect do - client.get_source(id: '1') - end.to raise_exception(ArgumentError) - end - - it 'requires the :id argument' do - expect do - client.get_source(index: 'foo') - end.to raise_exception(ArgumentError) - end - - context 'when the type parameter is not provided' do - let(:url) do - 'foo/_source/1' - end - - it 'performs the request' do - expect(client_double.get_source(index: 'foo', id: '1')).to eq({}) - end - end - - context 'when URL parameters are provided' do - let(:params) do - { routing: 'abc123' } - end - - it 'Passes the URL params' do - expect(client_double.get_source(index: 'foo', id: '1', routing: 'abc123')).to eq({}) - end - end - - context 'when the request needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_source/1' - end - - it 'URL-escapes the parts' do - expect(client_double.get_source(index: 'foo^bar', id: '1')).to eq({}) - end - end - - context 'when the request raises a NotFound error' do - before do - expect(client).to receive(:perform_request).and_raise(NotFound) - end - - it 'raises the error' do - expect do - client.get_source(index: 'foo', id: '1') - end.to raise_exception(NotFound) - end - end -end diff --git a/spec/opensearch/api/actions/get_document_spec.rb b/spec/opensearch/api/actions/get_document_spec.rb deleted file mode 100644 index bfcce23e7..000000000 --- a/spec/opensearch/api/actions/get_document_spec.rb +++ /dev/null @@ -1,125 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#get' do - let(:expected_args) do - [ - 'GET', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:url) do - 'foo/_doc/1' - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :index argument' do - expect do - client.get(id: '1') - end.to raise_exception(ArgumentError) - end - - it 'requires the :id argument' do - expect do - client.get(index: 'foo') - end.to raise_exception(ArgumentError) - end - - context 'when the type parameter is not provided' do - let(:url) do - 'foo/_doc/1' - end - - it 'performs the request' do - expect(client_double.get(index: 'foo', id: '1')).to eq({}) - end - end - - context 'when URL parameters are provided' do - let(:params) do - { routing: 'abc123' } - end - - it 'Passes the URL params' do - expect(client_double.get(index: 'foo', id: '1', routing: 'abc123')).to eq({}) - end - end - - context 'when invalid URL parameters are provided' do - it 'Passes the URL params' do - expect do - client.get(index: 'foo', id: '1', qwert: 'abc123') - end.to raise_exception(ArgumentError) - end - end - - context 'when the request needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_doc/1' - end - - it 'URL-escapes the parts' do - expect(client_double.get(index: 'foo^bar', id: '1')).to eq({}) - end - end - - context 'when the request raises a NotFound error' do - before do - expect(client).to receive(:perform_request).and_raise(NotFound) - end - - it 'raises an exception' do - expect do - client.get(index: 'foo', id: '1') - end.to raise_exception(NotFound) - end - - context 'when the ignore option is provided' do - context 'when the response is 404' do - let(:params) do - { ignore: 404 } - end - - it 'returns false' do - expect(client.get(index: 'foo', id: '1', ignore: 404)).to be(false) - end - end - end - end -end diff --git a/spec/opensearch/api/actions/get_script_spec.rb b/spec/opensearch/api/actions/get_script_spec.rb deleted file mode 100644 index 5a23d6a2b..000000000 --- a/spec/opensearch/api/actions/get_script_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#get_script' do - let(:expected_args) do - [ - 'GET', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:url) do - '_scripts/foo' - end - - context 'when the `lang` parameter is specificed' do - let(:params) do - { cluster_manager_timeout: '1s' } - end - - it 'performs the request' do - expect(client_double.get_script(cluster_manager_timeout: '1s', id: 'foo')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/hashie_spec.rb b/spec/opensearch/api/actions/hashie_spec.rb deleted file mode 100644 index 7c4633b55..000000000 --- a/spec/opensearch/api/actions/hashie_spec.rb +++ /dev/null @@ -1,95 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' -require 'hashie' - -describe 'Hashie' do - let(:json) do - <<-JSON - { - "took": 14, - "timed_out": false, - "_shards": { - "total": 1, - "successful": 1, - "failed": 0 - }, - "hits": { - "total": 5, - "max_score": 0.51104903, - "hits": [ - { - "_index": "myindex", - "_id": "1", - "_score": 0.51104903, - "_source": { - "title": "Test 1", - "tags": [ - "y", - "z" - ], - "published": true, - "published_at": "2013-06-22T21:13:00Z", - "counter": 1 - } - } - ] - }, - "facets": { - "tags": { - "missing": 0, - "total": 10, - "other": 0, - "terms": [ - { - "term": "z", - "count": 4 - }, - { - "term": "y", - "count": 3 - }, - { - "term": "x", - "count": 3 - } - ] - } - } - } - JSON - end - - let(:response) do - Hashie::Mash.new MultiJson.load(json) - end - - it 'wraps the response' do - expect(response.hits.hits.first._source.title).to eq('Test 1') - expect(response.facets.tags.terms.first.term).to eq('z') - end -end diff --git a/spec/opensearch/api/actions/http/connect_spec.rb b/spec/opensearch/api/actions/http/connect_spec.rb deleted file mode 100644 index 94fbfeb30..000000000 --- a/spec/opensearch/api/actions/http/connect_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.http#connect' do - let(:expected_args) do - [ - 'CONNECT', - 'some/api', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.http.connect('some/api')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/http/delete_spec.rb b/spec/opensearch/api/actions/http/delete_spec.rb deleted file mode 100644 index 0f152a524..000000000 --- a/spec/opensearch/api/actions/http/delete_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.http#delete' do - let(:expected_args) do - [ - 'DELETE', - 'books', - {}, - nil, - { foo: :bar } - ] - end - - it 'performs the request' do - expect(client_double.http.delete('books', headers: { foo: :bar })).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/http/get_spec.rb b/spec/opensearch/api/actions/http/get_spec.rb deleted file mode 100644 index debbf5a5d..000000000 --- a/spec/opensearch/api/actions/http/get_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.http#get' do - let(:expected_args) do - [ - 'GET', - '_cat/indices', - { v: true }, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.http.get('_cat/indices', params: { v: true })).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/http/head_spec.rb b/spec/opensearch/api/actions/http/head_spec.rb deleted file mode 100644 index f545842a3..000000000 --- a/spec/opensearch/api/actions/http/head_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.http#head' do - let(:expected_args) do - [ - 'HEAD', - 'books', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.http.head('books')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/http/options_spec.rb b/spec/opensearch/api/actions/http/options_spec.rb deleted file mode 100644 index 78f05fe57..000000000 --- a/spec/opensearch/api/actions/http/options_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.http#options' do - let(:expected_args) do - [ - 'OPTIONS', - 'some/api', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.http.options('some/api')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/http/patch_spec.rb b/spec/opensearch/api/actions/http/patch_spec.rb deleted file mode 100644 index 3ab5f7ef0..000000000 --- a/spec/opensearch/api/actions/http/patch_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.http#patch' do - let(:expected_args) do - [ - 'PATCH', - 'books/1984', - {}, - body, - {} - ] - end - - let(:body) do - { wonderful: 'tonight' } - end - - it 'performs the request' do - expect(client_double.http.patch('books/1984', body: body)).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/http/post_spec.rb b/spec/opensearch/api/actions/http/post_spec.rb deleted file mode 100644 index 0ba64c463..000000000 --- a/spec/opensearch/api/actions/http/post_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.http#post' do - let(:expected_args) do - [ - 'POST', - 'books/_close', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.http.post('books/_close')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/http/put_spec.rb b/spec/opensearch/api/actions/http/put_spec.rb deleted file mode 100644 index 21e4ecb47..000000000 --- a/spec/opensearch/api/actions/http/put_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.http#put' do - let(:expected_args) do - [ - 'PUT', - 'books', - {}, - body, - {} - ] - end - - let(:body) do - { - settings: { - number_of_shards: 3, - number_of_replicas: 2 - } - } - end - - it 'performs the request' do - expect(client_double.http.put('books', body: body)).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/http/trace_spec.rb b/spec/opensearch/api/actions/http/trace_spec.rb deleted file mode 100644 index aa58b7bf4..000000000 --- a/spec/opensearch/api/actions/http/trace_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.http#trace' do - let(:expected_args) do - [ - 'TRACE', - 'some/api', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.http.trace('some/api')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/index_document_spec.rb b/spec/opensearch/api/actions/index_document_spec.rb deleted file mode 100644 index 1ec82739a..000000000 --- a/spec/opensearch/api/actions/index_document_spec.rb +++ /dev/null @@ -1,141 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#index' do - let(:expected_args) do - [ - request_type, - url, - params, - body, - {} - ] - end - - let(:request_type) do - 'POST' - end - - let(:params) do - {} - end - - let(:url) do - 'foo/_doc' - end - - let(:body) do - { foo: 'bar' } - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :index argument' do - expect do - client.index - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.index(index: 'foo', body: body)).to eq({}) - end - - context 'when a specific id is provided' do - let(:request_type) do - 'PUT' - end - - let(:url) do - 'foo/_doc/1' - end - - it 'performs the request' do - expect(client_double.index(index: 'foo', id: '1', body: body)).to eq({}) - end - end - - context 'when URL parameters are provided' do - let(:request_type) do - 'POST' - end - - let(:url) do - 'foo/_doc' - end - - let(:params) do - { op_type: 'create' } - end - - it 'passes the URL params' do - expect(client_double.index(index: 'foo', op_type: 'create', body: body)).to eq({}) - end - - context 'when a specific id is provided' do - let(:request_type) do - 'PUT' - end - - let(:url) do - 'foo/_doc/1' - end - - let(:params) do - { op_type: 'create' } - end - - it 'passes the URL params' do - expect(client_double.index(index: 'foo', id: '1', op_type: 'create', body: body)).to eq({}) - end - end - end - - context 'when the request needs to be URL-escaped' do - let(:request_type) do - 'PUT' - end - - let(:url) do - 'foo%5Ebar/_doc/123' - end - - it 'URL-escapes the parts' do - expect(client_double.index(index: 'foo^bar', id: '123', body: body)).to eq({}) - end - end - - context 'when an invalid URL parameter is provided' do - it 'raises and ArgumentError' do - expect do - client.index(index: 'foo', id: '1', qwerty: 'yuiop') - end.to raise_exception(ArgumentError) - end - end -end diff --git a/spec/opensearch/api/actions/indices/add_block_spec.rb b/spec/opensearch/api/actions/indices/add_block_spec.rb deleted file mode 100644 index dacb51296..000000000 --- a/spec/opensearch/api/actions/indices/add_block_spec.rb +++ /dev/null @@ -1,72 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#add_block' do - let(:expected_args) do - [ - 'PUT', - url, - {}, - nil, - {} - ] - end - let(:url) { "#{index}/_block/#{block}" } - let(:index) { 'test_index' } - let(:block) { 'test_block' } - - it 'performs the request' do - expect( - client_double.indices.add_block(index: index, block: block) - ).to eq({}) - end - - context 'when an index is not specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an argument error' do - expect do - client.indices.add_block(block: block) - end.to raise_exception(ArgumentError) - end - end - - context 'when a block is not specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an argument error' do - expect do - client.indices.add_block(index: index) - end.to raise_exception(ArgumentError) - end - end -end diff --git a/spec/opensearch/api/actions/indices/analyze_spec.rb b/spec/opensearch/api/actions/indices/analyze_spec.rb deleted file mode 100644 index 283af0f0b..000000000 --- a/spec/opensearch/api/actions/indices/analyze_spec.rb +++ /dev/null @@ -1,77 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#analyze' do - let(:expected_args) do - [ - method, - url, - params, - body, - {} - ] - end - let(:method) { 'GET' } - - let(:body) do - nil - end - - let(:url) do - '_analyze' - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.indices.analyze).to eq({}) - end - - context 'when an index is specified' do - let(:url) do - 'foo/_analyze' - end - - it 'performs the request' do - expect(client_double.indices.analyze(index: 'foo')).to eq({}) - end - end - - context 'when a body is specified' do - let(:body) do - 'foo' - end - let(:method) { 'POST' } - - it 'performs the request' do - expect(client_double.indices.analyze(body: 'foo')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/clear_cache_spec.rb b/spec/opensearch/api/actions/indices/clear_cache_spec.rb deleted file mode 100644 index 2c87eb82d..000000000 --- a/spec/opensearch/api/actions/indices/clear_cache_spec.rb +++ /dev/null @@ -1,85 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#clear_cache' do - let(:expected_args) do - [ - 'POST', - url, - params, - nil, - {} - ] - end - - let(:url) do - '_cache/clear' - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.indices.clear_cache).to eq({}) - end - - context 'when an index is specified' do - let(:url) do - 'foo/_cache/clear' - end - - it 'performs the request' do - expect(client_double.indices.clear_cache(index: 'foo')).to eq({}) - end - end - - context 'when params are specified' do - let(:params) do - { fielddata: true } - end - - it 'performs the request' do - expect(client_double.indices.clear_cache(fielddata: true)).to eq({}) - end - end - - context 'when the path must be URL-escaped' do - let(:url) do - 'foo%5Ebar/_cache/clear' - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.indices.clear_cache(index: 'foo^bar')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/clone_spec.rb b/spec/opensearch/api/actions/indices/clone_spec.rb deleted file mode 100644 index 377c607f4..000000000 --- a/spec/opensearch/api/actions/indices/clone_spec.rb +++ /dev/null @@ -1,125 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#clone' do - let(:expected_args) do - [ - 'PUT', - url, - params, - body, - {} - ] - end - - let(:params) do - {} - end - - let(:body) do - nil - end - - let(:url) do - 'my_source_index/_clone/my_target_index' - end - - context 'when there is no index specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect do - client.indices.clone(target: 'my_target_index') - end.to raise_exception(ArgumentError) - end - end - - context 'when there is no index specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect do - client.indices.clone(index: 'my_source_index') - end.to raise_exception(ArgumentError) - end - end - - context 'when an index and target are specified' do - it 'performs the request' do - expect(client_double.indices.clone(index: 'my_source_index', target: 'my_target_index')).to eq({}) - end - end - - context 'when params are provided' do - let(:params) do - { - timeout: '1s', - cluster_manager_timeout: '10s', - wait_for_active_shards: 1 - } - end - - it 'performs the request' do - expect(client_double.indices.clone(index: 'my_source_index', - target: 'my_target_index', - timeout: '1s', - cluster_manager_timeout: '10s', - wait_for_active_shards: 1)).to eq({}) - end - end - - context 'when a body is specified' do - let(:body) do - { - settings: { - 'index.number_of_shards' => 5 - }, - aliases: { - my_search_indices: {} - } - } - end - - it 'performs the request' do - expect(client_double.indices.clone(index: 'my_source_index', - target: 'my_target_index', - body: { - settings: { - 'index.number_of_shards' => 5 - }, - aliases: { - my_search_indices: {} - } - })).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/close_spec.rb b/spec/opensearch/api/actions/indices/close_spec.rb deleted file mode 100644 index 4fb68065e..000000000 --- a/spec/opensearch/api/actions/indices/close_spec.rb +++ /dev/null @@ -1,89 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#close' do - let(:expected_args) do - [ - 'POST', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - context 'when there is no index specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect do - client.indices.close - end.to raise_exception(ArgumentError) - end - end - - context 'when an index is specified' do - let(:url) do - 'foo/_close' - end - - it 'performs the request' do - expect(client_double.indices.close(index: 'foo')).to eq({}) - end - end - - context 'when params are specified' do - let(:params) do - { timeout: '1s' } - end - - let(:url) do - 'foo/_close' - end - - it 'performs the request' do - expect(client_double.indices.close(index: 'foo', timeout: '1s')).to eq({}) - end - end - - context 'when the path must be URL-escaped' do - let(:url) do - 'foo%5Ebar/_close' - end - - it 'performs the request' do - expect(client_double.indices.close(index: 'foo^bar')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/create_spec.rb b/spec/opensearch/api/actions/indices/create_spec.rb deleted file mode 100644 index 07b393b4b..000000000 --- a/spec/opensearch/api/actions/indices/create_spec.rb +++ /dev/null @@ -1,89 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#create' do - let(:expected_args) do - [ - 'PUT', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - context 'when there is no index specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect do - client.indices.create - end.to raise_exception(ArgumentError) - end - end - - context 'when an index is specified' do - let(:url) do - 'foo' - end - - it 'performs the request' do - expect(client_double.indices.create(index: 'foo')).to eq({}) - end - end - - context 'when params are specified' do - let(:params) do - { timeout: '1s' } - end - - let(:url) do - 'foo' - end - - it 'performs the request' do - expect(client_double.indices.create(index: 'foo', timeout: '1s')).to eq({}) - end - end - - context 'when the path must be URL-escaped' do - let(:url) do - 'foo%5Ebar' - end - - it 'performs the request' do - expect(client_double.indices.create(index: 'foo^bar')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/delete_alias_spec.rb b/spec/opensearch/api/actions/indices/delete_alias_spec.rb deleted file mode 100644 index deaeb17ff..000000000 --- a/spec/opensearch/api/actions/indices/delete_alias_spec.rb +++ /dev/null @@ -1,87 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#delete_alias' do - let(:expected_args) do - [ - 'DELETE', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - context 'when there is no index specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect do - client.indices.delete_alias(name: 'foo') - end.to raise_exception(ArgumentError) - end - end - - context 'when there is no name specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect do - client.indices.delete_alias(index: 'foo') - end.to raise_exception(ArgumentError) - end - end - - context 'when an index and name are specified' do - let(:url) do - 'foo/_aliases/bar' - end - - it 'performs the request' do - expect(client_double.indices.delete_alias(index: 'foo', name: 'bar')).to eq({}) - end - end - - context 'when the path must be URL-escaped' do - let(:url) do - 'foo%5Ebar/_aliases/bar%2Fbam' - end - - it 'performs the request' do - expect(client_double.indices.delete_alias(index: 'foo^bar', name: 'bar/bam')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/delete_spec.rb b/spec/opensearch/api/actions/indices/delete_spec.rb deleted file mode 100644 index 5d63aca8c..000000000 --- a/spec/opensearch/api/actions/indices/delete_spec.rb +++ /dev/null @@ -1,111 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#delete' do - let(:expected_args) do - [ - 'DELETE', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:url) do - 'foo' - end - - it 'performs the request' do - expect(client_double.indices.delete(index: 'foo')).to eq({}) - end - - context 'when more than one index is specified' do - let(:url) do - 'foo,bar' - end - - it 'performs the request' do - expect(client_double.indices.delete(index: %w[foo bar])).to eq({}) - end - end - - context 'when params are specified' do - let(:params) do - { timeout: '1s' } - end - - it 'performs the request' do - expect(client_double.indices.delete(index: 'foo', timeout: '1s')).to eq({}) - end - end - - context 'when the path must be URL-escaped' do - let(:url) do - 'foo%5Ebar' - end - - it 'performs the request' do - expect(client_double.indices.delete(index: 'foo^bar')).to eq({}) - end - end - - context 'when a NotFound exception is raised by the request' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - before do - expect(client).to receive(:perform_request).and_raise(NotFound) - end - - it 'raises the exception' do - expect do - client.indices.delete(index: 'foo') - end.to raise_exception(NotFound) - end - end - - context 'when the ignore parameter is specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - before do - expect(client).to receive(:perform_request).and_raise(NotFound) - end - - it 'ignores the code' do - expect(client.indices.delete(index: 'foo', ignore: 404)).to be(false) - end - end -end diff --git a/spec/opensearch/api/actions/indices/delete_template_spec.rb b/spec/opensearch/api/actions/indices/delete_template_spec.rb deleted file mode 100644 index d733170d5..000000000 --- a/spec/opensearch/api/actions/indices/delete_template_spec.rb +++ /dev/null @@ -1,91 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#delete_template' do - let(:expected_args) do - [ - 'DELETE', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:url) do - '_template/foo' - end - - it 'performs the request' do - expect(client_double.indices.delete_template(name: 'foo')).to eq({}) - end - - context 'when the path needs to be URL-escaped' do - let(:url) do - '_template/foo%5Ebar' - end - - it 'performs the request' do - expect(client_double.indices.delete_template(name: 'foo^bar')).to eq({}) - end - end - - context 'when a NotFound exception is raised by the request' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - before do - expect(client).to receive(:perform_request).and_raise(NotFound) - end - - it 'raises the exception' do - expect do - client.indices.delete_template(name: 'foo') - end.to raise_exception(NotFound) - end - end - - context 'when the ignore parameter is specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - before do - expect(client).to receive(:perform_request).and_raise(NotFound) - end - - it 'ignores the code' do - expect(client.indices.delete_template(name: 'foo', ignore: 404)).to be(false) - end - end -end diff --git a/spec/opensearch/api/actions/indices/disk_usage_spec.rb b/spec/opensearch/api/actions/indices/disk_usage_spec.rb deleted file mode 100644 index f5f734dc2..000000000 --- a/spec/opensearch/api/actions/indices/disk_usage_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#disk_usage' do - let(:expected_args) do - [ - 'POST', - "#{index}/_disk_usage", - {}, - nil, - {} - ] - end - - let(:index) { 'foo' } - - it 'performs the request' do - expect(client_double.indices.disk_usage(index: index)).to eq({}) - end - - context 'when there is no index specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect do - client.indices.disk_usage - end.to raise_exception(ArgumentError) - end - end -end diff --git a/spec/opensearch/api/actions/indices/exists_alias_spec.rb b/spec/opensearch/api/actions/indices/exists_alias_spec.rb deleted file mode 100644 index 2e6320ad5..000000000 --- a/spec/opensearch/api/actions/indices/exists_alias_spec.rb +++ /dev/null @@ -1,111 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#exists_alias' do - let(:expected_args) do - [ - 'HEAD', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:url) do - '_alias/foo' - end - - it 'performs the request' do - expect(client_double.indices.exists_alias(name: 'foo')).to be(true) - end - - it 'aliased to a predicate method' do - expect(client_double.indices.exists_alias?(name: 'foo')).to be(true) - end - - context 'when multiple indices are specified' do - let(:url) do - 'foo,bar/_alias/bam' - end - - it 'performs the request' do - expect(client_double.indices.exists_alias(index: %w[foo bar], name: 'bam')).to be(true) - end - end - - context 'when the path needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_alias/bar%2Fbam' - end - - it 'performs the request' do - expect(client_double.indices.exists_alias(index: 'foo^bar', name: 'bar/bam')).to be(true) - end - end - - context 'when 404 response is received' do - let(:response_double) do - double('response', status: 404, body: {}, headers: {}) - end - - it 'returns false' do - expect(client_double.indices.exists_alias(name: 'foo')).to be(false) - end - end - - context 'when a \'not found\' exception is raised' do - let(:client) do - Class.new { include OpenSearch::API }.new.tap do |_client| - expect(_client).to receive(:perform_request).with(*expected_args).and_raise(StandardError.new('404 Not Found')) - end - end - - it 'returns false' do - expect(client.indices.exists_alias(name: 'foo')).to be(false) - end - end - - context 'when a generic exception is raised' do - let(:client) do - Class.new { include OpenSearch::API }.new.tap do |_client| - expect(_client).to receive(:perform_request).with(*expected_args).and_raise(StandardError.new) - end - end - - it 'raises the exception' do - expect do - client.indices.exists_alias(name: 'foo') - end.to raise_exception(StandardError) - end - end -end diff --git a/spec/opensearch/api/actions/indices/exists_spec.rb b/spec/opensearch/api/actions/indices/exists_spec.rb deleted file mode 100644 index 1303c9328..000000000 --- a/spec/opensearch/api/actions/indices/exists_spec.rb +++ /dev/null @@ -1,111 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#exists' do - let(:expected_args) do - [ - 'HEAD', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:url) do - 'foo' - end - - it 'performs the request' do - expect(client_double.indices.exists(index: 'foo')).to be(true) - end - - it 'aliased to a predicate method' do - expect(client_double.indices.exists?(index: 'foo')).to be(true) - end - - context 'when multiple indices are specified' do - let(:url) do - 'foo,bar' - end - - it 'performs the request' do - expect(client_double.indices.exists(index: %w[foo bar])).to be(true) - end - end - - context 'when the path needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar' - end - - it 'performs the request' do - expect(client_double.indices.exists(index: 'foo^bar')).to be(true) - end - end - - context 'when 404 response is received' do - let(:response_double) do - double('response', status: 404, body: {}, headers: {}) - end - - it 'returns false' do - expect(client_double.indices.exists(index: 'foo')).to be(false) - end - end - - context 'when a \'not found\' exception is raised' do - let(:client) do - Class.new { include OpenSearch::API }.new.tap do |_client| - expect(_client).to receive(:perform_request).with(*expected_args).and_raise(StandardError.new('404 Not Found')) - end - end - - it 'returns false' do - expect(client.indices.exists(index: 'foo')).to be(false) - end - end - - context 'when a generic exception is raised' do - let(:client) do - Class.new { include OpenSearch::API }.new.tap do |_client| - expect(_client).to receive(:perform_request).with(*expected_args).and_raise(StandardError.new) - end - end - - it 'raises the exception' do - expect do - client.indices.exists(index: 'foo') - end.to raise_exception(StandardError) - end - end -end diff --git a/spec/opensearch/api/actions/indices/exists_template_spec.rb b/spec/opensearch/api/actions/indices/exists_template_spec.rb deleted file mode 100644 index e1605d2c0..000000000 --- a/spec/opensearch/api/actions/indices/exists_template_spec.rb +++ /dev/null @@ -1,97 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#exists_template' do - let(:expected_args) do - [ - 'HEAD', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:url) do - '_template/foo' - end - - it 'performs the request' do - expect(client_double.indices.exists_template(name: 'foo')).to be(true) - end - - context 'when the path needs to be URL-escaped' do - let(:url) do - '_template/bar%2Fbam' - end - - it 'performs the request' do - expect(client_double.indices.exists_template(name: 'bar/bam')).to be(true) - end - end - - context 'when 404 response is received' do - let(:response_double) do - double('response', status: 404, body: {}, headers: {}) - end - - it 'returns false' do - expect(client_double.indices.exists_template(name: 'foo')).to be(false) - end - end - - context 'when a \'not found\' exception is raised' do - let(:client) do - Class.new { include OpenSearch::API }.new.tap do |_client| - expect(_client).to receive(:perform_request).with(*expected_args).and_raise(StandardError.new('404 Not Found')) - end - end - - it 'returns false' do - expect(client.indices.exists_template(name: 'foo')).to be(false) - end - end - - context 'when a generic exception is raised' do - let(:client) do - Class.new { include OpenSearch::API }.new.tap do |_client| - expect(_client).to receive(:perform_request).with(*expected_args).and_raise(StandardError.new) - end - end - - it 'raises the exception' do - expect do - client.indices.exists_template(name: 'foo') - end.to raise_exception(StandardError) - end - end -end diff --git a/spec/opensearch/api/actions/indices/field_usage_stats_spec.rb b/spec/opensearch/api/actions/indices/field_usage_stats_spec.rb deleted file mode 100644 index 5c1add76c..000000000 --- a/spec/opensearch/api/actions/indices/field_usage_stats_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#field_usage_stats' do - let(:expected_args) do - [ - 'GET', - 'foo/_field_usage_stats', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.indices.field_usage_stats(index: 'foo')).to eq({}) - end - - context 'when there is no index specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect do - client.indices.field_usage_stats - end.to raise_exception(ArgumentError) - end - end -end diff --git a/spec/opensearch/api/actions/indices/flush_spec.rb b/spec/opensearch/api/actions/indices/flush_spec.rb deleted file mode 100644 index a8658b423..000000000 --- a/spec/opensearch/api/actions/indices/flush_spec.rb +++ /dev/null @@ -1,95 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#flush' do - let(:expected_args) do - [ - 'POST', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:url) do - '_flush' - end - - it 'performs the request' do - expect(client_double.indices.flush).to eq({}) - end - - context 'when an index is specified' do - let(:url) do - 'foo/_flush' - end - - it 'performs the request' do - expect(client_double.indices.flush(index: 'foo')).to eq({}) - end - end - - context 'when multiple indices are specified' do - let(:url) do - 'foo,bar/_flush' - end - - it 'performs the request' do - expect(client_double.indices.flush(index: %w[foo bar])).to eq({}) - end - end - - context 'when the path needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_flush' - end - - it 'performs the request' do - expect(client_double.indices.flush(index: 'foo^bar')).to eq({}) - end - end - - context 'when URL parameters are specified' do - let(:url) do - 'foo/_flush' - end - - let(:params) do - { ignore_unavailable: true } - end - - it 'performs the request' do - expect(client_double.indices.flush(index: 'foo', ignore_unavailable: true)).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/forcemerge_spec.rb b/spec/opensearch/api/actions/indices/forcemerge_spec.rb deleted file mode 100644 index bce3f495d..000000000 --- a/spec/opensearch/api/actions/indices/forcemerge_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#forcemerge' do - let(:expected_args) do - [ - 'POST', - '_forcemerge', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.indices.forcemerge).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/indices/get_alias_spec.rb b/spec/opensearch/api/actions/indices/get_alias_spec.rb deleted file mode 100644 index 2953522d2..000000000 --- a/spec/opensearch/api/actions/indices/get_alias_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#get_alias' do - let(:expected_args) do - [ - 'GET', - url, - {}, - nil, - {} - ] - end - - let(:url) do - '_alias/foo' - end - - it 'performs the request' do - expect(client_double.indices.get_alias(name: 'foo')).to eq({}) - end - - context 'when multiple indices are specified' do - let(:url) do - 'foo,bar/_alias/bam' - end - - it 'performs the request' do - expect(client_double.indices.get_alias(index: %w[foo bar], name: 'bam')).to eq({}) - end - end - - context 'when the path needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_alias/bar%2Fbam' - end - - it 'performs the request' do - expect(client_double.indices.get_alias(index: 'foo^bar', name: 'bar/bam')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/get_field_mapping_spec.rb b/spec/opensearch/api/actions/indices/get_field_mapping_spec.rb deleted file mode 100644 index 4d218a228..000000000 --- a/spec/opensearch/api/actions/indices/get_field_mapping_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#get_field_mapping' do - let(:expected_args) do - [ - 'GET', - url, - {}, - nil, - {} - ] - end - - let(:url) do - '_mapping/field/foo' - end - - it 'performs the request' do - expect(client_double.indices.get_field_mapping(field: 'foo')).to eq({}) - end - - context 'when an index is specified' do - let(:url) do - 'foo/_mapping/field/bam' - end - - it 'performs the request' do - expect(client_double.indices.get_field_mapping(index: 'foo', field: 'bam')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/get_mapping_spec.rb b/spec/opensearch/api/actions/indices/get_mapping_spec.rb deleted file mode 100644 index 6ab11125c..000000000 --- a/spec/opensearch/api/actions/indices/get_mapping_spec.rb +++ /dev/null @@ -1,77 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#get_mapping' do - let(:expected_args) do - [ - 'GET', - url, - {}, - nil, - {} - ] - end - - let(:url) do - '_mapping' - end - - it 'performs the request' do - expect(client_double.indices.get_mapping).to eq({}) - end - - context 'when an index is specified' do - let(:url) do - 'foo/_mapping' - end - - it 'performs the request' do - expect(client_double.indices.get_mapping(index: 'foo')).to eq({}) - end - end - - context 'when multiple indices are specified' do - let(:url) do - 'foo,bar/_mapping' - end - - it 'performs the request' do - expect(client_double.indices.get_mapping(index: %w[foo bar])).to eq({}) - end - end - - context 'when the path must be URL-escaped' do - let(:url) do - 'foo%5Ebar/_mapping' - end - - it 'performs the request' do - expect(client_double.indices.get_mapping(index: 'foo^bar')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/get_settings_spec.rb b/spec/opensearch/api/actions/indices/get_settings_spec.rb deleted file mode 100644 index 4fda32db0..000000000 --- a/spec/opensearch/api/actions/indices/get_settings_spec.rb +++ /dev/null @@ -1,77 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#get_settings' do - let(:expected_args) do - [ - 'GET', - url, - {}, - nil, - {} - ] - end - - let(:url) do - '_settings' - end - - it 'performs the request' do - expect(client_double.indices.get_settings).to eq({}) - end - - context 'when an index is specified' do - let(:url) do - 'foo/_settings' - end - - it 'performs the request' do - expect(client_double.indices.get_settings(index: 'foo')).to eq({}) - end - end - - context 'when a name is specified' do - let(:url) do - 'foo/_settings/foo.bar' - end - - it 'performs the request' do - expect(client_double.indices.get_settings(index: 'foo', name: 'foo.bar')).to eq({}) - end - end - - context 'when the path must be URL-escaped' do - let(:url) do - 'foo%5Ebar/_settings' - end - - it 'performs the request' do - expect(client_double.indices.get_settings(index: 'foo^bar')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/get_spec.rb b/spec/opensearch/api/actions/indices/get_spec.rb deleted file mode 100644 index 8b39558c3..000000000 --- a/spec/opensearch/api/actions/indices/get_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#get' do - let(:expected_args) do - [ - 'GET', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:url) do - 'foo' - end - - it 'performs the request' do - expect(client_double.indices.get(index: 'foo')).to eq({}) - end - - context 'when parameters are specified' do - let(:params) do - { ignore_unavailable: 1 } - end - - it 'performs the request' do - expect(client_double.indices.get(index: 'foo', ignore_unavailable: 1)).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/open_spec.rb b/spec/opensearch/api/actions/indices/open_spec.rb deleted file mode 100644 index 0d1daa6c2..000000000 --- a/spec/opensearch/api/actions/indices/open_spec.rb +++ /dev/null @@ -1,71 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.indices#open' do - let(:expected_args) do - [ - 'POST', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:url) do - 'foo/_open' - end - - it 'performs the request' do - expect(client_double.indices.open(index: 'foo')).to eq({}) - end - - context 'when parameters are specified' do - let(:params) do - { timeout: '1s' } - end - - it 'performs the request' do - expect(client_double.indices.open(index: 'foo', timeout: '1s')).to eq({}) - end - end - - context 'when the path must be URL-escaped' do - let(:url) do - 'foo%5Ebar/_open' - end - - it 'performs the request' do - expect(client_double.indices.open(index: 'foo^bar')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/put_alias_spec.rb b/spec/opensearch/api/actions/indices/put_alias_spec.rb deleted file mode 100644 index 2f8e81b3a..000000000 --- a/spec/opensearch/api/actions/indices/put_alias_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#put_alias' do - let(:expected_args) do - [ - 'PUT', - url, - {}, - body, - {} - ] - end - - let(:url) do - 'foo/_aliases/bar' - end - - let(:body) do - nil - end - - it 'performs the request' do - expect(client_double.indices.put_alias(index: 'foo', name: 'bar')).to eq({}) - end - - context 'when there is no name specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect do - client.indices.put_alias(name: 'foo') - end.to raise_exception(ArgumentError) - end - end - - context 'when a body is specified' do - let(:body) do - { filter: 'foo' } - end - - it 'performs the request' do - expect(client_double.indices.put_alias(index: 'foo', name: 'bar', body: { filter: 'foo' })).to eq({}) - end - end - - context 'when multiple indices are specified' do - let(:url) do - 'foo,bar/_aliases/bam' - end - - it 'performs the request' do - expect(client_double.indices.put_alias(index: %w[foo bar], name: 'bam')).to eq({}) - end - end - - context 'when the path needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_aliases/bar%2Fbam' - end - - it 'performs the request' do - expect(client_double.indices.put_alias(index: 'foo^bar', name: 'bar/bam')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/put_mapping_spec.rb b/spec/opensearch/api/actions/indices/put_mapping_spec.rb deleted file mode 100644 index b7358268f..000000000 --- a/spec/opensearch/api/actions/indices/put_mapping_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#put_mapping' do - let(:expected_args) do - [ - 'PUT', - url, - {}, - body, - {} - ] - end - - let(:url) do - 'foo/_mappings' - end - - let(:body) do - {} - end - - it 'performs the request' do - expect(client_double.indices.put_mapping(index: 'foo', body: {})).to eq({}) - end - - context 'when there is no body specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect do - client.indices.put_mapping(index: 'foo') - end.to raise_exception(ArgumentError) - end - end - - context 'when a body is specified' do - let(:body) do - { filter: 'foo' } - end - - it 'performs the request' do - expect(client_double.indices.put_mapping(index: 'foo', body: { filter: 'foo' })).to eq({}) - end - end - - context 'when multiple indices are specified' do - let(:url) do - 'foo,bar/_mappings' - end - - it 'performs the request' do - expect(client_double.indices.put_mapping(index: %w[foo bar], body: {})).to eq({}) - end - end - - context 'when the path needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_mappings' - end - - it 'performs the request' do - expect(client_double.indices.put_mapping(index: 'foo^bar', body: {})).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/put_settings_spec.rb b/spec/opensearch/api/actions/indices/put_settings_spec.rb deleted file mode 100644 index f2967077e..000000000 --- a/spec/opensearch/api/actions/indices/put_settings_spec.rb +++ /dev/null @@ -1,111 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#put_settings' do - let(:expected_args) do - [ - 'PUT', - url, - params, - body, - {} - ] - end - - let(:url) do - '_settings' - end - - let(:body) do - {} - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.indices.put_settings(body: {})).to eq({}) - end - - context 'when there is no body specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect do - client.indices.put_settings - end.to raise_exception(ArgumentError) - end - end - - context 'when parameters are specified' do - let(:params) do - { flat_settings: true } - end - - let(:url) do - 'foo/_settings' - end - - it 'performs the request' do - expect(client_double.indices.put_settings(index: 'foo', flat_settings: true, body: {})).to eq({}) - end - end - - context 'when an index is specified' do - let(:url) do - 'foo/_settings' - end - - it 'performs the request' do - expect(client_double.indices.put_settings(index: 'foo', body: {})).to eq({}) - end - end - - context 'when multiple indices are specified' do - let(:url) do - 'foo,bar/_settings' - end - - it 'performs the request' do - expect(client_double.indices.put_settings(index: %w[foo bar], body: {})).to eq({}) - end - end - - context 'when the path needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_settings' - end - - it 'performs the request' do - expect(client_double.indices.put_settings(index: 'foo^bar', body: {})).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/put_template_spec.rb b/spec/opensearch/api/actions/indices/put_template_spec.rb deleted file mode 100644 index 2799e9e0c..000000000 --- a/spec/opensearch/api/actions/indices/put_template_spec.rb +++ /dev/null @@ -1,111 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#put_template' do - let(:expected_args) do - [ - 'PUT', - url, - params, - body, - {} - ] - end - - let(:url) do - '_template/foo' - end - - let(:body) do - { template: 'bar' } - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.indices.put_template(name: 'foo', body: { template: 'bar' })).to eq({}) - end - - context 'when there is no name specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect do - client.indices.put_template(body: {}) - end.to raise_exception(ArgumentError) - end - end - - context 'when there is no body specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect do - client.indices.put_template(name: 'foo') - end.to raise_exception(ArgumentError) - end - end - - context 'when parameters are specified' do - let(:params) do - { order: 3 } - end - - let(:url) do - '_template/foo' - end - - let(:body) do - {} - end - - it 'performs the request' do - expect(client_double.indices.put_template(name: 'foo', order: 3, body: {})).to eq({}) - end - end - - context 'when the path needs to be URL-escaped' do - let(:url) do - '_template/foo%5Ebar' - end - - let(:body) do - {} - end - - it 'performs the request' do - expect(client_double.indices.put_template(name: 'foo^bar', body: {})).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/recovery_spec.rb b/spec/opensearch/api/actions/indices/recovery_spec.rb deleted file mode 100644 index 42420413f..000000000 --- a/spec/opensearch/api/actions/indices/recovery_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#recovery' do - let(:expected_args) do - [ - 'GET', - 'foo/_recovery', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.indices.recovery(index: 'foo')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/indices/refresh_spec.rb b/spec/opensearch/api/actions/indices/refresh_spec.rb deleted file mode 100644 index 88f0d7995..000000000 --- a/spec/opensearch/api/actions/indices/refresh_spec.rb +++ /dev/null @@ -1,95 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#refresh' do - let(:expected_args) do - [ - 'POST', - url, - params, - body, - {} - ] - end - - let(:url) do - '_refresh' - end - - let(:body) do - nil - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.indices.refresh).to eq({}) - end - - context 'when an index is specified' do - let(:url) do - 'foo/_refresh' - end - - it 'performs the request' do - expect(client_double.indices.refresh(index: 'foo')).to eq({}) - end - end - - context 'when multiple indicies are specified as a list' do - let(:url) do - 'foo,bar/_refresh' - end - - it 'performs the request' do - expect(client_double.indices.refresh(index: %w[foo bar])).to eq({}) - end - end - - context 'when multiple indicies are specified as a string' do - let(:url) do - 'foo,bar/_refresh' - end - - it 'performs the request' do - expect(client_double.indices.refresh(index: 'foo,bar')).to eq({}) - end - end - - context 'when the path needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_refresh' - end - - it 'performs the request' do - expect(client_double.indices.refresh(index: 'foo^bar')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/rollover_spec.rb b/spec/opensearch/api/actions/indices/rollover_spec.rb deleted file mode 100644 index bb324a5a3..000000000 --- a/spec/opensearch/api/actions/indices/rollover_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#rollover' do - let(:expected_args) do - [ - 'POST', - url, - params, - body, - {} - ] - end - - let(:url) do - 'foo/_rollover' - end - - let(:body) do - nil - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.indices.rollover(alias: 'foo')).to eq({}) - end - - context 'when an index is specified' do - let(:url) do - 'foo/_rollover/bar' - end - - it 'performs the request' do - expect(client_double.indices.rollover(alias: 'foo', new_index: 'bar')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/segments_spec.rb b/spec/opensearch/api/actions/indices/segments_spec.rb deleted file mode 100644 index e59750174..000000000 --- a/spec/opensearch/api/actions/indices/segments_spec.rb +++ /dev/null @@ -1,95 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#segments' do - let(:expected_args) do - [ - 'GET', - url, - params, - body, - {} - ] - end - - let(:url) do - '_segments' - end - - let(:body) do - nil - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.indices.segments).to eq({}) - end - - context 'when an index is specified' do - let(:url) do - 'foo/_segments' - end - - it 'performs the request' do - expect(client_double.indices.segments(index: 'foo')).to eq({}) - end - end - - context 'when multiple indicies are specified as a list' do - let(:url) do - 'foo,bar/_segments' - end - - it 'performs the request' do - expect(client_double.indices.segments(index: %w[foo bar])).to eq({}) - end - end - - context 'when multiple indicies are specified as a string' do - let(:url) do - 'foo,bar/_segments' - end - - it 'performs the request' do - expect(client_double.indices.segments(index: 'foo,bar')).to eq({}) - end - end - - context 'when the path needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_segments' - end - - it 'performs the request' do - expect(client_double.indices.segments(index: 'foo^bar')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/shard_stores_spec.rb b/spec/opensearch/api/actions/indices/shard_stores_spec.rb deleted file mode 100644 index e832d957b..000000000 --- a/spec/opensearch/api/actions/indices/shard_stores_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#shard_stores' do - let(:expected_args) do - [ - 'GET', - '_shard_stores', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.indices.shard_stores).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/indices/shrink_spec.rb b/spec/opensearch/api/actions/indices/shrink_spec.rb deleted file mode 100644 index 8135eab27..000000000 --- a/spec/opensearch/api/actions/indices/shrink_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#shrink' do - let(:expected_args) do - [ - 'PUT', - 'foo/_shrink/bar', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.indices.shrink(index: 'foo', target: 'bar')).to eq({}) - end - - it 'does not mutate the arguments' do - arguments = { index: 'foo', target: 'bar' } - client_double.indices.shrink(arguments) - expect(arguments[:index]).to eq('foo') - expect(arguments[:target]).to eq('bar') - end -end diff --git a/spec/opensearch/api/actions/indices/split_spec.rb b/spec/opensearch/api/actions/indices/split_spec.rb deleted file mode 100644 index cb0795843..000000000 --- a/spec/opensearch/api/actions/indices/split_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#split' do - let(:expected_args) do - [ - 'PUT', - 'foo/_split/bar', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.indices.split(index: 'foo', target: 'bar')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/indices/stats_spec.rb b/spec/opensearch/api/actions/indices/stats_spec.rb deleted file mode 100644 index 59290ba42..000000000 --- a/spec/opensearch/api/actions/indices/stats_spec.rb +++ /dev/null @@ -1,127 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#stats' do - let(:expected_args) do - [ - 'GET', - url, - params, - body, - {} - ] - end - - let(:url) do - '_stats' - end - - let(:body) do - nil - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.indices.stats).to eq({}) - end - - context 'when an index is specified' do - let(:url) do - 'foo/_stats' - end - - it 'performs the request' do - expect(client_double.indices.stats(index: 'foo')).to eq({}) - end - end - - context 'when multiple indicies are specified as a list' do - let(:url) do - 'foo,bar/_stats' - end - - it 'performs the request' do - expect(client_double.indices.stats(index: %w[foo bar])).to eq({}) - end - end - - context 'when multiple indicies are specified as a string' do - let(:url) do - 'foo,bar/_stats' - end - - it 'performs the request' do - expect(client_double.indices.stats(index: 'foo,bar')).to eq({}) - end - end - - context 'when parameters are specified' do - let(:params) do - { expand_wildcards: true } - end - - let(:url) do - 'foo/_stats' - end - - it 'performs the request' do - expect(client_double.indices.stats(index: 'foo', expand_wildcards: true)).to eq({}) - end - end - - context 'when the fields parameter is specified as a list' do - let(:params) do - { fields: 'foo,bar' } - end - - let(:url) do - 'foo/_stats/fielddata' - end - - it 'performs the request' do - expect(client_double.indices.stats(index: 'foo', fielddata: true, fields: %w[foo bar])).to eq({}) - end - end - - context 'when the groups parameter is specified as a list' do - let(:params) do - { groups: 'groupA,groupB' } - end - - let(:url) do - '_stats/search' - end - - it 'performs the request' do - expect(client_double.indices.stats(search: true, groups: %w[groupA groupB])).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/update_aliases_spec.rb b/spec/opensearch/api/actions/indices/update_aliases_spec.rb deleted file mode 100644 index a019999de..000000000 --- a/spec/opensearch/api/actions/indices/update_aliases_spec.rb +++ /dev/null @@ -1,73 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#update_aliases' do - let(:expected_args) do - [ - 'POST', - '_aliases', - params, - body, - {} - ] - end - - let(:body) do - { actions: [] } - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.indices.update_aliases(body: { actions: [] })).to eq({}) - end - - context 'when a body is not specified' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect do - client.indices.update_aliases - end.to raise_exception(ArgumentError) - end - end - - context 'when parameters are specified' do - let(:params) do - { timeout: '1s' } - end - - it 'performs the request' do - expect(client_double.indices.update_aliases(timeout: '1s', body: { actions: [] })).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/indices/upgrade_spec.rb b/spec/opensearch/api/actions/indices/upgrade_spec.rb deleted file mode 100644 index 9ae781268..000000000 --- a/spec/opensearch/api/actions/indices/upgrade_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#upgrade' do - let(:expected_args) do - [ - 'POST', - '_upgrade', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.indices.upgrade).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/indices/validate_query_spec.rb b/spec/opensearch/api/actions/indices/validate_query_spec.rb deleted file mode 100644 index 24201db44..000000000 --- a/spec/opensearch/api/actions/indices/validate_query_spec.rb +++ /dev/null @@ -1,121 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.cluster#validate_query' do - let(:expected_args) do - [ - method, - url, - params, - body, - {} - ] - end - let(:method) { 'GET' } - - let(:url) do - '_validate/query' - end - - let(:body) do - nil - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.indices.validate_query).to eq({}) - end - - context 'when an index is specified' do - let(:url) do - 'foo/_validate/query' - end - - it 'performs the request' do - expect(client_double.indices.validate_query(index: 'foo')).to eq({}) - end - end - - context 'when multiple indicies are specified as a list' do - let(:url) do - 'foo,bar/_validate/query' - end - - it 'performs the request' do - expect(client_double.indices.validate_query(index: %w[foo bar])).to eq({}) - end - end - - context 'when multiple indicies are specified as a string' do - let(:url) do - 'foo,bar/_validate/query' - end - - it 'performs the request' do - expect(client_double.indices.validate_query(index: 'foo,bar')).to eq({}) - end - end - - context 'when parameters are specified' do - let(:params) do - { explain: true, q: 'foo' } - end - - let(:url) do - '_validate/query' - end - - it 'performs the request' do - expect(client_double.indices.validate_query(explain: true, q: 'foo')).to eq({}) - end - end - - context 'when a body is specified' do - let(:body) do - { filtered: {} } - end - let(:method) { 'POST' } - - it 'performs the request' do - expect(client_double.indices.validate_query(body: { filtered: {} })).to eq({}) - end - end - - context 'when the path needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_validate/query' - end - - it 'performs the request' do - expect(client_double.indices.validate_query(index: 'foo^bar')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/info_spec.rb b/spec/opensearch/api/actions/info_spec.rb deleted file mode 100644 index eb03dfc65..000000000 --- a/spec/opensearch/api/actions/info_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#info' do - let(:expected_args) do - [ - 'GET', - '', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.info).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/ingest/delete_pipeline_spec.rb b/spec/opensearch/api/actions/ingest/delete_pipeline_spec.rb deleted file mode 100644 index 3de4db294..000000000 --- a/spec/opensearch/api/actions/ingest/delete_pipeline_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.ingest#delete_pipeline' do - let(:expected_args) do - [ - 'DELETE', - url, - {}, - nil, - {} - ] - end - - let(:url) do - '_ingest/pipeline/foo' - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :id argument' do - expect do - client.ingest.delete_pipeline - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.ingest.delete_pipeline(id: 'foo')).to eq({}) - end - - context 'when the path must be URL-escaped' do - let(:url) do - '_ingest/pipeline/foo%5Ebar' - end - - it 'performs the request' do - expect(client_double.ingest.delete_pipeline(id: 'foo^bar')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/ingest/geo_ip_stats_spec.rb b/spec/opensearch/api/actions/ingest/geo_ip_stats_spec.rb deleted file mode 100644 index ed4b2ba0e..000000000 --- a/spec/opensearch/api/actions/ingest/geo_ip_stats_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.ingest#geo_ip_stats' do - let(:expected_args) do - [ - 'GET', - '_ingest/geoip/stats', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.ingest.geo_ip_stats).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/ingest/get_pipeline_spec.rb b/spec/opensearch/api/actions/ingest/get_pipeline_spec.rb deleted file mode 100644 index 615ed822f..000000000 --- a/spec/opensearch/api/actions/ingest/get_pipeline_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.ingest#get_pipeline' do - let(:expected_args) do - [ - 'GET', - url, - {}, - nil, - {} - ] - end - - let(:url) do - '_ingest/pipeline/foo' - end - - it 'performs the request' do - expect(client_double.ingest.get_pipeline(id: 'foo')).to eq({}) - end - - context 'when the path must be URL-escaped' do - let(:url) do - '_ingest/pipeline/foo%5Ebar' - end - - it 'performs the request' do - expect(client_double.ingest.get_pipeline(id: 'foo^bar')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/ingest/put_pipeline_spec.rb b/spec/opensearch/api/actions/ingest/put_pipeline_spec.rb deleted file mode 100644 index 51191f948..000000000 --- a/spec/opensearch/api/actions/ingest/put_pipeline_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.ingest#put_pipeline' do - let(:expected_args) do - [ - 'PUT', - url, - {}, - {}, - {} - ] - end - - let(:url) do - '_ingest/pipeline/foo' - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :id argument' do - expect do - client.ingest.put_pipeline - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.ingest.put_pipeline(id: 'foo', body: {})).to eq({}) - end - - context 'when the path must be URL-escaped' do - let(:url) do - '_ingest/pipeline/foo%5Ebar' - end - - it 'performs the request' do - expect(client_double.ingest.put_pipeline(id: 'foo^bar', body: {})).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/ingest/simulate_spec.rb b/spec/opensearch/api/actions/ingest/simulate_spec.rb deleted file mode 100644 index 7ee99dd53..000000000 --- a/spec/opensearch/api/actions/ingest/simulate_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.ingest#simulate' do - let(:expected_args) do - [ - method, - url, - {}, - {}, - {} - ] - end - let(:method) { 'POST' } - - let(:url) do - '_ingest/pipeline/_simulate' - end - - it 'performs the request' do - expect(client_double.ingest.simulate(body: {})).to eq({}) - end - - context 'when a pipeline id is provided' do - let(:url) do - '_ingest/pipeline/foo/_simulate' - end - - it 'performs the request' do - expect(client_double.ingest.simulate(id: 'foo', body: {})).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/json_builders_spec.rb b/spec/opensearch/api/actions/json_builders_spec.rb deleted file mode 100644 index a34c51da4..000000000 --- a/spec/opensearch/api/actions/json_builders_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'JSON builders' do - context 'JBuilder' do - let(:expected_args) do - [ - 'POST', - '_search', - {}, - body, - {} - ] - end - - let(:json) do - Jbuilder.encode do |json| - json.query do - json.match do - json.title do - json.query 'test' - end - end - end - end - end - - let(:body) do - json - end - - it 'properly builds the json' do - expect(client_double.search(body: json)).to eq({}) - end - end - - context 'Jsonify' do - let(:expected_args) do - [ - 'POST', - '_search', - {}, - body, - {} - ] - end - - let(:json) do - Jsonify::Builder.compile do |json| - json.query do - json.match do - json.title do - json.query 'test' - end - end - end - end - end - - let(:body) do - json - end - - it 'properly builds the json' do - expect(client_double.search(body: json)).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/mget_spec.rb b/spec/opensearch/api/actions/mget_spec.rb deleted file mode 100644 index 817b2edea..000000000 --- a/spec/opensearch/api/actions/mget_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#mget' do - let(:expected_args) do - [ - 'POST', - url, - params, - body, - {} - ] - end - - let(:body) do - { docs: [] } - end - - let(:url) do - '_mget' - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.mget(body: { docs: [] })).to eq({}) - end - - context 'when an index is specified' do - let(:url) do - 'foo/_mget' - end - - it 'performs the request' do - expect(client_double.mget(index: 'foo', body: { docs: [] })).to eq({}) - end - end - - context 'when url parameters are provided' do - let(:params) do - { refresh: true } - end - - let(:body) do - {} - end - - it 'performs the request' do - expect(client_double.mget(body: {}, refresh: true)).to eq({}) - end - end - - context 'when the request needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_mget' - end - - let(:body) do - { ids: %w[1 2] } - end - - it 'performs the request' do - expect(client_double.mget(index: 'foo^bar', body: { ids: %w[1 2] })).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/msearch_spec.rb b/spec/opensearch/api/actions/msearch_spec.rb deleted file mode 100644 index 1a57377af..000000000 --- a/spec/opensearch/api/actions/msearch_spec.rb +++ /dev/null @@ -1,160 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#msearch' do - let(:expected_args) do - [ - 'POST', - url, - params, - body, - headers - ] - end - - let(:body) do - nil - end - - let(:url) do - '_msearch' - end - - let(:params) do - {} - end - - let(:headers) do - { 'Content-Type' => 'application/x-ndjson' } - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.msearch - end.to raise_exception(ArgumentError) - end - - context 'when the body is an object' do - let(:body) do - <<-PAYLOAD.gsub(/^\s+/, '') - {"index":"foo"} - {"query":{"match_all":{}}} - {"index":"bar"} - {"query":{"match":{"foo":"bar"}}} - {"search_type":"count"} - {"facets":{"tags":{}}} - PAYLOAD - end - - it 'performs the request' do - expect( - client_double.msearch( - body: [ - { index: 'foo', search: { query: { match_all: {} } } }, - { index: 'bar', search: { query: { match: { foo: 'bar' } } } }, - { search_type: 'count', search: { facets: { tags: {} } } } - ] - ) - ) - end - end - - context 'when the body is a string' do - let(:body) do - %({"foo":"bar"}\n{"moo":"lam"}) - end - - it 'performs the request' do - expect(client_double.msearch(body: %({"foo":"bar"}\n{"moo":"lam"}))).to eq({}) - end - end - - context 'when an index is specified' do - let(:url) do - 'foo/_msearch' - end - - let(:body) do - '' - end - - it 'performs the request' do - expect(client_double.msearch(index: 'foo', body: [])) - end - end - - context 'when multiple indices are specified' do - let(:url) do - 'foo,bar/_msearch' - end - - let(:body) do - '' - end - - it 'performs the request' do - expect(client_double.msearch(index: %w[foo bar], body: [])) - end - end - - context 'when the request needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_msearch' - end - - let(:body) do - '' - end - - it 'performs the request' do - expect(client_double.msearch(index: 'foo^bar', body: [])).to eq({}) - end - end - - context 'when the URL params need to be URL-encoded' do - let(:url) do - '_msearch' - end - - let(:body) do - '' - end - - let(:params) do - { search_type: 'scroll' } - end - - it 'performs the request' do - expect(client_double.msearch(body: [], search_type: 'scroll')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/msearch_template_spec.rb b/spec/opensearch/api/actions/msearch_template_spec.rb deleted file mode 100644 index c7edf77fb..000000000 --- a/spec/opensearch/api/actions/msearch_template_spec.rb +++ /dev/null @@ -1,99 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#msearch_template' do - let(:expected_args) do - [ - 'POST', - url, - params, - body, - headers - ] - end - - let(:body) do - nil - end - - let(:params) do - {} - end - - let(:headers) do - { 'Content-Type' => 'application/x-ndjson' } - end - - let(:url) do - '_msearch/template' - end - - context 'when a body is provided as a document' do - let(:body) do - <<-PAYLOAD.gsub(/^\s+/, '') - {"index":"foo"} - {"inline":{"query":{"match":{"foo":"{{q}}"}}},"params":{"q":"foo"}} - {"index":"bar"} - {"id":"query_foo","params":{"q":"foo"}} - PAYLOAD - end - - it 'performs the request' do - expect(client_double.msearch_template(body: [ - { index: 'foo' }, - { inline: { query: { match: { foo: '{{q}}' } } }, params: { q: 'foo' } }, - { index: 'bar' }, - { id: 'query_foo', params: { q: 'foo' } } - ])).to eq({}) - end - end - - context 'when a body is provided as a string' do - let(:body) do - %({"foo":"bar"}\n{"moo":"lam"}) - end - - it 'performs the request' do - expect(client_double.msearch_template(body: %({"foo":"bar"}\n{"moo":"lam"}))).to eq({}) - end - end - - context 'when an index is provided' do - let(:url) do - 'foo/_msearch/template' - end - - let(:body) do - '' - end - - it 'performs the request' do - expect(client_double.msearch_template(index: 'foo', body: [])) - end - end -end diff --git a/spec/opensearch/api/actions/mtermvectors_spec.rb b/spec/opensearch/api/actions/mtermvectors_spec.rb deleted file mode 100644 index 0c35b4d8b..000000000 --- a/spec/opensearch/api/actions/mtermvectors_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#mtermvectors' do - let(:expected_args) do - [ - method, - 'my-index/_mtermvectors', - {}, - body, - {} - ] - end - let(:method) { 'POST' } - - let(:body) do - { ids: [1, 2, 3] } - end - - it 'performs the request' do - expect(client_double.mtermvectors(index: 'my-index', body: { ids: [1, 2, 3] })).to eq({}) - end - - context 'when a list of ids is passed instead of a body' do - let(:method) { 'GET' } - - it 'performs the request' do - expect(client_double.mtermvectors(index: 'my-index', ids: [1, 2, 3])).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/nodes/hot_threads_spec.rb b/spec/opensearch/api/actions/nodes/hot_threads_spec.rb deleted file mode 100644 index f1ea13ac8..000000000 --- a/spec/opensearch/api/actions/nodes/hot_threads_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.nodes#hot_threads' do - let(:expected_args) do - [ - 'GET', - url, - {}, - nil, - {} - ] - end - - let(:url) do - '_cluster/nodes/hot_threads' - end - - it 'performs the request' do - expect(client_double.nodes.hot_threads).to eq({}) - end - - context 'when the node id is specified' do - let(:url) do - '_cluster/nodes/foo/hot_threads' - end - - it 'performs the request' do - expect(client_double.nodes.hot_threads(node_id: 'foo')).to eq({}) - end - end - - context 'when the path must be URL-escaped' do - let(:url) do - '_cluster/nodes/foo%5Ebar/hot_threads' - end - - it 'performs the request' do - expect(client_double.nodes.hot_threads(node_id: 'foo^bar')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/nodes/info_spec.rb b/spec/opensearch/api/actions/nodes/info_spec.rb deleted file mode 100644 index 141f9bdcf..000000000 --- a/spec/opensearch/api/actions/nodes/info_spec.rb +++ /dev/null @@ -1,108 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.nodes#info' do - let(:expected_args) do - [ - 'GET', - url, - params, - nil, - {} - ] - end - let(:params) do - {} - end - - let(:url) do - '_nodes' - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.nodes.info).to eq({}) - end - - context 'when the node id is specified' do - let(:url) do - '_nodes/foo' - end - - it 'performs the request' do - expect(client_double.nodes.info(node_id: 'foo')).to eq({}) - end - end - - context 'when multiple node ids are specified as a list' do - let(:url) do - '_nodes/A,B,C' - end - - it 'performs the request' do - expect(client_double.nodes.info(node_id: %w[A B C])).to eq({}) - end - end - - context 'when multiple node ids are specified as a String' do - let(:url) do - '_nodes/A,B,C' - end - - it 'performs the request' do - expect(client_double.nodes.info(node_id: 'A,B,C')).to eq({}) - end - end - - context 'when URL params are specified' do - let(:url) do - '_nodes' - end - - let(:params) do - { format: 'yaml' } - end - - it 'performs the request' do - expect(client_double.nodes.info(format: 'yaml')).to eq({}) - end - end - - context 'when metrics are specified' do - let(:url) do - '_nodes/http,network' - end - - it 'performs the request' do - expect(client_double.nodes.info(metric: %w[http network])).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/nodes/reload_secure_settings_spec.rb b/spec/opensearch/api/actions/nodes/reload_secure_settings_spec.rb deleted file mode 100644 index 607b0ca50..000000000 --- a/spec/opensearch/api/actions/nodes/reload_secure_settings_spec.rb +++ /dev/null @@ -1,90 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client#reload_secure_settings' do - let(:expected_args) do - [ - 'POST', - url, - params, - body, - {} - ] - end - - let(:params) { {} } - let(:url) { '_nodes/reload_secure_settings' } - let(:body) { nil } - - it 'performs the request' do - expect(client_double.nodes.reload_secure_settings).to eq({}) - end - - context 'when a node id is specified' do - let(:url) do - '_nodes/foo/reload_secure_settings' - end - - it 'performs the request' do - expect(client_double.nodes.reload_secure_settings(node_id: 'foo')).to eq({}) - end - end - - context 'when more than one node id is specified as a string' do - let(:body) { { foo: 'bar' } } - - let(:url) do - '_nodes/foo,bar/reload_secure_settings' - end - - it 'performs the request' do - expect(client_double.nodes.reload_secure_settings(node_id: 'foo,bar', body: { foo: 'bar' })).to eq({}) - end - end - - context 'when more than one node id is specified as a list' do - let(:body) { { foo: 'bar' } } - let(:url) do - '_nodes/foo,bar/reload_secure_settings' - end - - it 'performs the request' do - expect(client_double.nodes.reload_secure_settings(node_id: %w[foo bar], body: { foo: 'bar' })).to eq({}) - end - end - - context 'when a timeout param is specified' do - let(:params) do - { timeout: '30s' } - end - - it 'performs the request' do - expect(client_double.nodes.reload_secure_settings(timeout: '30s')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/nodes/shutdown_spec.rb b/spec/opensearch/api/actions/nodes/shutdown_spec.rb deleted file mode 100644 index 4be8ec43f..000000000 --- a/spec/opensearch/api/actions/nodes/shutdown_spec.rb +++ /dev/null @@ -1,84 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.nodes#shutdown' do - let(:expected_args) do - [ - 'POST', - url, - params, - nil, - nil - ] - end - let(:params) do - {} - end - - let(:url) do - '_cluster/nodes/_shutdown' - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.nodes.shutdown).to eq({}) - end - - context 'when the node id is specified' do - let(:url) do - '_cluster/nodes/foo/_shutdown' - end - - it 'performs the request' do - expect(client_double.nodes.shutdown(node_id: 'foo')).to eq({}) - end - end - - context 'when multiple node ids are specified as a list' do - let(:url) do - '_cluster/nodes/A,B,C/_shutdown' - end - - it 'performs the request' do - expect(client_double.nodes.shutdown(node_id: %w[A B C])).to eq({}) - end - end - - context 'when multiple node ids are specified as a String' do - let(:url) do - '_cluster/nodes/A,B,C/_shutdown' - end - - it 'performs the request' do - expect(client_double.nodes.shutdown(node_id: 'A,B,C')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/nodes/stats_spec.rb b/spec/opensearch/api/actions/nodes/stats_spec.rb deleted file mode 100644 index cc0a33301..000000000 --- a/spec/opensearch/api/actions/nodes/stats_spec.rb +++ /dev/null @@ -1,84 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.nodes#stats' do - let(:expected_args) do - [ - 'GET', - url, - params, - nil, - {} - ] - end - let(:params) do - {} - end - - let(:url) do - '_nodes/stats' - end - - let(:params) do - {} - end - - it 'performs the request' do - expect(client_double.nodes.stats).to eq({}) - end - - context 'when the node id is specified' do - let(:url) do - '_nodes/foo/stats' - end - - it 'performs the request' do - expect(client_double.nodes.stats(node_id: 'foo')).to eq({}) - end - end - - context 'when metrics are specified' do - let(:url) do - '_nodes/stats/http,fs' - end - - it 'performs the request' do - expect(client_double.nodes.stats(metric: %i[http fs])).to eq({}) - end - end - - context 'when index metric is specified' do - let(:url) do - '_nodes/stats/indices/filter_cache' - end - - it 'performs the request' do - expect(client_double.nodes.stats(metric: :indices, index_metric: :filter_cache)).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/ping_spec.rb b/spec/opensearch/api/actions/ping_spec.rb deleted file mode 100644 index 520ef9e6d..000000000 --- a/spec/opensearch/api/actions/ping_spec.rb +++ /dev/null @@ -1,81 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#ping' do - let(:expected_args) do - [ - 'HEAD', - '', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.ping).to be(true) - end - - context 'when the response is a 404' do - let(:response_double) do - double('response', status: 404, body: {}, headers: {}) - end - - it 'returns false' do - expect(client_double.ping).to be(false) - end - end - - context 'when a 404 \'not found\' exception is raised' do - before do - allow(client).to receive(:perform_request).and_raise(StandardError.new('404 NotFound')) - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'returns false' do - expect(client.ping).to be(false) - end - end - - context 'when \'connection failed\' exception is raised' do - before do - allow(client).to receive(:perform_request).and_raise(StandardError.new('ConnectionFailed')) - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'returns false' do - expect(client.ping).to be(false) - end - end -end diff --git a/spec/opensearch/api/actions/put_script_spec.rb b/spec/opensearch/api/actions/put_script_spec.rb deleted file mode 100644 index e93aeb813..000000000 --- a/spec/opensearch/api/actions/put_script_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#put_script' do - let(:url) do - '_scripts/foo' - end - - context 'when the lang parameter is provided' do - let(:expected_args) do - [ - 'PUT', - url, - {}, - { script: 'bar', lang: 'groovy' }, - {} - ] - end - - it 'performs the request' do - expect(client_double.put_script(id: 'foo', body: { script: 'bar', lang: 'groovy' })).to eq({}) - end - end - - context 'when the lang parameter is not provided' do - let(:expected_args) do - [ - 'PUT', - url, - {}, - { script: 'bar' }, - {} - ] - end - - it 'performs the request' do - expect(client_double.put_script(id: 'foo', body: { script: 'bar' })).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/reindex_spec.rb b/spec/opensearch/api/actions/reindex_spec.rb deleted file mode 100644 index bf940ebd5..000000000 --- a/spec/opensearch/api/actions/reindex_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#reindex' do - let(:expected_args) do - [ - 'POST', - '_reindex', - {}, - {}, - {} - ] - end - - it 'performs the request' do - expect(client_double.reindex(body: {})).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/remote/info_spec.rb b/spec/opensearch/api/actions/remote/info_spec.rb deleted file mode 100644 index 1d6ec190b..000000000 --- a/spec/opensearch/api/actions/remote/info_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.remote#info' do - let(:expected_args) do - [ - 'GET', - '_remote/info', - {}, - nil, - nil - ] - end - - it 'performs the request' do - expect(client_double.remote.info).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/remote_store/restore_spec.rb b/spec/opensearch/api/actions/remote_store/restore_spec.rb deleted file mode 100644 index 753b5789d..000000000 --- a/spec/opensearch/api/actions/remote_store/restore_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.remote_store#restore' do - let(:expected_args) do - [ - 'POST', - '_remotestore/_restore', - { cluster_manager_timeout: '1m', - wait_for_completion: true }, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.remote_store.restore - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.remote_store.restore( - cluster_manager_timeout: '1m', - wait_for_completion: true, - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/render_search_template_spec.rb b/spec/opensearch/api/actions/render_search_template_spec.rb deleted file mode 100644 index 19dba9a50..000000000 --- a/spec/opensearch/api/actions/render_search_template_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#render_search_template' do - context 'when no id is specified' do - let(:expected_args) do - [ - 'POST', - '_render/template', - {}, - { foo: 'bar' }, - {} - ] - end - - it 'performs the request' do - expect(client_double.render_search_template(body: { foo: 'bar' })).to eq({}) - end - end - - context 'when id is specified' do - let(:expected_args) do - [ - 'POST', - '_render/template/foo', - {}, - { foo: 'bar' }, - {} - ] - end - - it 'performs the request' do - expect(client_double.render_search_template(id: 'foo', body: { foo: 'bar' })).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/scroll_spec.rb b/spec/opensearch/api/actions/scroll_spec.rb deleted file mode 100644 index 86fdfabda..000000000 --- a/spec/opensearch/api/actions/scroll_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#scroll' do - context 'with scroll_id as a param' do - let(:expected_args) do - [ - 'GET', - '_search/scroll/cXVlcn...', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.scroll(scroll_id: 'cXVlcn...')).to eq({}) - end - end - - context 'with scroll_id in the body' do - let(:expected_args) do - [ - 'POST', - '_search/scroll', - {}, - { scroll_id: 'cXVlcn...' }, - {} - ] - end - - it 'performs the request' do - expect(client_double.scroll(body: { scroll_id: 'cXVlcn...' })).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/search_shards_spec.rb b/spec/opensearch/api/actions/search_shards_spec.rb deleted file mode 100644 index 9efb0942c..000000000 --- a/spec/opensearch/api/actions/search_shards_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#search_shards' do - let(:expected_args) do - [ - 'GET', - '_search_shards', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.search_shards).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/search_spec.rb b/spec/opensearch/api/actions/search_spec.rb deleted file mode 100644 index bcad54743..000000000 --- a/spec/opensearch/api/actions/search_spec.rb +++ /dev/null @@ -1,127 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#search' do - let(:expected_args) do - [ - method, - url, - params, - body, - {} - ] - end - let(:method) { 'GET' } - - let(:body) do - nil - end - - let(:params) do - {} - end - - let(:url) do - '_search' - end - - it 'has a default value for index' do - expect(client_double.search) - end - - context 'when a request definition is specified' do - let(:body) do - { query: { match: {} } } - end - let(:method) { 'POST' } - - let(:url) do - '_search' - end - - it 'performs the request' do - expect(client_double.search(body: { query: { match: {} } })) - end - end - - context 'when an index is specified' do - let(:url) do - 'foo/_search' - end - - it 'performs the request' do - expect(client_double.search(index: 'foo')) - end - end - - context 'when an index is specified' do - let(:url) do - 'foo/_search' - end - - it 'performs the request' do - expect(client_double.search(index: 'foo')) - end - end - - context 'when multiple indices are specified' do - let(:url) do - 'foo,bar/_search' - end - - it 'performs the request' do - expect(client_double.search(index: %w[foo bar])) - end - end - - context 'when there are URL params' do - let(:url) do - '_search' - end - - let(:params) do - { search_type: 'count' } - end - - it 'performs the request' do - expect(client_double.search(search_type: 'count')) - end - end - - context 'when there are invalid URL params' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an ArgumentError' do - expect do - client.search(search_type: 'count', qwertypoiuy: 'asdflkjhg') - end.to raise_exception(ArgumentError) - end - end -end diff --git a/spec/opensearch/api/actions/search_template_spec.rb b/spec/opensearch/api/actions/search_template_spec.rb deleted file mode 100644 index 9902c2a4f..000000000 --- a/spec/opensearch/api/actions/search_template_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#search_template' do - let(:expected_args) do - [ - 'POST', - 'foo/_search/template', - {}, - { foo: 'bar' }, - {} - ] - end - - it 'performs the request' do - expect(client_double.search_template(index: 'foo', body: { foo: 'bar' })).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/change_password_spec.rb b/spec/opensearch/api/actions/security/change_password_spec.rb deleted file mode 100644 index 27af7abe6..000000000 --- a/spec/opensearch/api/actions/security/change_password_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#change_password' do - let(:expected_args) do - [ - 'PUT', - '_plugins/_security/api/account', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.security.change_password - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.change_password( - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/create_action_group_spec.rb b/spec/opensearch/api/actions/security/create_action_group_spec.rb deleted file mode 100644 index 2c1d41d95..000000000 --- a/spec/opensearch/api/actions/security/create_action_group_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#create_action_group' do - let(:expected_args) do - [ - 'PUT', - '_plugins/_security/api/actiongroups/songs', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :action_group argument' do - expect do - client.security.create_action_group - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.create_action_group( - action_group: 'songs', - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/create_role_mapping_spec.rb b/spec/opensearch/api/actions/security/create_role_mapping_spec.rb deleted file mode 100644 index 6b35ec0b7..000000000 --- a/spec/opensearch/api/actions/security/create_role_mapping_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#create_role_mapping' do - let(:expected_args) do - [ - 'PUT', - '_plugins/_security/api/rolesmapping/songs', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :role argument' do - expect do - client.security.create_role_mapping(body: {}) - end.to raise_exception(ArgumentError) - end - - it 'requires the :body argument' do - expect do - client.security.create_role_mapping(role: 'songs') - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.create_role_mapping( - role: 'songs', - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/create_role_spec.rb b/spec/opensearch/api/actions/security/create_role_spec.rb deleted file mode 100644 index 79b9dafc6..000000000 --- a/spec/opensearch/api/actions/security/create_role_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#create_role' do - let(:expected_args) do - [ - 'PUT', - '_plugins/_security/api/roles/songs', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :role argument' do - expect do - client.security.create_role(body: {}) - end.to raise_exception(ArgumentError) - end - - it 'requires the :body argument' do - expect do - client.security.create_role(role: 'songs') - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.create_role( - role: 'songs', - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/create_tenant_spec.rb b/spec/opensearch/api/actions/security/create_tenant_spec.rb deleted file mode 100644 index 4a5136fa2..000000000 --- a/spec/opensearch/api/actions/security/create_tenant_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#create_tenant' do - let(:expected_args) do - [ - 'PUT', - '_plugins/_security/api/tenants/songs', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :tenant argument' do - expect do - client.security.create_tenant - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.create_tenant( - tenant: 'songs', - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/create_user_spec.rb b/spec/opensearch/api/actions/security/create_user_spec.rb deleted file mode 100644 index 5eeaa3d12..000000000 --- a/spec/opensearch/api/actions/security/create_user_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#create_user' do - let(:expected_args) do - [ - 'PUT', - '_plugins/_security/api/internalusers/songs', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :username argument' do - expect do - client.security.create_user(body: {}) - end.to raise_exception(ArgumentError) - end - - it 'requires the :body argument' do - expect do - client.security.create_user(username: 'songs') - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.create_user( - username: 'songs', - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/delete_action_group_spec.rb b/spec/opensearch/api/actions/security/delete_action_group_spec.rb deleted file mode 100644 index 399d5213e..000000000 --- a/spec/opensearch/api/actions/security/delete_action_group_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#delete_action_group' do - let(:expected_args) do - [ - 'DELETE', - '_plugins/_security/api/actiongroups/songs', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :action_group argument' do - expect do - client.security.delete_action_group - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.delete_action_group( - action_group: 'songs' - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/delete_distinguished_names_spec.rb b/spec/opensearch/api/actions/security/delete_distinguished_names_spec.rb deleted file mode 100644 index 3941038dd..000000000 --- a/spec/opensearch/api/actions/security/delete_distinguished_names_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#delete_distinguished_names' do - let(:expected_args) do - [ - 'DELETE', - '_plugins/_security/api/nodesdn/songs', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :cluster_name argument' do - expect do - client.security.delete_distinguished_names - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.delete_distinguished_names( - cluster_name: 'songs' - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/delete_role_mapping_spec.rb b/spec/opensearch/api/actions/security/delete_role_mapping_spec.rb deleted file mode 100644 index b00a44bd8..000000000 --- a/spec/opensearch/api/actions/security/delete_role_mapping_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#delete_role_mapping' do - let(:expected_args) do - [ - 'DELETE', - '_plugins/_security/api/rolesmapping/songs', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :role argument' do - expect do - client.security.delete_role_mapping - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.delete_role_mapping( - role: 'songs' - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/delete_role_spec.rb b/spec/opensearch/api/actions/security/delete_role_spec.rb deleted file mode 100644 index b40f8b977..000000000 --- a/spec/opensearch/api/actions/security/delete_role_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#delete_role' do - let(:expected_args) do - [ - 'DELETE', - '_plugins/_security/api/roles/songs', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :role argument' do - expect do - client.security.delete_role - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.delete_role( - role: 'songs' - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/delete_tenant_spec.rb b/spec/opensearch/api/actions/security/delete_tenant_spec.rb deleted file mode 100644 index 25732e6ec..000000000 --- a/spec/opensearch/api/actions/security/delete_tenant_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#delete_tenant' do - let(:expected_args) do - [ - 'DELETE', - '_plugins/_security/api/tenants/songs', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :tenant argument' do - expect do - client.security.delete_tenant - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.delete_tenant( - tenant: 'songs' - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/delete_user_spec.rb b/spec/opensearch/api/actions/security/delete_user_spec.rb deleted file mode 100644 index 3d8f21b42..000000000 --- a/spec/opensearch/api/actions/security/delete_user_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#delete_user' do - let(:expected_args) do - [ - 'DELETE', - '_plugins/_security/api/internalusers/songs', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :username argument' do - expect do - client.security.delete_user - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.delete_user( - username: 'songs' - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/flush_cache_spec.rb b/spec/opensearch/api/actions/security/flush_cache_spec.rb deleted file mode 100644 index 8eec2ea6d..000000000 --- a/spec/opensearch/api/actions/security/flush_cache_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#flush_cache' do - let(:expected_args) do - [ - 'DELETE', - '_plugins/_security/api/cache', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.flush_cache).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_account_details_spec.rb b/spec/opensearch/api/actions/security/get_account_details_spec.rb deleted file mode 100644 index ac0b725eb..000000000 --- a/spec/opensearch/api/actions/security/get_account_details_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_account_details' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/account', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_account_details).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_action_group_spec.rb b/spec/opensearch/api/actions/security/get_action_group_spec.rb deleted file mode 100644 index 565f231d9..000000000 --- a/spec/opensearch/api/actions/security/get_action_group_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_action_group' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/actiongroups/songs', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :action_group argument' do - expect do - client.security.get_action_group - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_action_group( - action_group: 'songs' - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_action_groups_spec.rb b/spec/opensearch/api/actions/security/get_action_groups_spec.rb deleted file mode 100644 index a95f346e7..000000000 --- a/spec/opensearch/api/actions/security/get_action_groups_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_action_groups' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/actiongroups', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_action_groups).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_audit_configuration_spec.rb b/spec/opensearch/api/actions/security/get_audit_configuration_spec.rb deleted file mode 100644 index 4d20265a1..000000000 --- a/spec/opensearch/api/actions/security/get_audit_configuration_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_audit_configuration' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/audit', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_audit_configuration).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_certificates_spec.rb b/spec/opensearch/api/actions/security/get_certificates_spec.rb deleted file mode 100644 index e1618aa5f..000000000 --- a/spec/opensearch/api/actions/security/get_certificates_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_certificates' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/ssl/certs', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_certificates).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_configuration_spec.rb b/spec/opensearch/api/actions/security/get_configuration_spec.rb deleted file mode 100644 index 91916834c..000000000 --- a/spec/opensearch/api/actions/security/get_configuration_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_configuration' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/securityconfig', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_configuration).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_distinguished_names_spec.rb b/spec/opensearch/api/actions/security/get_distinguished_names_spec.rb deleted file mode 100644 index 9b44b0daa..000000000 --- a/spec/opensearch/api/actions/security/get_distinguished_names_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_distinguished_names' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/nodesdn/songs', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_distinguished_names( - cluster_name: 'songs' - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_role_mapping_spec.rb b/spec/opensearch/api/actions/security/get_role_mapping_spec.rb deleted file mode 100644 index 189cd860b..000000000 --- a/spec/opensearch/api/actions/security/get_role_mapping_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_role_mapping' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/rolesmapping/songs', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :role argument' do - expect do - client.security.get_role_mapping - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_role_mapping( - role: 'songs' - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_role_mappings_spec.rb b/spec/opensearch/api/actions/security/get_role_mappings_spec.rb deleted file mode 100644 index 728c10d3d..000000000 --- a/spec/opensearch/api/actions/security/get_role_mappings_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_role_mappings' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/rolesmapping', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_role_mappings).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_role_spec.rb b/spec/opensearch/api/actions/security/get_role_spec.rb deleted file mode 100644 index 6eeffa43e..000000000 --- a/spec/opensearch/api/actions/security/get_role_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_role' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/roles/songs', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :role argument' do - expect do - client.security.get_role - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_role( - role: 'songs' - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_roles_spec.rb b/spec/opensearch/api/actions/security/get_roles_spec.rb deleted file mode 100644 index 9653cad29..000000000 --- a/spec/opensearch/api/actions/security/get_roles_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_roles' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/roles', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_roles).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_tenant_spec.rb b/spec/opensearch/api/actions/security/get_tenant_spec.rb deleted file mode 100644 index cbfa1cb16..000000000 --- a/spec/opensearch/api/actions/security/get_tenant_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_tenant' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/tenants/songs', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :tenant argument' do - expect do - client.security.get_tenant - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_tenant( - tenant: 'songs' - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_tenants_spec.rb b/spec/opensearch/api/actions/security/get_tenants_spec.rb deleted file mode 100644 index 241788eb7..000000000 --- a/spec/opensearch/api/actions/security/get_tenants_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_tenants' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/tenants', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_tenants).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_user_spec.rb b/spec/opensearch/api/actions/security/get_user_spec.rb deleted file mode 100644 index 44e356158..000000000 --- a/spec/opensearch/api/actions/security/get_user_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_user' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/internalusers/songs', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :username argument' do - expect do - client.security.get_user - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_user( - username: 'songs' - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/get_users_spec.rb b/spec/opensearch/api/actions/security/get_users_spec.rb deleted file mode 100644 index dfaa30ee7..000000000 --- a/spec/opensearch/api/actions/security/get_users_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#get_users' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/api/internalusers', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.get_users).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/health_spec.rb b/spec/opensearch/api/actions/security/health_spec.rb deleted file mode 100644 index c8d87157e..000000000 --- a/spec/opensearch/api/actions/security/health_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#health' do - let(:expected_args) do - [ - 'GET', - '_plugins/_security/health', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.health).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/patch_action_group_spec.rb b/spec/opensearch/api/actions/security/patch_action_group_spec.rb deleted file mode 100644 index fe3394841..000000000 --- a/spec/opensearch/api/actions/security/patch_action_group_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#patch_action_group' do - let(:expected_args) do - [ - 'PATCH', - '_plugins/_security/api/actiongroups/songs', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :action_group argument' do - expect do - client.security.patch_action_group - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.patch_action_group( - action_group: 'songs', - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/patch_action_groups_spec.rb b/spec/opensearch/api/actions/security/patch_action_groups_spec.rb deleted file mode 100644 index 2a70e3dbf..000000000 --- a/spec/opensearch/api/actions/security/patch_action_groups_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#patch_action_groups' do - let(:expected_args) do - [ - 'PATCH', - '_plugins/_security/api/actiongroups', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.patch_action_groups( - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/patch_audit_configuration_spec.rb b/spec/opensearch/api/actions/security/patch_audit_configuration_spec.rb deleted file mode 100644 index 4f1d51973..000000000 --- a/spec/opensearch/api/actions/security/patch_audit_configuration_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#patch_audit_configuration' do - let(:expected_args) do - [ - 'PATCH', - '_plugins/_security/api/audit', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.security.patch_audit_configuration - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.patch_audit_configuration( - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/patch_configuration_spec.rb b/spec/opensearch/api/actions/security/patch_configuration_spec.rb deleted file mode 100644 index 49a04672f..000000000 --- a/spec/opensearch/api/actions/security/patch_configuration_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#patch_configuration' do - let(:expected_args) do - [ - 'PATCH', - '_plugins/_security/api/securityconfig', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.security.patch_configuration - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.patch_configuration( - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/patch_distinguished_names_spec.rb b/spec/opensearch/api/actions/security/patch_distinguished_names_spec.rb deleted file mode 100644 index e951c939c..000000000 --- a/spec/opensearch/api/actions/security/patch_distinguished_names_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#patch_distinguished_names' do - let(:expected_args) do - [ - 'PATCH', - '_plugins/_security/api/nodesdn', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.security.patch_distinguished_names - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.patch_distinguished_names( - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/patch_role_mapping_spec.rb b/spec/opensearch/api/actions/security/patch_role_mapping_spec.rb deleted file mode 100644 index f209f1c26..000000000 --- a/spec/opensearch/api/actions/security/patch_role_mapping_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#patch_role_mapping' do - let(:expected_args) do - [ - 'PATCH', - '_plugins/_security/api/rolesmapping/songs', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :role argument' do - expect do - client.security.patch_role_mapping(body: {}) - end.to raise_exception(ArgumentError) - end - - it 'requires the :body argument' do - expect do - client.security.patch_role_mapping(role: 'songs') - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.patch_role_mapping( - role: 'songs', - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/patch_role_mappings_spec.rb b/spec/opensearch/api/actions/security/patch_role_mappings_spec.rb deleted file mode 100644 index 73ed8c8e4..000000000 --- a/spec/opensearch/api/actions/security/patch_role_mappings_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#patch_role_mappings' do - let(:expected_args) do - [ - 'PATCH', - '_plugins/_security/api/rolesmapping', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.security.patch_role_mappings - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.patch_role_mappings( - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/patch_role_spec.rb b/spec/opensearch/api/actions/security/patch_role_spec.rb deleted file mode 100644 index b083c8073..000000000 --- a/spec/opensearch/api/actions/security/patch_role_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#patch_role' do - let(:expected_args) do - [ - 'PATCH', - '_plugins/_security/api/roles/songs', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :role argument' do - expect do - client.security.patch_role(body: {}) - end.to raise_exception(ArgumentError) - end - - it 'requires the :body argument' do - expect do - client.security.patch_role(role: 'songs') - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.patch_role( - role: 'songs', - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/patch_roles_spec.rb b/spec/opensearch/api/actions/security/patch_roles_spec.rb deleted file mode 100644 index 22cf8f632..000000000 --- a/spec/opensearch/api/actions/security/patch_roles_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#patch_roles' do - let(:expected_args) do - [ - 'PATCH', - '_plugins/_security/api/roles', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.security.patch_roles - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.patch_roles( - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/patch_tenant_spec.rb b/spec/opensearch/api/actions/security/patch_tenant_spec.rb deleted file mode 100644 index c80e556be..000000000 --- a/spec/opensearch/api/actions/security/patch_tenant_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#patch_tenant' do - let(:expected_args) do - [ - 'PATCH', - '_plugins/_security/api/tenants/songs', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :tenant argument' do - expect do - client.security.patch_tenant(body: {}) - end.to raise_exception(ArgumentError) - end - - it 'requires the :body argument' do - expect do - client.security.patch_tenant(tenant: 'songs') - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.patch_tenant( - tenant: 'songs', - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/patch_tenants_spec.rb b/spec/opensearch/api/actions/security/patch_tenants_spec.rb deleted file mode 100644 index 26fce590c..000000000 --- a/spec/opensearch/api/actions/security/patch_tenants_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#patch_tenants' do - let(:expected_args) do - [ - 'PATCH', - '_plugins/_security/api/tenants', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.security.patch_tenants - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.patch_tenants( - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/patch_user_spec.rb b/spec/opensearch/api/actions/security/patch_user_spec.rb deleted file mode 100644 index 7ba378272..000000000 --- a/spec/opensearch/api/actions/security/patch_user_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#patch_user' do - let(:expected_args) do - [ - 'PATCH', - '_plugins/_security/api/internalusers/songs', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :username argument' do - expect do - client.security.patch_user(body: {}) - end.to raise_exception(ArgumentError) - end - - it 'requires the :body argument' do - expect do - client.security.patch_user(username: 'songs') - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.patch_user( - username: 'songs', - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/patch_users_spec.rb b/spec/opensearch/api/actions/security/patch_users_spec.rb deleted file mode 100644 index 02727e2d4..000000000 --- a/spec/opensearch/api/actions/security/patch_users_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#patch_users' do - let(:expected_args) do - [ - 'PATCH', - '_plugins/_security/api/internalusers', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.security.patch_users - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.patch_users( - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/reload_http_certificates_spec.rb b/spec/opensearch/api/actions/security/reload_http_certificates_spec.rb deleted file mode 100644 index cfbab27c9..000000000 --- a/spec/opensearch/api/actions/security/reload_http_certificates_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#reload_http_certificates' do - let(:expected_args) do - [ - 'PUT', - '_plugins/_security/api/ssl/http/reloadcerts', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.reload_http_certificates).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/reload_transport_certificates_spec.rb b/spec/opensearch/api/actions/security/reload_transport_certificates_spec.rb deleted file mode 100644 index 2dbc388eb..000000000 --- a/spec/opensearch/api/actions/security/reload_transport_certificates_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#reload_transport_certificates' do - let(:expected_args) do - [ - 'PUT', - '_plugins/_security/api/ssl/transport/reloadcerts', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request with all optional params' do - expect(client_double.security.reload_transport_certificates).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/update_audit_configuration_spec.rb b/spec/opensearch/api/actions/security/update_audit_configuration_spec.rb deleted file mode 100644 index 8aafb0b07..000000000 --- a/spec/opensearch/api/actions/security/update_audit_configuration_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#update_audit_configuration' do - let(:expected_args) do - [ - 'PUT', - '_plugins/_security/api/audit/config', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.security.update_audit_configuration - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.update_audit_configuration( - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/update_configuration_spec.rb b/spec/opensearch/api/actions/security/update_configuration_spec.rb deleted file mode 100644 index b0ee4cc9b..000000000 --- a/spec/opensearch/api/actions/security/update_configuration_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#update_configuration' do - let(:expected_args) do - [ - 'PUT', - '_plugins/_security/api/securityconfig/config', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.security.update_configuration - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.update_configuration( - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/security/update_distinguished_names_spec.rb b/spec/opensearch/api/actions/security/update_distinguished_names_spec.rb deleted file mode 100644 index 076d0bf75..000000000 --- a/spec/opensearch/api/actions/security/update_distinguished_names_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -# This code was generated from OpenSearch API Spec. -# Update the code generation logic instead of modifying this file directly. - -# frozen_string_literal: true - -require_relative '../../../../spec_helper' - -describe 'client.security#update_distinguished_names' do - let(:expected_args) do - [ - 'PUT', - '_plugins/_security/api/nodesdn/songs', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :cluster_name argument' do - expect do - client.security.update_distinguished_names - end.to raise_exception(ArgumentError) - end - - it 'performs the request with all optional params' do - expect(client_double.security.update_distinguished_names( - cluster_name: 'songs', - body: {} - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/shutdown/delete_node_spec.rb b/spec/opensearch/api/actions/shutdown/delete_node_spec.rb deleted file mode 100644 index 76a9eeddb..000000000 --- a/spec/opensearch/api/actions/shutdown/delete_node_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.shutdown#delete_node' do - let(:expected_args) do - [ - 'DELETE', - '_nodes/id/shutdown', - {}, - nil, - {} - ] - end - let(:client) do - Class.new { include OpenSearch::API }.new - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request' do - expect(client_double.shutdown.delete_node(node_id: 'id')).to eq({}) - end - - it 'raises an error if no node_id is provided' do - expect do - client.shutdown.delete_node - end.to raise_exception(ArgumentError) - end -end diff --git a/spec/opensearch/api/actions/shutdown/get_node_spec.rb b/spec/opensearch/api/actions/shutdown/get_node_spec.rb deleted file mode 100644 index 7bed2f475..000000000 --- a/spec/opensearch/api/actions/shutdown/get_node_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.shutdown#get_node' do - let(:expected_args) do - [ - 'GET', - url, - {}, - nil, - {} - ] - end - - context 'when id is provided' do - let(:url) { '_nodes/id/shutdown' } - - it 'performs the request' do - expect(client_double.shutdown.get_node(node_id: 'id')).to eq({}) - end - end - - context 'when no id is provided' do - let(:url) { '_nodes/shutdown' } - - it 'performs the request' do - expect(client_double.shutdown.get_node).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/shutdown/put_node_spec.rb b/spec/opensearch/api/actions/shutdown/put_node_spec.rb deleted file mode 100644 index d6f97c533..000000000 --- a/spec/opensearch/api/actions/shutdown/put_node_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.shutdown#put_node' do - let(:expected_args) do - [ - 'PUT', - '_nodes/id/shutdown', - {}, - {}, - {} - ] - end - let(:client) do - Class.new { include OpenSearch::API }.new - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request' do - expect(client_double.shutdown.put_node(body: {}, node_id: 'id')).to eq({}) - end - - it 'raises an error if no node_id is provided' do - expect do - client.shutdown.put_node(body: {}) - end.to raise_exception(ArgumentError) - end - - it 'raises an error if no body is provided' do - expect do - client.shutdown.put_node(node_id: 'id') - end.to raise_exception(ArgumentError) - end -end diff --git a/spec/opensearch/api/actions/snapshot/clone_spec.rb b/spec/opensearch/api/actions/snapshot/clone_spec.rb deleted file mode 100644 index 9d5de5745..000000000 --- a/spec/opensearch/api/actions/snapshot/clone_spec.rb +++ /dev/null @@ -1,76 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.snapshot#clone' do - let(:expected_args) do - [ - 'PUT', - '_snapshot/foo/bar/_clone/snapshot', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.snapshot.clone(snapshot: 'bar') - end.to raise_exception(ArgumentError) - end - - it 'requires the :repository argument' do - expect do - client.snapshot.clone(snapshot: 'foo', body: {}) - end.to raise_exception(ArgumentError) - end - - it 'requires the :snapshot argument' do - expect do - client.snapshot.clone(repository: 'foo', body: {}) - end.to raise_exception(ArgumentError) - end - - it 'requires the :target_snapshot argument' do - expect do - client.snapshot.clone(repository: 'foo', body: {}, snapshot: 'bar') - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.snapshot.clone( - repository: 'foo', - snapshot: 'bar', - body: {}, - target_snapshot: 'snapshot' - )).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/snapshot/create_repository_spec.rb b/spec/opensearch/api/actions/snapshot/create_repository_spec.rb deleted file mode 100644 index 9731ec729..000000000 --- a/spec/opensearch/api/actions/snapshot/create_repository_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.snapshot#create_repository' do - let(:expected_args) do - [ - 'PUT', - '_snapshot/foo', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :body argument' do - expect do - client.snapshot.create_repository(repository: 'foo') - end.to raise_exception(ArgumentError) - end - - it 'requires the :repository argument' do - expect do - client.snapshot.create_repository(body: {}) - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.snapshot.create_repository(repository: 'foo', body: {})).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/snapshot/create_spec.rb b/spec/opensearch/api/actions/snapshot/create_spec.rb deleted file mode 100644 index 9d2dcb58b..000000000 --- a/spec/opensearch/api/actions/snapshot/create_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.snapshot#create' do - let(:expected_args) do - [ - 'PUT', - '_snapshot/foo/bar', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :repository argument' do - expect do - client.snapshot.create(snapshot: 'bar', body: {}) - end.to raise_exception(ArgumentError) - end - - it 'requires the :snapshot argument' do - expect do - client.snapshot.create(repository: 'foo', body: {}) - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.snapshot.create(repository: 'foo', snapshot: 'bar', body: {})).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/snapshot/delete_repository_spec.rb b/spec/opensearch/api/actions/snapshot/delete_repository_spec.rb deleted file mode 100644 index f1402d712..000000000 --- a/spec/opensearch/api/actions/snapshot/delete_repository_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.snapshot#delete_repository' do - let(:expected_args) do - [ - 'DELETE', - url, - {}, - nil, - {} - ] - end - - let(:url) do - '_snapshot/foo' - end - - it 'performs the request' do - expect(client_double.snapshot.delete_repository(repository: 'foo')).to eq({}) - end - - context 'when multiple indices are specified' do - let(:url) do - '_snapshot/foo,bar' - end - - it 'performs the request' do - expect(client_double.snapshot.delete_repository(repository: %w[foo bar])).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/snapshot/delete_spec.rb b/spec/opensearch/api/actions/snapshot/delete_spec.rb deleted file mode 100644 index 373af74ad..000000000 --- a/spec/opensearch/api/actions/snapshot/delete_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.snapshot#delete' do - let(:expected_args) do - [ - 'DELETE', - '_snapshot/foo/bar', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :snapshot argument' do - expect do - client.snapshot.delete(repository: 'foo') - end.to raise_exception(ArgumentError) - end - - it 'requires the :repository argument' do - expect do - client.snapshot.delete(snapshot: 'bar') - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.snapshot.delete(repository: 'foo', snapshot: 'bar')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/snapshot/get_features_spec.rb b/spec/opensearch/api/actions/snapshot/get_features_spec.rb deleted file mode 100644 index bfcf7e626..000000000 --- a/spec/opensearch/api/actions/snapshot/get_features_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.snapshot#get' do - let(:expected_args) do - [ - 'GET', - '_snapshottable_features', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request' do - expect(client_double.snapshot.get_features).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/snapshot/get_repository_spec.rb b/spec/opensearch/api/actions/snapshot/get_repository_spec.rb deleted file mode 100644 index fc2ac2efa..000000000 --- a/spec/opensearch/api/actions/snapshot/get_repository_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.snapshot#get_repository' do - let(:expected_args) do - [ - 'GET', - '_snapshot/foo', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.snapshot.get_repository(repository: 'foo')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/snapshot/get_spec.rb b/spec/opensearch/api/actions/snapshot/get_spec.rb deleted file mode 100644 index 487bb3dd5..000000000 --- a/spec/opensearch/api/actions/snapshot/get_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.snapshot#get' do - let(:expected_args) do - [ - 'GET', - '_snapshot/foo/bar', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :snapshot argument' do - expect do - client.snapshot.get(repository: 'foo') - end.to raise_exception(ArgumentError) - end - - it 'requires the :repository argument' do - expect do - client.snapshot.get(snapshot: 'bar') - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.snapshot.get(repository: 'foo', snapshot: 'bar')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/snapshot/repository_analize_spec.rb b/spec/opensearch/api/actions/snapshot/repository_analize_spec.rb deleted file mode 100644 index 5f2b61b1b..000000000 --- a/spec/opensearch/api/actions/snapshot/repository_analize_spec.rb +++ /dev/null @@ -1,60 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.snapshot#repository_analyze' do - let(:expected_args) do - [ - 'POST', - url, - {}, - nil, - {} - ] - end - let(:client) do - Class.new { include OpenSearch::API }.new - end - - let(:url) do - '_snapshot/foo/_analyze' - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'performs the request' do - expect(client_double.snapshot.repository_analyze(repository: 'foo')).to eq({}) - end - - it 'requires the :repository argument' do - expect do - client.snapshot.repository_analyze - end.to raise_exception(ArgumentError) - end -end diff --git a/spec/opensearch/api/actions/snapshot/restore_spec.rb b/spec/opensearch/api/actions/snapshot/restore_spec.rb deleted file mode 100644 index 06fa1bb0d..000000000 --- a/spec/opensearch/api/actions/snapshot/restore_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.snapshot#restore' do - let(:expected_args) do - [ - 'POST', - '_snapshot/foo/bar/_restore', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :snapshot argument' do - expect do - client.snapshot.restore(repository: 'foo') - end.to raise_exception(ArgumentError) - end - - it 'requires the :repository argument' do - expect do - client.snapshot.restore(snapshot: 'bar') - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.snapshot.restore(repository: 'foo', snapshot: 'bar')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/snapshot/status_spec.rb b/spec/opensearch/api/actions/snapshot/status_spec.rb deleted file mode 100644 index 3bb0540f5..000000000 --- a/spec/opensearch/api/actions/snapshot/status_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.snapshot#status' do - let(:expected_args) do - [ - 'GET', - url, - {}, - nil, - {} - ] - end - - let(:url) do - '_snapshot/_status' - end - - it 'performs the request' do - expect(client_double.snapshot.status).to eq({}) - end - - context 'when a repository and snapshot are specified' do - let(:url) do - '_snapshot/foo/bar/_status' - end - - it 'performs the request' do - expect(client_double.snapshot.status(repository: 'foo', snapshot: 'bar')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/snapshot/verify_repository_spec.rb b/spec/opensearch/api/actions/snapshot/verify_repository_spec.rb deleted file mode 100644 index f3b11f363..000000000 --- a/spec/opensearch/api/actions/snapshot/verify_repository_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.snapshot#verify_repository' do - let(:expected_args) do - [ - 'POST', - '_snapshot/foo/_verify', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.snapshot.verify_repository(repository: 'foo')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/tasks/cancel_spec.rb b/spec/opensearch/api/actions/tasks/cancel_spec.rb deleted file mode 100644 index d9521ad33..000000000 --- a/spec/opensearch/api/actions/tasks/cancel_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.tasks#cancel' do - let(:expected_args) do - [ - 'POST', - url, - {}, - nil, - {} - ] - end - - let(:url) do - '_tasks/_cancel' - end - - it 'performs the request' do - expect(client_double.tasks.cancel).to eq({}) - end - - context 'when a task id is specified' do - let(:url) do - '_tasks/foo/_cancel' - end - - it 'performs the request' do - expect(client_double.tasks.cancel(task_id: 'foo')).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/tasks/get_spec.rb b/spec/opensearch/api/actions/tasks/get_spec.rb deleted file mode 100644 index cad591552..000000000 --- a/spec/opensearch/api/actions/tasks/get_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.tasks#get' do - let(:expected_args) do - [ - 'GET', - '_tasks/foo1', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.tasks.get(task_id: 'foo1')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/tasks/list_spec.rb b/spec/opensearch/api/actions/tasks/list_spec.rb deleted file mode 100644 index 532d2455b..000000000 --- a/spec/opensearch/api/actions/tasks/list_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../../spec_helper' - -describe 'client.tasks#list' do - let(:expected_args) do - [ - 'GET', - url, - {}, - nil, - {} - ] - end - - let(:url) do - '_tasks' - end - - it 'performs the request' do - expect(client_double.tasks.list).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/termvectors_spec.rb b/spec/opensearch/api/actions/termvectors_spec.rb deleted file mode 100644 index 4694bace8..000000000 --- a/spec/opensearch/api/actions/termvectors_spec.rb +++ /dev/null @@ -1,75 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#termvectors' do - let(:expected_args) do - [ - 'POST', - url, - params, - body, - {} - ] - end - - let(:url) do - 'foo/_termvectors/123' - end - - let(:params) do - {} - end - - let(:body) do - {} - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'requires the :index argument' do - expect do - client.termvectors(id: '1') - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.termvectors(index: 'foo', id: '123', body: {})).to eq({}) - end - - context 'when the older api name \'termvector\' is used' do - let(:url) do - 'foo/_termvector/123' - end - - it 'performs the request' do - expect(client_double.termvector(index: 'foo', id: '123', body: {})).to eq({}) - end - end -end diff --git a/spec/opensearch/api/actions/update_by_query_spec.rb b/spec/opensearch/api/actions/update_by_query_spec.rb deleted file mode 100644 index bb5c53e26..000000000 --- a/spec/opensearch/api/actions/update_by_query_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#update_by_query' do - let(:expected_args) do - [ - 'POST', - 'foo/_update_by_query', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.update_by_query(index: 'foo')).to eq({}) - end -end diff --git a/spec/opensearch/api/actions/update_document_spec.rb b/spec/opensearch/api/actions/update_document_spec.rb deleted file mode 100644 index 755e12b3a..000000000 --- a/spec/opensearch/api/actions/update_document_spec.rb +++ /dev/null @@ -1,125 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' - -describe 'client#update' do - let(:expected_args) do - [ - 'POST', - url, - params, - body, - {} - ] - end - - let(:body) do - { doc: {} } - end - - let(:url) do - 'foo/_update/1' - end - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - let(:params) do - {} - end - - it 'requires the :index argument' do - expect do - client.update(id: '1') - end.to raise_exception(ArgumentError) - end - - it 'requires the :id argument' do - expect do - client.update(index: 'foo') - end.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.update(index: 'foo', id: '1', body: { doc: {} })).to eq({}) - end - - context 'when URL parameters are provided' do - let(:url) do - 'foo/_update/1' - end - - let(:body) do - {} - end - - it 'performs the request' do - expect(client_double.update(index: 'foo', id: '1', body: {})) - end - end - - context 'when invalid parameters are specified' do - it 'raises an ArgumentError' do - expect do - client.update(index: 'foo', id: '1', body: { doc: {} }, qwertypoiuy: 'asdflkjhg') - end.to raise_exception(ArgumentError) - end - end - - context 'when the request needs to be URL-escaped' do - let(:url) do - 'foo%5Ebar/_update/1' - end - - let(:body) do - {} - end - - it 'escapes the parts' do - expect(client_double.update(index: 'foo^bar', id: '1', body: {})) - end - end - - context 'when a NotFound exception is raised' do - before do - allow(client).to receive(:perform_request).and_raise(NotFound) - end - - it 'raises it to the user' do - expect do - client.update(index: 'foo', id: 'XXX', body: {}) - end.to raise_exception(NotFound) - end - - context 'when the :ignore parameter is specified' do - it 'does not raise the error to the user' do - expect(client.update(index: 'foo', id: 'XXX', body: {}, ignore: 404)).to be(false) - end - end - end -end diff --git a/spec/opensearch/api/client_spec.rb b/spec/opensearch/api/client_spec.rb deleted file mode 100644 index 905cf93e3..000000000 --- a/spec/opensearch/api/client_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../spec_helper' - -describe 'API Client' do - let(:client) do - Class.new { include OpenSearch::API }.new - end - - describe '#cluster' do - it 'responds to the method' do - expect(client.respond_to?(:cluster)).to be(true) - end - end - - describe '#indices' do - it 'responds to the method' do - expect(client.respond_to?(:indices)).to be(true) - end - end - - describe '#bulk' do - it 'responds to the method' do - expect(client.respond_to?(:bulk)).to be(true) - end - end -end diff --git a/spec/opensearch/api/utils_spec.rb b/spec/opensearch/api/utils_spec.rb index 101cfe9fe..2720e6fe2 100644 --- a/spec/opensearch/api/utils_spec.rb +++ b/spec/opensearch/api/utils_spec.rb @@ -27,81 +27,59 @@ require_relative '../../spec_helper' describe OpenSearch::API::Utils do - let(:utils) do - Class.new { include OpenSearch::API::Utils }.new - end - - describe '#__escape' do - it 'encodes Unicode characters' do - expect(utils.__escape('中文')).to eq('%E4%B8%AD%E6%96%87') - end - - it 'encodes special characters' do - expect(utils.__escape('foo bar')).to eq('foo+bar') - expect(utils.__escape('foo/bar')).to eq('foo%2Fbar') - expect(utils.__escape('foo^bar')).to eq('foo%5Ebar') - end - - it 'does not encode asterisks' do - expect(utils.__escape('*')).to eq('*') - end - - it 'uses CGI.escape by default' do - expect(CGI).to receive(:escape).and_call_original - expect(utils.__escape('foo bar')).to eq('foo+bar') + describe '#normalize_arguments' do + subject(:normalized) { described_class.normalize_arguments(arguments) } + + let(:arguments) do + { hello: 'world', + 'hello' => 'world 2', + hash: { bar: 'baz' }, + 'number' => 42, + string: 'amazing spider-man, big & small', + bool: true, + 'nil' => nil, + 'array' => [1, 2, 3], + ignore: [404] } + end + + it 'returns a new hash with keys as strings and values normalized except those of NON_URL_ARGS' do + is_expected.to eq({ + 'hello' => 'world+2', + 'hash' => { bar: 'baz' }, + 'number' => '42', + 'bool' => 'true', + 'string' => 'amazing+spider-man,+big+%26+small', + 'nil' => '', + 'array' => '1,2,3', + 'ignore' => [404] + }) end end - describe '#__listify' do - it 'creates a list from a single value' do - expect(utils.__listify('foo')).to eq('foo') - end - - it 'creates a list from an array' do - expect(utils.__listify(%w[foo bar])).to eq('foo,bar') - end - - it 'creates a list from multiple arguments' do - expect(utils.__listify('foo', 'bar')).to eq('foo,bar') - end - - it 'ignores nil values' do - expect(utils.__listify(['foo', nil, 'bar'])).to eq('foo,bar') - end + describe '#validate_query_params' do + subject(:validate) { described_class.validate_query_params(params, Set.new(%w[foo bar])) } - it 'ignores special characters' do - expect(utils.__listify(['foo', 'bar^bam'])).to eq('foo,bar%5Ebam') - end + context 'when the params are valid' do + let(:params) { { 'foo' => true, 'bar' => nil, 'human' => 'yes' } } - context 'when the escape option is set to false' do - it 'does not escape the characters' do - expect(utils.__listify(['foo', 'bar^bam'], escape: false)).to eq('foo,bar^bam') + it 'does not raise an error' do + expect { validate }.not_to raise_error end end - end - - describe '#__pathify' do - it 'creates a path from a single value' do - expect(utils.__pathify('foo')).to eq('foo') - end - - it 'creates a path from an array' do - expect(utils.__pathify(%w[foo bar])).to eq('foo/bar') - end - it 'ignores nil values' do - expect(utils.__pathify(['foo', nil, 'bar'])).to eq('foo/bar') - end + context 'when the params are invalid' do + let(:params) { { 'foo' => true, 'bar' => nil, 'human' => 'yes', 'waldo' => 'hello' } } - it 'ignores empty string values' do - expect(utils.__pathify(['foo', '', 'bar'])).to eq('foo/bar') + it 'raises an error' do + expect { validate }.to raise_error(ArgumentError, "URL parameter 'waldo' is not supported") + end end end - describe '#__bulkify' do + describe '#bulkify' do context 'when the input is an array of hashes' do let(:result) do - utils.__bulkify [ + described_class.bulkify [ { index: { _index: 'myindexA', _id: '1', data: { title: 'Test' } } }, { update: { _index: 'myindexB', _id: '2', data: { doc: { title: 'Update' } } } }, { delete: { _index: 'myindexC', _id: '3' } } @@ -125,7 +103,7 @@ context 'when the input is an array of strings' do let(:result) do - utils.__bulkify(['{"foo":"bar"}', '{"moo":"bam"}']) + described_class.bulkify(['{"foo":"bar"}', '{"moo":"bam"}']) end let(:expected_string) do @@ -142,7 +120,7 @@ context 'when the input is an array of header/data pairs' do let(:result) do - utils.__bulkify([{ foo: 'bar' }, { moo: 'bam' }, { foo: 'baz' }]) + described_class.bulkify([{ foo: 'bar' }, { moo: 'bam' }, { foo: 'baz' }]) end let(:expected_string) do @@ -164,7 +142,7 @@ end let(:result) do - utils.__bulkify([input]) + described_class.bulkify([input]) end let(:expected_string) do @@ -189,7 +167,7 @@ end let(:result) do - utils.__bulkify([{ index: { foo: 'bar' } }, data]) + described_class.bulkify([{ index: { foo: 'bar' } }, data]) end let(:lines) do @@ -215,191 +193,4 @@ end end end - - describe '#__validate_and_extract_params' do - it 'listify Arrays' do - expect(utils.__validate_and_extract_params({ foo: %w[a b] }, [:foo])).to eq(foo: 'a,b') - end - - it 'does not escape the parameters' do - expect(utils.__validate_and_extract_params({ foo: ['a.*', 'b.*'] }, [:foo])).to eq(foo: 'a.*,b.*') - end - - context 'when the params are valid' do - it 'extracts the valid params from the hash' do - expect(utils.__validate_and_extract_params({ foo: 'qux' }, %i[foo bar])).to eq(foo: 'qux') - end - end - - context 'when the params are invalid' do - it 'raises an ArgumentError' do - expect do - utils.__validate_and_extract_params({ foo: 'qux', bam: 'mux' }, %i[foo bar]) - end.to raise_exception(ArgumentError) - end - end - - context 'when COMMON_PARAMS are provided' do - it 'extracts the params' do - expect(utils.__validate_and_extract_params({ index: 'foo' }, [:foo])).to eq({}) - end - end - - context 'when COMMON_QUERY_PARAMS are provided' do - it 'extracts the params' do - expect(utils.__validate_and_extract_params(format: 'yaml')).to eq(format: 'yaml') - end - end - - context 'when the :skip_paramter_validation option is set' do - let(:result) do - utils.__validate_and_extract_params({ foo: 'q', bam: 'm' }, %i[foo bar], { skip_parameter_validation: true }) - end - - it 'skips parameter validation' do - expect(result).to eq(foo: 'q', bam: 'm') - end - end - - context 'when the module has the setting to skip parameter validation' do - around do |example| - original_value = OpenSearch::API.settings[:skip_parameter_validation] - OpenSearch::API.settings[:skip_parameter_validation] = true - example.run - OpenSearch::API.settings[:skip_parameter_validation] = original_value - end - - let(:result) do - utils.__validate_and_extract_params({ foo: 'q', bam: 'm' }, %i[foo bar]) - end - - it 'applies the module setting' do - expect(result).to eq(foo: 'q', bam: 'm') - end - end - end - - describe '#__extract_parts' do - it 'extracts parts with true value from a Hash' do - expect(utils.__extract_parts({ foo: true, moo: 'blah' }, %i[foo bar])).to eq(['foo']) - end - - it 'extracts parts with string value from a Hash' do - expect(utils.__extract_parts({ foo: 'qux', moo: 'blah' }, %i[foo bar])).to eq(['qux']) - end - end - - describe '#__rescue_from_not_found' do - it 'returns false if exception class name contains \'NotFound\'' do - expect(utils.__rescue_from_not_found { raise NotFound }).to be(false) - end - - it 'returns false if exception message contains \'Not Found\'' do - expect(utils.__rescue_from_not_found { raise StandardError, 'Not Found' }).to be(false) - expect(utils.__rescue_from_not_found { raise StandardError, 'NotFound' }).to be(false) - end - - it 'raises the exception if the class name and message do not include \'NotFound\'' do - expect do - utils.__rescue_from_not_found { raise StandardError, 'Any other exception' } - end.to raise_exception(StandardError) - end - end - - describe '#__report_unsupported_parameters' do - context 'when the parameters are passed as Symbols' do - let(:arguments) do - { foo: 'bar', moo: 'bam', baz: 'qux' } - end - - let(:unsupported_params) do - %i[foo moo] - end - - let(:message) do - message = '' - expect(Kernel).to receive(:warn) { |msg| message = msg } - utils.__report_unsupported_parameters(arguments, unsupported_params) - message - end - - it 'prints the unsupported parameters' do - expect(message).to match(/You are using unsupported parameter \[:foo\]/) - expect(message).to match(/You are using unsupported parameter \[:moo\]/) - end - end - - context 'when the parameters are passed as Hashes' do - let(:arguments) do - { foo: 'bar', moo: 'bam', baz: 'qux' } - end - - let(:unsupported_params) do - %i[foo moo] - end - - let(:message) do - message = '' - expect(Kernel).to receive(:warn) { |msg| message = msg } - utils.__report_unsupported_parameters(arguments, unsupported_params) - message - end - - it 'prints the unsupported parameters' do - expect(message).to match(/You are using unsupported parameter \[:foo\]/) - expect(message).to match(/You are using unsupported parameter \[:moo\]/) - end - end - - context 'when the parameters are passed as a mix of Hashes and Symbols' do - let(:arguments) do - { foo: 'bar', moo: 'bam', baz: 'qux' } - end - - let(:unsupported_params) do - [{ foo: { explanation: 'NOT_SUPPORTED' } }, :moo] - end - - let(:message) do - message = '' - expect(Kernel).to receive(:warn) { |msg| message = msg } - utils.__report_unsupported_parameters(arguments, unsupported_params) - message - end - - it 'prints the unsupported parameters' do - expect(message).to match(/You are using unsupported parameter \[:foo\]/) - expect(message).to match(/You are using unsupported parameter \[:moo\]/) - expect(message).to match(/NOT_SUPPORTED/) - end - end - - context 'when unsupported parameters are unused' do - let(:arguments) do - { moo: 'bam', baz: 'qux' } - end - - let(:unsupported_params) do - [:foo] - end - - it 'prints the unsupported parameters' do - expect(Kernel).not_to receive(:warn) - utils.__report_unsupported_parameters(arguments, unsupported_params) - end - end - end - - describe '#__report_unsupported_method' do - let(:message) do - message = '' - expect(Kernel).to receive(:warn) { |msg| message = msg } - utils.__report_unsupported_method(:foo) - message - end - - it 'prints a warning' do - expect(message).to match(/foo/) - end - end end diff --git a/spec/opensearch/client/integration/security_disabled/validation_integration_spec.rb b/spec/opensearch/client/integration/security_disabled/validation_integration_spec.rb deleted file mode 100644 index 1717a7450..000000000 --- a/spec/opensearch/client/integration/security_disabled/validation_integration_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -require_relative '../../../../spec_helper' -require 'logger' - -describe 'OpenSearch validation integration' do - it 'Validates for OpenSearch' do - client = OpenSearch::Client.new( - host: OPENSEARCH_URL, - logger: Logger.new($stderr) - ) - expect(client.instance_variable_get('@verified')).to be false - client.count - expect(client.instance_variable_get('@verified')).to be true - end -end diff --git a/spec/opensearch/client/integration/security_enabled/client_integration_spec.rb b/spec/opensearch/client/integration/security_enabled/client_integration_spec.rb index 001bceef8..adf34e03d 100644 --- a/spec/opensearch/client/integration/security_enabled/client_integration_spec.rb +++ b/spec/opensearch/client/integration/security_enabled/client_integration_spec.rb @@ -6,6 +6,8 @@ # # Modifications Copyright OpenSearch Contributors. See # GitHub history for details. + +# rubocop:disable RSpec/MultipleExpectations, RSpec/ExampleLength require_relative '../../../../spec_helper' require 'logger' @@ -22,22 +24,82 @@ context 'Integrates with opensearch API' do it 'performs the API methods' do - expect do - # Index a document - client.index(index: 'test-index', id: '1', body: { title: 'Test' }) + # Ping the cluster + expect(client.ping).to be_truthy + + # Delete the index if it exists + client.indices.delete(index: 'movies') if client.indices.exists(index: 'movies') + + # Create index movies with settings and mappings + client.indices.create( + index: 'movies', + body: { + settings: { + number_of_shards: 1, + number_of_replicas: 0 + }, + mappings: { + properties: { + title: { type: 'text' }, + director: { type: 'text' }, + year: { type: 'date' } + } + } + } + ) + + # Check if the created index has the correct settings and mappings + index_settings = client.indices.get_settings(index: 'movies') + expect(index_settings['movies']['settings']['index']['number_of_shards']).to eq '1' + expect(index_settings['movies']['settings']['index']['number_of_replicas']).to eq '0' + + index_mappings = client.indices.get_mapping(index: 'movies') + expect(index_mappings['movies']['mappings']['properties']['title']['type']).to eq 'text' + expect(index_mappings['movies']['mappings']['properties']['director']['type']).to eq 'text' + expect(index_mappings['movies']['mappings']['properties']['year']['type']).to eq 'date' + + # Index a document + client.index(index: 'movies', id: 1, body: { title: 'Test 1', director: 'Director', year: '2020-01-01' }) + + # Bulk index 3 documents + client.bulk( + index: 'movies', + body: [ + { index: { _id: 2, data: { title: 'Test 2', director: 'Director 2', year: '2020-01-02' } } }, + { index: { _id: 3, data: { title: 'OpenSearch 3', director: 'Director 3', year: '2020-01-03' } } }, + { index: { _id: 4, data: { title: 'OpenSearch 4', director: 'Director 4', year: '2020-01-04' } } } + ] + ) + + # Refresh the index + client.indices.refresh(index: 'movies') + + # Search + response = client.search(index: 'movies', body: { query: { match: { title: 'Test' } } }) + + expect(response['hits']['total']['value']).to eq 2 + expect(response['hits']['hits'][0]['_source']['title']).to eq 'Test 1' + + # Delete the index + client.indices.delete(index: 'movies') + + # Execute delete index without providing index name + expect { client.indices.delete }.to raise_error 'Required argument \'index\' missing' - # Refresh the index - client.indices.refresh(index: 'test-index') + # Delete a non-existent index without ignoring 404 + expect { client.indices.delete(index: 'movies') }.to raise_error(OpenSearch::Transport::Transport::Errors::NotFound) - # Search - response = client.search(index: 'test-index', body: { query: { match: { title: 'test' } } }) + # Delete a non-existent index ignoring 404 + expect(client.indices.delete(index: 'movies', ignore: [404])).to be_falsey - expect(response['hits']['total']['value']).to eq 1 - expect(response['hits']['hits'][0]['_source']['title']).to eq 'Test' + # Using unsupported query parameter + expect { client.ping(invalid: 'invalid') }.to raise_error 'URL parameter \'invalid\' is not supported' - # Delete the index - client.indices.delete(index: 'test-index') - end.not_to raise_error + # Create, get, and delete an index with HTTP methods + client.http.put('books', body: { settings: { number_of_shards: 1, number_of_replicas: 0 } }) + expect(client.http.get('books')['books']['settings']['index']['number_of_shards']).to eq '1' + expect(client.http.delete('books')).to be_truthy end end end +# rubocop:enable RSpec/MultipleExpectations, RSpec/ExampleLength diff --git a/spec/opensearch/client/integration/security_enabled/validation_integration_spec.rb b/spec/opensearch/client/integration/security_enabled/validation_integration_spec.rb deleted file mode 100644 index 40d438de8..000000000 --- a/spec/opensearch/client/integration/security_enabled/validation_integration_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -require_relative '../../../../spec_helper' -require 'logger' - -describe 'OpenSearch validation integration with security plugin enabled' do - it 'Validates for OpenSearch' do - client = OpenSearch::Client.new( - host: OPENSEARCH_URL, - logger: Logger.new($stderr), - transport_options: { ssl: { verify: false } } - ) - expect(client.instance_variable_get('@verified')).to be false - client.count - expect(client.instance_variable_get('@verified')).to be true - end -end diff --git a/spec/opensearch/client/unit/opensearch_client_spec.rb b/spec/opensearch/client/unit/opensearch_client_spec.rb deleted file mode 100644 index c43290714..000000000 --- a/spec/opensearch/client/unit/opensearch_client_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. - -require_relative '../../../spec_helper' - -describe 'OpenSearch::Client#respond_to_missing?' do - it 'returns to correct results' do - client = OpenSearch::Client.new - expect(client.send(:respond_to_missing?, :perform_request)).to be true - expect(client.send(:respond_to_missing?, :something_else)).to be false - end -end diff --git a/spec/opensearch/client/unit/opensearch_product_validation_spec.rb b/spec/opensearch/client/unit/opensearch_product_validation_spec.rb deleted file mode 100644 index a014d6854..000000000 --- a/spec/opensearch/client/unit/opensearch_product_validation_spec.rb +++ /dev/null @@ -1,199 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../../../spec_helper' -require 'webmock/rspec' - -describe 'OpenSearch: Validation' do - let(:host) { 'http://localhost:9200' } - let(:verify_request_stub) do - stub_request(:get, host) - .to_return(status: status, body: body, headers: headers) - end - let(:count_request_stub) do - stub_request(:post, "#{host}/_count") - .to_return(status: 200, body: nil, headers: {}) - end - let(:status) { 200 } - let(:body) { {}.to_json } - let(:client) { OpenSearch::Client.new } - let(:headers) do - { 'content-type' => 'json' } - end - - def error_requests_and_expectations(message = OpenSearch::NOT_SUPPORTED_WARNING) - expect { client.count }.to raise_error OpenSearch::UnsupportedProductError, message - assert_requested :get, host - assert_not_requested :post, "#{host}/_count" - expect { client.cluster.health }.to raise_error OpenSearch::UnsupportedProductError, message - expect(client.instance_variable_get('@verified')).to be false - expect { client.cluster.health }.to raise_error OpenSearch::UnsupportedProductError, message - end - - def valid_requests_and_expectations - expect(client.instance_variable_get('@verified')).to be false - assert_not_requested :get, host - - client.count - expect(client.instance_variable_get('@verified')) - assert_requested :get, host - assert_requested :post, "#{host}/_count" - end - - context 'When OpenSearch replies with status 401' do - let(:status) { 401 } - let(:body) { {}.to_json } - - it 'Verifies the request but shows a warning' do - stderr = $stderr - fake_stderr = StringIO.new - $stderr = fake_stderr - - verify_request_stub - count_request_stub - - valid_requests_and_expectations - - fake_stderr.rewind - expect(fake_stderr.string).to eq("#{OpenSearch::SECURITY_PRIVILEGES_VALIDATION_WARNING}\n") - ensure - $stderr = stderr - end - end - - context 'When OpenSearch replies with status 403' do - let(:status) { 403 } - let(:body) { {}.to_json } - - it 'Verifies the request but shows a warning' do - stderr = $stderr - fake_stderr = StringIO.new - $stderr = fake_stderr - - verify_request_stub - count_request_stub - - valid_requests_and_expectations - - fake_stderr.rewind - expect(fake_stderr.string).to eq("#{OpenSearch::SECURITY_PRIVILEGES_VALIDATION_WARNING}\n") - ensure - $stderr = stderr - end - end - - context 'When the OpenSearch version is 2.0.0' do - context 'With a valid OpenSearch response' do - let(:body) { { 'version' => { 'number' => '2.0.0', 'distribution' => 'opensearch' } }.to_json } - let(:headers) do - { - 'content-type' => 'json' - } - end - - it 'Makes requests and passes validation' do - verify_request_stub - count_request_stub - - valid_requests_and_expectations - end - end - - context 'When the distribution is not present' do - let(:body) { { 'version' => { 'number' => '2.0.0' } }.to_json } - - it 'Fails validation' do - verify_request_stub - - expect(client.instance_variable_get('@verified')).to be false - assert_not_requested :get, host - - error_requests_and_expectations - end - end - end - - context 'When the Elasticsearch version is >= 6.0' do - context 'With a valid Elasticsearch response' do - let(:body) { { 'version' => { 'number' => '6.0.0' } }.to_json } - let(:headers) do - { - 'content-type' => 'json' - } - end - - it 'Makes requests and passes validation' do - verify_request_stub - count_request_stub - - valid_requests_and_expectations - end - end - end - - context 'When the Elasticsearch version is >= 8.0.0' do - context 'With a valid Elasticsearch response' do - let(:body) { { 'version' => { 'number' => '8.0.0' } }.to_json } - let(:headers) do - { - 'content-type' => 'json' - } - end - - it 'Fails validation' do - verify_request_stub - count_request_stub - - error_requests_and_expectations - end - end - end - - context 'When there is no version data' do - let(:body) { {}.to_json } - - it 'Raises an exception and client doesnae work' do - verify_request_stub - error_requests_and_expectations - end - end - - context 'When doing a yaml content-type request' do - let(:client) do - OpenSearch::Client.new(transport_options: { headers: { accept: 'application/yaml', - content_type: 'application/yaml' } }) - end - - let(:headers) { { 'content-type' => 'application/yaml' } } - let(:body) { "---\nversion:\n number: \"2.0.0\"\n distribution: \"opensearch\"\n" } - - it 'validates' do - verify_request_stub - count_request_stub - valid_requests_and_expectations - end - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cb8d00e31..019f33093 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -29,6 +29,7 @@ SimpleCov.start { add_filter %r{^/test|spec/} } end +require 'active_support' require 'ansi' require 'opensearch' require 'opensearch-dsl' @@ -58,7 +59,7 @@ unless defined?(OPENSEARCH_URL) OPENSEARCH_URL = ENV.fetch('OPENSEARCH_URL', nil) || ENV.fetch('TEST_OPENSEARCH_SERVER', nil) || - "http://localhost:#{ENV.fetch('TEST_CLUSTER_PORT', nil) || 9200}" + "https://admin:myStrongPassword123!@localhost:#{ENV.fetch('TEST_CLUSTER_PORT', nil) || 9200}" end DEFAULT_CLIENT = OpenSearch::Client.new(host: OPENSEARCH_URL, @@ -83,7 +84,7 @@ def jruby? # The names of the connected nodes. # @return [ Array ] The node names. def node_names - node_stats = default_client.perform_request('GET', '_nodes/stats').body + node_stats = default_client.transport.perform_request('GET', '_nodes/stats').body $node_names ||= node_stats['nodes'].collect do |name, stats| stats['name'] end @@ -99,22 +100,6 @@ class NotFound < StandardError; end module HelperModule def self.included(context) - context.let(:client_double) do - Class.new { include OpenSearch::API }.new.tap do |client| - expect(client).to receive(:perform_request).with(*expected_args).and_return(response_double) - end - end - - context.let(:client) do - Class.new { include OpenSearch::API }.new.tap do |client| - expect(client).to receive(:perform_request).with(*expected_args).and_return(response_double) - end - end - - context.let(:response_double) do - double('response', status: 200, body: {}, headers: {}) - end - context.let(:hosts) { OPENSEARCH_HOSTS } end end